fix(icmp): ICMP tunnel not working on Windows due to wildcard bind (#98)

On Windows, icmp.ListenPacket("ip4:icmp", "0.0.0.0") does not reliably
deliver ICMP packets (golang/go#38427). Add a platform-specific
ListenPacket helper that binds to a discovered interface address and
enables SIO_RCVALL via WSAIoctl for promiscuous receive.

Fixes go-gost/x#36
This commit is contained in:
ginuerzh
2026-05-27 21:02:26 +08:00
committed by GitHub
parent 618cc7fd9c
commit 87b055a83b
4 changed files with 103 additions and 6 deletions
+2 -3
View File
@@ -14,7 +14,6 @@ import (
icmp_pkg "github.com/go-gost/x/internal/util/icmp"
"github.com/go-gost/x/registry"
"github.com/quic-go/quic-go"
"golang.org/x/net/icmp"
)
func init() {
@@ -87,9 +86,9 @@ func (d *icmpDialer) Dial(ctx context.Context, addr string, opts ...dialer.DialO
var pc net.PacketConn
if d.ip6 {
pc, err = icmp.ListenPacket("ip6:ipv6-icmp", "")
pc, err = icmp_pkg.ListenPacket("ip6:ipv6-icmp", "")
} else {
pc, err = icmp.ListenPacket("ip4:icmp", "")
pc, err = icmp_pkg.ListenPacket("ip4:icmp", "")
}
if err != nil {
return