mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2026-05-22 13:56:30 +03:00
Respond with ICMPv6 Packet Too Big over network
This commit is contained in:
@@ -4,6 +4,9 @@ import (
|
||||
"crypto/ed25519"
|
||||
|
||||
"github.com/yggdrasil-network/yggdrasil-go/src/address"
|
||||
"golang.org/x/net/icmp"
|
||||
"golang.org/x/net/ipv6"
|
||||
|
||||
//"github.com/yggdrasil-network/yggdrasil-go/src/crypto"
|
||||
//"github.com/yggdrasil-network/yggdrasil-go/src/yggdrasil"
|
||||
|
||||
@@ -70,6 +73,17 @@ func (tun *TunAdapter) write() {
|
||||
if len(bs) < 40 {
|
||||
continue
|
||||
}
|
||||
tun.log.Println(len(bs), tun.MTU())
|
||||
if len(bs) > int(tun.MTU()) {
|
||||
ptb := &icmp.PacketTooBig{
|
||||
MTU: int(tun.mtu),
|
||||
Data: bs[:40],
|
||||
}
|
||||
if packet, err := CreateICMPv6(bs[8:24], bs[24:40], ipv6.ICMPTypePacketTooBig, 0, ptb); err == nil {
|
||||
_, _ = tun.core.WriteTo(packet, from)
|
||||
}
|
||||
continue
|
||||
}
|
||||
var srcAddr, dstAddr address.Address
|
||||
var srcSubnet, dstSubnet address.Subnet
|
||||
copy(srcAddr[:], bs[8:])
|
||||
|
||||
Reference in New Issue
Block a user