5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-09-19 00:59:37 +00:00

Return ICMPv6 Destination Unreachable for unknown destinations (#748)

* Return ICMPv6 Destination Unreachable for unknown destinations

* Update go.mod/go.sum for yggdrasil-extras

* go mod tidy
This commit is contained in:
Neil Alexander 2020-12-06 19:47:25 +00:00 committed by GitHub
parent cb3d8647de
commit b9f35c5530
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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?