TUN-6531: Implement ICMP proxy for Windows using IcmpSendEcho

This commit is contained in:
Chung-Ting Huang
2022-08-29 18:49:07 +01:00
parent 7a19798682
commit 3e0ff3a771
7 changed files with 472 additions and 17 deletions

View File

@@ -15,6 +15,7 @@ import (
const (
defaultCloseAfterIdle = time.Second * 15
mtu = 1500
icmpTimeoutMs = 1000
)
var (
@@ -42,3 +43,11 @@ func newICMPConn(listenIP netip.Addr) (*icmp.PacketConn, error) {
}
return icmp.ListenPacket(network, listenIP.String())
}
func getICMPEcho(pk *packet.ICMP) (*icmp.Echo, error) {
echo, ok := pk.Message.Body.(*icmp.Echo)
if !ok {
return nil, fmt.Errorf("expect ICMP echo, got %s", pk.Type)
}
return echo, nil
}