Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.23.0
require (
github.com/google/gopacket v1.1.19
github.com/stretchr/testify v1.10.0
github.com/wjordan/netinterfaces v0.1.0
golang.org/x/net v0.37.0
golang.org/x/sys v0.31.0
)
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/wjordan/netinterfaces v0.1.0 h1:gLOZRrOc61SsSMmJ0c660bCxA/ZoRT6HBHOYlFyLHyE=
github.com/wjordan/netinterfaces v0.1.0/go.mod h1:Km4e70ZSru7NvdOMl4rqLjGQ2L0kQcBcEtmxZcVoHbI=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
Expand Down
5 changes: 3 additions & 2 deletions netroute_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"unsafe"

"github.com/google/gopacket/routing"
. "github.com/wjordan/netinterfaces"

Check failure on line 21 in netroute_linux.go

View workflow job for this annotation

GitHub Actions / go-check / All

should not use dot imports (ST1001)
)

func New() (routing.Router, error) {
Expand Down Expand Up @@ -87,12 +88,12 @@
}
sort.Sort(rtr.v4)
sort.Sort(rtr.v6)
ifaces, err := net.Interfaces()
ifaces, err := NetInterfaces()
if err != nil {
return nil, err
}
for _, iface := range ifaces {
rtr.ifaces[iface.Index] = iface
rtr.ifaces[iface.Index] = iface.Interface
var addrs ipAddrs
ifaceAddrs, err := iface.Addrs()
if err != nil {
Expand Down
9 changes: 9 additions & 0 deletions netroute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ import (
"testing"
)

func BenchmarkNew(b *testing.B) {
for i := 0; i < b.N; i++ {
_, err := New()
if err != nil {
b.Fatal(err)
}
}
}

func TestRoute(t *testing.T) {
r, err := New()
if err != nil {
Expand Down
Loading