修复了macos下ipv6不能指定dev的问题

This commit is contained in:
tsosunchia
2023-08-31 13:19:21 +08:00
parent 9228cdf307
commit 96671d263c
2 changed files with 2 additions and 2 deletions

View File

@@ -10,7 +10,6 @@ import (
"sync"
"time"
"github.com/xgadget-lab/nexttrace/trace/internal"
"golang.org/x/net/context"
"golang.org/x/net/icmp"
"golang.org/x/net/ipv6"
@@ -66,7 +65,7 @@ func (t *ICMPTracerv6) Execute() (*Result, error) {
var err error
t.icmpListen, err = internal.ListenICMP("ip6:58", t.SrcAddr)
t.icmpListen, err = net.ListenPacket("ip6:58", t.SrcAddr)
if err != nil {
return &t.res, err
}

View File

@@ -28,6 +28,7 @@ var (
}
)
// 会造成指定出口IP功能不可使用
func ListenICMP(network string, laddr string) (net.PacketConn, error) {
if os.Getuid() == 0 { // root
return net.ListenPacket(network, laddr)