Skip to content

Commit 6263a1e

Browse files
committed
add js stub impl
1 parent 55bb74e commit 6263a1e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

netroute_stub.go

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// A stub routing table conformant interface for js/wasm environments.
2+
3+
// +build js,wasm
4+
5+
package netroute
6+
7+
import (
8+
"net"
9+
10+
"github.com/google/gopacket/routing"
11+
)
12+
13+
func New() (routing.Router, error) {
14+
rtr := &router{}
15+
rtr.ifaces = make(map[int]net.Interface)
16+
rtr.ifaces[0] = net.Interface{}
17+
rtr.addrs = make(map[int]ipAddrs)
18+
rtr.addrs[0] = ipAddrs{}
19+
rtr.v4 = routeSlice{&rtInfo{}}
20+
rtr.v6 = routeSlice{&rtInfo{}}
21+
return rtr, nil
22+
}

0 commit comments

Comments
 (0)