Prevent link-local to non-link-local connections for multicast and broadcast.

This commit is contained in:
Kleissner
2021-03-01 04:13:18 +01:00
parent fec5644b9f
commit c34adc472c
2 changed files with 10 additions and 0 deletions

View File

@@ -71,6 +71,11 @@ func (network *Network) BroadcastIPv4Listen() {
continue
}
// For good network practice (and reducing amount of parallel connections), do not allow link-local to talk to non-link-local addresses.
if sender.(*net.UDPAddr).IP.IsLinkLocalUnicast() != network.address.IP.IsLinkLocalUnicast() {
continue
}
//fmt.Printf("BroadcastIPv4Listen from %s at network %s\n", sender.String(), network.address.String())
if length < packetLengthMin {

View File

@@ -117,6 +117,11 @@ func (network *Network) MulticastIPv6Listen() {
continue
}
// For good network practice (and reducing amount of parallel connections), do not allow link-local to talk to non-link-local addresses.
if sender.(*net.UDPAddr).IP.IsLinkLocalUnicast() != network.address.IP.IsLinkLocalUnicast() {
continue
}
//fmt.Printf("MulticastIPv6Listen from %s at network %s\n", sender.String(), network.address.String())
if length < packetLengthMin {