Properly count IPv4 and IPv6 networks listening (exclude link-local ones). Close #22

This commit is contained in:
Kleissner
2021-05-18 23:22:11 +02:00
parent 9eb1127b40
commit 8e2043728c
3 changed files with 33 additions and 7 deletions

View File

@@ -481,12 +481,11 @@ func isPacketSizeExceed(currentSize int, testSize int) bool {
return currentSize+testSize > udpMaxPacketSize-packetLengthMin
}
func selfFeatureSupport() (feature byte) {
// networksMutex not needed here
if len(networks4) > 0 {
func FeatureSupport() (feature byte) {
if countListen4 > 0 {
feature |= 1 << FeatureIPv4Listen
}
if len(networks6) > 0 {
if countListen6 > 0 {
feature |= 1 << FeatureIPv6Listen
}
return feature
@@ -514,7 +513,7 @@ createPacketLoop:
packetSize := announcementPayloadHeaderSize
raw[0] = byte(ProtocolVersion) // Protocol
raw[1] = selfFeatureSupport() // Feature support
raw[1] = FeatureSupport() // Feature support
//raw[2] = Actions // Action bit array
binary.LittleEndian.PutUint32(raw[3:7], BlockchainHeight)
binary.LittleEndian.PutUint64(raw[7:15], BlockchainVersion)
@@ -656,7 +655,7 @@ createPacketLoop:
packetSize := announcementPayloadHeaderSize
raw[0] = byte(ProtocolVersion) // Protocol
raw[1] = selfFeatureSupport() // Feature support
raw[1] = FeatureSupport() // Feature support
//raw[2] = Actions // Action bit array
binary.LittleEndian.PutUint32(raw[3:7], BlockchainHeight)
binary.LittleEndian.PutUint64(raw[7:15], BlockchainVersion)