add route every time

This commit is contained in:
afeiszli 2021-12-11 12:13:41 -05:00
parent 548997f9ef
commit 833151c86d
3 changed files with 8 additions and 2 deletions

View file

@ -5,7 +5,9 @@ RUN apk add build-base
WORKDIR /app WORKDIR /app
COPY . . COPY . .
ENV GO111MODULE=auto ENV GO111MODULE=auto
RUN GOOS=linux CGO_ENABLED=1 go build -ldflags="-s -X 'main.version=$version'" -o netmaker main.go
# RUN GOOS=linux CGO_ENABLED=1 go build -ldflags="-s -X 'main.version=$version'" -o netmaker main.go
RUN GOOS=linux CGO_ENABLED=1 go build -tags debug -ldflags="-s -X 'main.version=$version'" -o netmaker main.go
FROM alpine:3.13.6 FROM alpine:3.13.6
# add a c lib # add a c lib
RUN apk add gcompat iptables RUN apk add gcompat iptables

View file

@ -216,6 +216,8 @@ func LeaveNetwork(network string) error {
_, _ = ncutils.RunCmd("route delete "+ip+" mask "+mask+" "+node.Address, true) _, _ = ncutils.RunCmd("route delete "+ip+" mask "+mask+" "+node.Address, true)
} else if ncutils.IsFreeBSD() { } else if ncutils.IsFreeBSD() {
_, _ = ncutils.RunCmd("route del -net "+node.NetworkSettings.AddressRange+" -interface "+node.Interface, true) _, _ = ncutils.RunCmd("route del -net "+node.NetworkSettings.AddressRange+" -interface "+node.Interface, true)
} else if ncutils.IsLinux() {
_, _ = ncutils.RunCmd("ip -4 route del "+node.NetworkSettings.AddressRange+" dev "+node.Interface, false)
} }
return RemoveLocalInstance(cfg, network) return RemoveLocalInstance(cfg, network)
} }

View file

@ -296,9 +296,11 @@ func InitWireguard(node *models.Node, privkey string, peers []wgtypes.PeerConfig
} }
} }
//extra network route setting required for freebsd and windows //extra network route setting
if ncutils.IsFreeBSD() { if ncutils.IsFreeBSD() {
_, _ = ncutils.RunCmd("route add -net "+nodecfg.NetworkSettings.AddressRange+" -interface "+ifacename, true) _, _ = ncutils.RunCmd("route add -net "+nodecfg.NetworkSettings.AddressRange+" -interface "+ifacename, true)
} else if ncutils.IsLinux() {
_, _ = ncutils.RunCmd("ip -4 route add "+nodecfg.NetworkSettings.AddressRange+" dev "+ifacename, false)
} }
return err return err