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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user