edgd1er / nordvpn-proxy

NordVPN openVPN socks
26 stars 8 forks source link

Save status of VPN to a file #10

Closed alpe12 closed 2 years ago

alpe12 commented 2 years ago

I could really use a file that says wheter vpn is working as intended or not. One way to do it would be to add it to check_openvpn() on healthcheck.sh. Something like: Save 1 to a file if it's working and 0 if it's not. This way I could mount that file on my system and access the vpn status from my other scripts.

Ideally it should only write to this file if there's an environment variable enabling this feature. So that the people that don't need it won't have unnecessary writes to their drives.

Thanks, anyway. :)

PS: I know there is an EXIT_WHEN_IP_NOTEXPECTED option. But for my use-case I need it disabled.

edgd1er commented 2 years ago

There are three kind of kill switches in the container:

if you need to know openvpn status from another context, you may run echo "state" | socat -s - unix-connect:/run/openvpn.sock | sed -n '2p'

I could add a file with status, but I'm afraid writing a file every minute or so, would increase disk wearness, especially of running on a Raspberry pi. also this feature would be available based on an ENV var like EXIT_WHEN_IP_NOTEXPECTED. based on checks logic, the file would never be set to 0 or just before the container stop. that would be a good check of the defined controls.

Not a big issue though, I'll see when I have time to implement it.

alpe12 commented 2 years ago

Thanks. :)

alpe12 commented 2 years ago

https://github.com/edgd1er/nordvpn-proxy/blame/d91e70663adc549e86a583f718a24f886bc5f9d4/app/utils.sh#L12 It logs even if it's disabled.

edgd1er commented 2 years ago

Yes but no file written