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