This commit is contained in:
JackDoan 2026-02-17 15:00:00 -06:00
parent 27d764ba57
commit 7498c6846d
6 changed files with 23 additions and 9 deletions

View file

@ -322,7 +322,7 @@ func (t *tun) reload(c *config.C, initial bool) error {
return nil
}
if !initial {
if initial {
t.snatAddr = prepareSnatAddr(t, t.l, c, routes)
}

View file

@ -413,6 +413,10 @@ func (t *tun) reload(c *config.C, initial bool) error {
return nil
}
if initial {
t.snatAddr = prepareSnatAddr(t, t.l, c, routes)
}
routeTree, err := makeRouteTree(t.l, routes, false)
if err != nil {
return err

View file

@ -182,7 +182,7 @@ func (t *tun) reload(c *config.C, initial bool) error {
return nil
}
if !initial {
if initial {
t.snatAddr = prepareSnatAddr(t, t.l, c, routes)
}
@ -328,7 +328,8 @@ func (t *tun) addIPs(link netlink.Link) error {
Label: t.vpnNetworks[i].Addr().Zone(),
}
}
if t.snatAddr.IsValid() {
if t.snatAddr.IsValid() && len(t.vpnNetworks) > 0 { //TODO unsafe-routers should be able to snat and be snatted
newAddrs = append(newAddrs, &netlink.Addr{
IPNet: &net.IPNet{
IP: t.snatAddr.Addr().AsSlice(),
@ -429,11 +430,12 @@ func (t *tun) Activate() error {
return fmt.Errorf("failed to set default route MTU for %s: %w", t.vpnNetworks[i], err)
}
}
if t.snatAddr.IsValid() {
if err = t.setDefaultRoute(t.snatAddr); err != nil {
return fmt.Errorf("failed to set default route MTU for %s: %w", t.snatAddr, err)
}
}
//TODO snat and be snatted
//if t.snatAddr.IsValid() {
// if err = t.setDefaultRoute(t.snatAddr); err != nil {
// return fmt.Errorf("failed to set default route MTU for %s: %w", t.snatAddr, err)
// }
//}
// Set the routes
if err = t.addRoutes(false); err != nil {

View file

@ -352,6 +352,10 @@ func (t *tun) reload(c *config.C, initial bool) error {
return nil
}
if initial {
t.snatAddr = prepareSnatAddr(t, t.l, c, routes)
}
routeTree, err := makeRouteTree(t.l, routes, false)
if err != nil {
return err

View file

@ -273,6 +273,10 @@ func (t *tun) reload(c *config.C, initial bool) error {
return nil
}
if initial {
t.snatAddr = prepareSnatAddr(t, t.l, c, routes)
}
routeTree, err := makeRouteTree(t.l, routes, false)
if err != nil {
return err

View file

@ -105,7 +105,7 @@ func (t *winTun) reload(c *config.C, initial bool) error {
return nil
}
if !initial {
if initial {
t.snatAddr = prepareSnatAddr(t, t.l, c, routes)
}