From 020b4b59930045e634de2da04f68ebb6b08e818a Mon Sep 17 00:00:00 2001 From: wlynxg Date: Sun, 29 Sep 2024 10:02:01 +0800 Subject: [PATCH] fix: use `github.com/wlynxg/anet` package replace `net` to get `InterfaceAddrs()` --- go.mod | 1 + go.sum | 2 ++ net/net.go | 3 ++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index e3249bf..c8bc517 100644 --- a/go.mod +++ b/go.mod @@ -20,6 +20,7 @@ require ( github.com/multiformats/go-base36 v0.2.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect + github.com/wlynxg/anet v0.0.4 // indirect golang.org/x/crypto v0.18.0 // indirect golang.org/x/sys v0.16.0 // indirect gopkg.in/yaml.v3 v3.0.0 // indirect diff --git a/go.sum b/go.sum index 076449b..c2856c8 100644 --- a/go.sum +++ b/go.sum @@ -34,6 +34,8 @@ github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/wlynxg/anet v0.0.4 h1:0de1OFQxnNqAu+x2FAKKCVIrnfGKQbs7FQz++tB0+Uw= +github.com/wlynxg/anet v0.0.4/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= diff --git a/net/net.go b/net/net.go index 10fcff7..bf77263 100644 --- a/net/net.go +++ b/net/net.go @@ -11,6 +11,7 @@ import ( "net" ma "github.com/multiformats/go-multiaddr" + "github.com/wlynxg/anet" ) // Conn is the equivalent of a net.Conn object. It is the @@ -387,7 +388,7 @@ func WrapPacketConn(pc net.PacketConn) (PacketConn, error) { // InterfaceMultiaddrs will return the addresses matching net.InterfaceAddrs func InterfaceMultiaddrs() ([]ma.Multiaddr, error) { - addrs, err := net.InterfaceAddrs() + addrs, err := anet.InterfaceAddrs() if err != nil { return nil, err }