diff --git a/netroute_stub.go b/netroute_stub.go new file mode 100644 index 0000000..0ec5397 --- /dev/null +++ b/netroute_stub.go @@ -0,0 +1,22 @@ +// A stub routing table conformant interface for js/wasm environments. + +// +build js,wasm + +package netroute + +import ( + "net" + + "github.com/google/gopacket/routing" +) + +func New() (routing.Router, error) { + rtr := &router{} + rtr.ifaces = make(map[int]net.Interface) + rtr.ifaces[0] = net.Interface{} + rtr.addrs = make(map[int]ipAddrs) + rtr.addrs[0] = ipAddrs{} + rtr.v4 = routeSlice{&rtInfo{}} + rtr.v6 = routeSlice{&rtInfo{}} + return rtr, nil +}