Add back random iproute2 table index
This commit is contained in:
parent
2e21cd99ef
commit
635920688d
1 changed files with 11 additions and 0 deletions
11
tun_linux.go
11
tun_linux.go
|
|
@ -3,6 +3,7 @@ package tun
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"net"
|
||||
"net/netip"
|
||||
"os"
|
||||
|
|
@ -283,6 +284,16 @@ func (t *NativeTun) Start() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
if t.options.IPRoute2TableIndex == 0 {
|
||||
for {
|
||||
t.options.IPRoute2TableIndex = int(rand.Uint32())
|
||||
routeList, fErr := netlink.RouteListFiltered(netlink.FAMILY_ALL, &netlink.Route{Table: t.options.IPRoute2TableIndex}, netlink.RT_FILTER_TABLE)
|
||||
if len(routeList) == 0 || fErr != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
err = t.setRoute(tunLink)
|
||||
if err != nil {
|
||||
_ = t.unsetRoute0(tunLink)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue