Browse Source

Fix bug with encoding nonstd ip addresses and add debug output

master
Lyndsay Roger 9 years ago
parent
commit
a2ef24a926
  1. 11
      dnsseeder.go

11
dnsseeder.go

@ -221,6 +221,9 @@ func (s *Seeder) addNa(nNa *wire.NetAddress) bool {
if nNa.Port != TWSTDPORT { if nNa.Port != TWSTDPORT {
nt.dnsType = DNSV4NON nt.dnsType = DNSV4NON
// force ipv4 address into a 4 byte buffer
nt.na.IP = nt.na.IP.To4()
// produce the nonstdIP // produce the nonstdIP
nt.nonstdIP = getNonStdIP(nt.na.IP, nt.na.Port) nt.nonstdIP = getNonStdIP(nt.na.IP, nt.na.Port)
} }
@ -247,8 +250,12 @@ func getNonStdIP(rip net.IP, port uint16) net.IP {
b[2] = byte(port >> 8) b[2] = byte(port >> 8)
b[3] = byte(port & 0xff) b[3] = byte(port & 0xff)
//nip := net.IPv4(b[0], b[1], b[2], b[3]) encip := net.IPv4(b[0], b[1], b[2], b[3])
return net.IPv4(b[0], b[1], b[2], b[3]) if config.debug {
log.Printf("debug encode nonstd - realip: %s port: %v encip: %s crc: %x\n", rip.String(), port, encip.String(), crcAddr)
}
return encip
} }
// crc16 produces a crc16 from a byte slice // crc16 produces a crc16 from a byte slice

Loading…
Cancel
Save