mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-24 17:11:35 +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:
parent
cb3d8647de
commit
b9f35c5530
@ -5,6 +5,9 @@ import (
|
|||||||
"github.com/yggdrasil-network/yggdrasil-go/src/crypto"
|
"github.com/yggdrasil-network/yggdrasil-go/src/crypto"
|
||||||
"github.com/yggdrasil-network/yggdrasil-go/src/yggdrasil"
|
"github.com/yggdrasil-network/yggdrasil-go/src/yggdrasil"
|
||||||
|
|
||||||
|
"golang.org/x/net/icmp"
|
||||||
|
"golang.org/x/net/ipv6"
|
||||||
|
|
||||||
"github.com/Arceliar/phony"
|
"github.com/Arceliar/phony"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -147,6 +150,16 @@ func (tun *TunAdapter) _handlePacket(recvd []byte, err error) {
|
|||||||
}
|
}
|
||||||
if addrlen != 16 || (!dstAddr.IsValid() && !dstSnet.IsValid()) {
|
if addrlen != 16 || (!dstAddr.IsValid() && !dstSnet.IsValid()) {
|
||||||
// Couldn't find this node's ygg IP
|
// 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
|
return
|
||||||
}
|
}
|
||||||
// Do we have an active connection for this node address?
|
// Do we have an active connection for this node address?
|
||||||
|
Loading…
Reference in New Issue
Block a user