mirror of
https://github.com/slackhq/nebula.git
synced 2026-04-01 07:05:17 +02:00
auto-assign snataddr on Mac+Windows
This commit is contained in:
@@ -216,6 +216,11 @@ func (t *tun) Activate() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if t.snatAddr.IsValid() && t.snatAddr.Addr().Is4() {
|
||||||
|
if err = t.activate4(t.snatAddr); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Run the interface
|
// Run the interface
|
||||||
ifrf.Flags = ifrf.Flags | unix.IFF_UP | unix.IFF_RUNNING
|
ifrf.Flags = ifrf.Flags | unix.IFF_UP | unix.IFF_RUNNING
|
||||||
@@ -317,6 +322,10 @@ func (t *tun) reload(c *config.C, initial bool) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !initial {
|
||||||
|
t.snatAddr = prepareSnatAddr(t, t.l, c, routes)
|
||||||
|
}
|
||||||
|
|
||||||
routeTree, err := makeRouteTree(t.l, routes, false)
|
routeTree, err := makeRouteTree(t.l, routes, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -139,7 +139,12 @@ func (t *winTun) reload(c *config.C, initial bool) error {
|
|||||||
func (t *winTun) Activate() error {
|
func (t *winTun) Activate() error {
|
||||||
luid := winipcfg.LUID(t.tun.LUID())
|
luid := winipcfg.LUID(t.tun.LUID())
|
||||||
|
|
||||||
err := luid.SetIPAddresses(t.vpnNetworks)
|
prefixes := t.vpnNetworks
|
||||||
|
if t.snatAddr.IsValid() {
|
||||||
|
prefixes = append(prefixes, t.snatAddr)
|
||||||
|
}
|
||||||
|
|
||||||
|
err := luid.SetIPAddresses(prefixes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to set address: %w", err)
|
return fmt.Errorf("failed to set address: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user