mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 22:25:07 +03:00
Respond with ICMPv6 Packet Too Big over network
This commit is contained in:
parent
57ea61b338
commit
815f2a2822
4 changed files with 16 additions and 23 deletions
|
@ -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:])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue