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
@@ -16,7 +16,6 @@ import (
stats "github.com/go-gost/x/observer/stats/wrapper"
"github.com/go-gost/x/registry"
"github.com/quic-go/quic-go"
"golang.org/x/net/icmp"
)
func init() {
@@ -69,9 +68,9 @@ func (l *icmpListener) Init(md md.Metadata) (err error) {
var conn net.PacketConn
if l.ip6 {
conn, err = icmp.ListenPacket("ip6:ipv6-icmp", addr)
conn, err = icmp_pkg.ListenPacket("ip6:ipv6-icmp", addr)
} else {
conn, err = icmp.ListenPacket("ip4:icmp", addr)
conn, err = icmp_pkg.ListenPacket("ip4:icmp", addr)
}
if err != nil {
return