Return ICMPv6 Destination Unreachable for unknown destinations

This commit is contained in:
Neil Alexander 2020-12-06 13:32:35 +00:00
parent ea58a0f181
commit cb4666bf7d
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -5,6 +5,9 @@ import (
"github.com/yggdrasil-network/yggdrasil-go/src/crypto"
"github.com/yggdrasil-network/yggdrasil-go/src/yggdrasil"
"golang.org/x/net/icmp"
"golang.org/x/net/ipv6"
"github.com/Arceliar/phony"
)
@ -147,6 +150,16 @@ func (tun *TunAdapter) _handlePacket(recvd []byte, err error) {
}
if addrlen != 16 || (!dstAddr.IsValid() && !dstSnet.IsValid()) {
// Couldn't find this node's ygg IP
dlen := len(bs)
if dlen > 900 {
dlen = 900
}
ptb := &icmp.DstUnreach{
Data: bs[:dlen],
}
if packet, err := CreateICMPv6(bs[8:24], bs[24:40], ipv6.ICMPTypeDestinationUnreachable, 0, ptb); err == nil {
tun.writer.writeFrom(nil, packet)
}
return
}
// Do we have an active connection for this node address?