Skip to content

Commit

Permalink
NET-1224:fix egress route issue for Win in multinet (#784)
Browse files Browse the repository at this point in the history
* fix egress route issue for Win in multinet

* add egress Gw for Linux

* darwin: add gw ip for egress routes

* Revert "darwin: add gw ip for egress routes"

This reverts commit a8a6a5d.

* remove egress route cache after interface reset

* set egress routes from cache on reset

---------

Co-authored-by: abhishek9686 <[email protected]>
  • Loading branch information
yabinma and abhishek9686 authored May 14, 2024
1 parent 88f3f5d commit b3a6114
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 31 deletions.
26 changes: 14 additions & 12 deletions functions/mqhandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,20 @@ func NodeUpdate(client mqtt.Client, msg mqtt.Message) {
case models.NODE_NOOP:
default:
}
// Save new config
newNode.Action = models.NODE_NOOP
config.UpdateNodeMap(network, newNode)
if err := config.WriteNodeConfig(); err != nil {
slog.Warn("failed to write node config", "error", err)
}
nc := wireguard.NewNCIface(config.Netclient(), config.GetNodes())
if err := nc.Configure(); err != nil {
slog.Error("could not configure netmaker interface", "error", err)
return
}
time.Sleep(time.Second)
if ifaceDelta { // if a change caused an ifacedelta we need to notify the server to update the peers
// Save new config
newNode.Action = models.NODE_NOOP
config.UpdateNodeMap(network, newNode)
if err := config.WriteNodeConfig(); err != nil {
slog.Warn("failed to write node config", "error", err)
}
nc := wireguard.NewNCIface(config.Netclient(), config.GetNodes())
if err := nc.Configure(); err != nil {
slog.Error("could not configure netmaker interface", "error", err)
return
}
time.Sleep(time.Second)

doneErr := publishSignal(&newNode, DONE)
if doneErr != nil {
slog.Warn("could not notify server to update peers after interface change", "network:", newNode.Network, "error", doneErr)
Expand Down Expand Up @@ -348,6 +349,7 @@ func resetInterfaceFunc() {
if err := wireguard.SetPeers(false); err != nil {
slog.Error("failed to set peers", err)
}
wireguard.SetRoutesFromCache()
}

// handleEndpointDetection - select best interface for each peer and set it as endpoint
Expand Down
16 changes: 12 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/google/nftables v0.1.0
github.com/google/uuid v1.6.0
github.com/gorilla/websocket v1.5.1
github.com/gravitl/netmaker v0.24.1-0.20240425143610-a3d6a0af09ca
github.com/gravitl/netmaker v0.24.1-0.20240511070838-f8481c75bbd0
github.com/gravitl/tcping v0.1.2-0.20230801110928-546055ebde06
github.com/gravitl/txeh v0.0.0-20230509181318-3778c58bd69f
github.com/guumaster/hostctl v1.1.4
Expand All @@ -25,7 +25,7 @@ require (
github.com/spf13/viper v1.18.2
github.com/stretchr/testify v1.9.0
github.com/vishvananda/netlink v1.1.0
golang.org/x/crypto v0.22.0
golang.org/x/crypto v0.23.0
golang.org/x/exp v0.0.0-20230905200255-921286631fa9
golang.org/x/net v0.24.0
golang.org/x/sys v0.20.0
Expand All @@ -39,21 +39,27 @@ require (

require (
aead.dev/minisign v0.2.0 // indirect
cloud.google.com/go/compute/metadata v0.3.0 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/coreos/go-oidc/v3 v3.9.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/docker v23.0.5+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/go-jose/go-jose/v3 v3.0.3 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.19.0 // indirect
github.com/go-playground/validator/v10 v10.20.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/gorilla/handlers v1.5.2 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
Expand All @@ -79,6 +85,7 @@ require (
github.com/rqlite/gorqlite v0.0.0-20240122221808-a8a425b1a6aa // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
Expand All @@ -90,8 +97,9 @@ require (
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/tools v0.17.0 // indirect
golang.zx2c4.com/wintun v0.0.0-20211104114900-415007cec224 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand Down
Loading

0 comments on commit b3a6114

Please sign in to comment.