Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Making Magneticod exit if IP address goes away #262

Open
seanbert-monkey opened this issue Oct 1, 2020 · 0 comments
Open

Making Magneticod exit if IP address goes away #262

seanbert-monkey opened this issue Oct 1, 2020 · 0 comments

Comments

@seanbert-monkey
Copy link

In the file magnetico/cmd/magneticod/dht/mainline/transport.go if we add the following -

*** transport.go 2020-10-01 21:48:55.671143085 +0000
--- transport.go_orij 2020-10-01 21:43:48.048129174 +0000


*** 155,164 ****
t.onCongestion()
}
} else if err != nil {

  •           /* Do panic handling here in event IP addresses has changed */
    
  •           if err.Error() == "network is unreachable" {
    
  •                   zap.L().Panic("Network has become unavailable! (VPN down?)")
    
  •           }
              zap.L().Warn("Could NOT write an UDP packet!", zap.Error(err))
      }
    
    }
    --- 155,160 ----

this makes magneticod fall over if the IP address it binds to at start up vanishes.

this tends to only happen with VPN connections.

I also created a little script to look at the tun0 interface and use it configuration to launch magenticod with the right IPv4 address.

ideally the best solution would be to set a flag to a) switch this behaviour on or off and b) pass the interface name as an option and have magneticod react to this failure by rebinding (or exiting).

I am going to see if my paltry go hacking skills can achieve this in due course - for me I have achieved Minimal Viable Product - such that magneticod (as a service) now recovers from a VPN failure / IP address change.

Until I do something that adds some command options to enable the things I mention above I wont be doing any pushes, the idea would be that unless you selected the options magneticod behaviour would be as before.

Frankly if my VPN did not flip IP addresses so often I would not be even scratching this itch ! :)

Also great project, very interesting.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant