Skip to content

Commit

Permalink
fix: handle disconnection (nil gateway) in routes monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Apr 12, 2021
1 parent c9ae0f3 commit 4dac3b9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions session/session_routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ func (s *Session) routeMon() {

s.Events.Log(log.INFO, "gateway monitor started ...")

gw4 = s.Gateway
if gw4 = s.Gateway; gw4 == nil {
gw4 = &network.Endpoint{}
}

gwIP6, err = routing.Gateway(routing.IPv6, s.Interface.Name())
if err != nil {
Expand All @@ -43,10 +45,12 @@ func (s *Session) routeMon() {
time.Sleep(5 * time.Second)

gw4now, err := network.FindGateway(s.Interface)
if gw4now == nil {
gw4now = &network.Endpoint{}
}

if err != nil {
s.Events.Log(log.ERROR, "error getting ipv4 gateway: %v", err)
} else if gw4now == nil {
s.Events.Log(log.ERROR, "null ipv4 gateway")
} else {
if gw4now.IpAddress != gw4.IpAddress || gw4now.HwAddress != gw4.HwAddress {
s.Events.Add("gateway.change", GatewayChange{
Expand Down

0 comments on commit 4dac3b9

Please sign in to comment.