diff --git a/go.mod b/go.mod index 40a0a69..300b827 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.19 require ( github.com/pion/logging v0.2.2 github.com/stretchr/testify v1.9.0 + github.com/wlynxg/anet v0.0.1 golang.org/x/net v0.26.0 golang.org/x/sys v0.22.0 ) diff --git a/go.sum b/go.sum index f1a495e..64b08d6 100644 --- a/go.sum +++ b/go.sum @@ -6,6 +6,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/wlynxg/anet v0.0.1 h1:VbkEEgHxPSrRQSiyRd0pmrbcEQAEU2TTb8fb4DmSYoQ= +github.com/wlynxg/anet v0.0.1/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA= golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= diff --git a/stdnet/net.go b/stdnet/net.go index 7ca482b..3d2a6e8 100644 --- a/stdnet/net.go +++ b/stdnet/net.go @@ -10,6 +10,7 @@ import ( "net" "github.com/pion/transport/v3" + "github.com/wlynxg/anet" ) const ( @@ -38,15 +39,15 @@ var _ transport.Net = &Net{} func (n *Net) UpdateInterfaces() error { ifs := []*transport.Interface{} - oifs, err := net.Interfaces() + oifs, err := anet.Interfaces() if err != nil { return err } - for _, oif := range oifs { - ifc := transport.NewInterface(oif) + for i := range oifs { + ifc := transport.NewInterface(oifs[i]) - addrs, err := oif.Addrs() + addrs, err := anet.InterfaceAddrsByInterface(&oifs[i]) if err != nil { return err } diff --git a/stdnet/net_test.go b/stdnet/net_test.go index c5b148e..a1b619e 100644 --- a/stdnet/net_test.go +++ b/stdnet/net_test.go @@ -28,7 +28,7 @@ func TestStdNet(t *testing.T) { return } - log.Debugf("interfaces: %+v", interfaces) + log.Debugf("interfaces: %+v", interfaces) for _, ifc := range interfaces { if ifc.Name == lo0String { _, err := ifc.Addrs()