Skip to content

Commit

Permalink
resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishek9686 committed Jun 11, 2024
2 parents f2a8df4 + 99d8184 commit d36d185
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 27 deletions.
4 changes: 2 additions & 2 deletions functions/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func startGoRoutines(wg *sync.WaitGroup) context.CancelFunc {

if updateConfig {
if err := config.WriteNetclientConfig(); err != nil {
slog.Error("error writing endpoint/port netclient config file", "error", err)
slog.Warn("error writing endpoint/port netclient config file", "error", err)
}
}
slog.Info("configuring netmaker wireguard interface")
Expand Down Expand Up @@ -247,7 +247,7 @@ func startGoRoutines(wg *sync.WaitGroup) context.CancelFunc {
if pullresp.ChangeDefaultGw && !pullresp.DefaultGwIp.Equal(gwIP) {
err = wireguard.SetInternetGw(pullresp.DefaultGwIp)
if err != nil {
slog.Error("failed to set inet gw", "error", err)
slog.Warn("failed to set inet gw", "error", err)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion functions/fail_over.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func handlePeerFailOver(signal models.Signal) error {
TimeStamp: time.Now().Unix(),
})
if err != nil {
slog.Error("failed to signal peer", "error", err.Error())
slog.Warn("failed to signal peer", "error", err.Error())
} else {
signalThrottleCache.Delete(signal.FromHostID)
}
Expand Down
3 changes: 3 additions & 0 deletions functions/mqpublish.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ func publish(serverName, dest string, msg []byte, qos byte) error {
if err != nil {
return err
}
if Mqclient == nil || !Mqclient.IsConnectionOpen() {
return errors.New("cannot publish ... Mqclient not connected")
}
if token := Mqclient.Publish(dest, qos, false, encrypted); !token.WaitTimeout(30*time.Second) || token.Error() != nil {
logger.Log(0, "could not connect to broker at "+serverName)
var err error
Expand Down
2 changes: 1 addition & 1 deletion metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func extPeerConnStatus(address string) (bool, int64) {
slog.Debug("[metrics] checking external peer connectivity", "address", address)
pinger, err := ping.NewPinger(address)
if err != nil {
slog.Error("could not initiliaze ping for metrics on peer address", "address", address, "err", err)
slog.Warn("could not initiliaze ping for metrics on peer address", "address", address, "err", err)
} else {
pinger.SetPrivileged(true)
pinger.Count = 3
Expand Down
46 changes: 23 additions & 23 deletions wireguard/wireguard_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (nc *NCIface) ApplyAddrs() error {
if addr.IP != nil && addr.Network.IP != nil {
slog.Info("adding address", "address", addr.IP.String(), "network", addr.Network.String())
if err := netlink.AddrAdd(l, &netlink.Addr{IPNet: &net.IPNet{IP: addr.IP, Mask: addr.Network.Mask}}); err != nil {
slog.Error("error adding addr", "error", err.Error())
slog.Warn("error adding addr", "error", err.Error())
}
}

Expand Down Expand Up @@ -173,7 +173,7 @@ func RemoveRoutes(addrs []ifaceAddress) {
Dst: &addr.Network,
Priority: EgressRouteMetric,
}); err != nil {
slog.Error("error removing route", "error", err.Error())
slog.Warn("error removing route", "error", err.Error())
}
}
}
Expand All @@ -199,7 +199,7 @@ func SetRoutes(addrs []ifaceAddress) error {
Dst: &addr.Network,
Priority: EgressRouteMetric,
}); err != nil && !strings.Contains(err.Error(), "file exists") {
slog.Error("error adding route", "error", err.Error())
slog.Warn("error adding route", "error", err.Error())
}
}
return nil
Expand Down Expand Up @@ -468,9 +468,9 @@ func restoreInternetGwV6() (err error) {

//delete default gateway at first
if err := netlink.RouteDel(&gwRoute); err != nil {
slog.Error("remove default gateway failed", "error", err.Error())
slog.Error("please remove the gateway route manually")
slog.Error("gateway route: ", gwRoute.String())
slog.Warn("remove default gateway failed", "error", err.Error())
slog.Warn("please remove the gateway route manually")
slog.Warn("gateway route: ", gwRoute.String())
}

//delete rules
Expand All @@ -485,9 +485,9 @@ func restoreInternetGwV6() (err error) {
tRule.Table = RouteTableName
tRule.Priority = 3000
if err := netlink.RuleDel(tRule); err != nil {
slog.Error("delete rule failed", "error", err.Error())
slog.Error("please remove the rule manually")
slog.Error("rule: ", tRule.String())
slog.Warn("delete rule failed", "error", err.Error())
slog.Warn("please remove the rule manually")
slog.Warn("rule: ", tRule.String())
}
//second rule :ip rule add table main suppress_prefixlength 0
sRule := netlink.NewRule()
Expand All @@ -497,8 +497,8 @@ func restoreInternetGwV6() (err error) {
sRule.SuppressPrefixlen = 0
sRule.Priority = 2500
if err := netlink.RuleDel(sRule); err != nil {
slog.Error("delete rule failed", "error", err.Error())
slog.Error("please remove the rule manually", "rule: ", sRule.String())
slog.Warn("delete rule failed", "error", err.Error())
slog.Warn("please remove the rule manually", "rule: ", sRule.String())
}
//third rule :ip rule add from 68.183.79.137 table main
lIp, err := getLocalIpByDefaultInterfaceName()
Expand All @@ -516,8 +516,8 @@ func restoreInternetGwV6() (err error) {
mRule.Table = unix.RT_TABLE_MAIN
mRule.Priority = 2000
if err := netlink.RuleDel(mRule); err != nil {
slog.Error("delete rule failed", "error", err.Error())
slog.Error("please remove the rule manually", "rule: ", mRule.String())
slog.Warn("delete rule failed", "error", err.Error())
slog.Warn("please remove the rule manually", "rule: ", mRule.String())

}

Expand All @@ -532,9 +532,9 @@ func restoreInternetGwV4() (err error) {

//delete default gateway at first
if err := netlink.RouteDel(&gwRoute); err != nil && !strings.Contains(err.Error(), "no such process") {
slog.Error("remove default gateway failed", "error", err.Error())
slog.Error("please remove the gateway route manually")
slog.Error("gateway route: ", gwRoute.String())
slog.Warn("remove default gateway failed", "error", err.Error())
slog.Warn("please remove the gateway route manually")
slog.Warn("gateway route: ", gwRoute.String())
}

//delete rules
Expand All @@ -548,9 +548,9 @@ func restoreInternetGwV4() (err error) {
tRule.Table = RouteTableName
tRule.Priority = 3000
if err := netlink.RuleDel(tRule); err != nil {
slog.Error("delete rule failed", "error", err.Error())
slog.Error("please remove the rule manually")
slog.Error("rule: ", tRule.String())
slog.Warn("delete rule failed", "error", err.Error())
slog.Warn("please remove the rule manually")
slog.Warn("rule: ", tRule.String())
}
//second rule :ip rule add table main suppress_prefixlength 0
sRule := netlink.NewRule()
Expand All @@ -559,8 +559,8 @@ func restoreInternetGwV4() (err error) {
sRule.SuppressPrefixlen = 0
sRule.Priority = 2500
if err := netlink.RuleDel(sRule); err != nil {
slog.Error("delete rule failed", "error", err.Error())
slog.Error("please remove the rule manually", "rule: ", sRule.String())
slog.Warn("delete rule failed", "error", err.Error())
slog.Warn("please remove the rule manually", "rule: ", sRule.String())
}
//third rule :ip rule add from 68.183.79.137 table main
lIp, err := getLocalIpByDefaultInterfaceName()
Expand All @@ -577,8 +577,8 @@ func restoreInternetGwV4() (err error) {
mRule.Table = unix.RT_TABLE_MAIN
mRule.Priority = 2000
if err := netlink.RuleDel(mRule); err != nil {
slog.Error("delete rule failed", "error", err.Error())
slog.Error("please remove the rule manually", "rule: ", mRule.String())
slog.Warn("delete rule failed", "error", err.Error())
slog.Warn("please remove the rule manually", "rule: ", mRule.String())

}

Expand Down

0 comments on commit d36d185

Please sign in to comment.