Normalise IP addresses when adding to collections

This commit is contained in:
Bryan Boreham committed 2014-09-10 15:25:10 +01:00
1 parent e5bd3933d8
commit 83175cdd0a
1 file changed
+5 -2
+5 -2
View File
@@ -68,7 +68,7 @@ func (cm *ConnectionMaker) queryLoop(queryChan <-chan *ConnectionMakerInteractio
}
switch {
case query.code == CMInitiate:
cm.cmdLineAddress[query.address] = true
cm.cmdLineAddress[NormalisePeerAddr(query.address)] = true
tickNow()
case query.code == CMStatus:
query.resultChan <- cm.status()
@@ -122,9 +122,11 @@ func (cm *ConnectionMaker) checkStateAndAttemptConnections(now time.Time) {
// try both portnumber of connection and standart port
if host, port, err := ExtractHostPort(address); err == nil {
if port != Port {
// This is an address with port, that is not the standard port
validTarget[address] = true
}
validTarget[host] = true
// Add the address with standard port
validTarget[NormalisePeerAddr(host)] = true
}
}
})
@@ -149,6 +151,7 @@ func (cm *ConnectionMaker) checkStateAndAttemptConnections(now time.Time) {
}
func (cm *ConnectionMaker) addToTargets(address string) {
address = NormalisePeerAddr(address)
target := cm.targets[address]
if target == nil {
target = &Target{