Massimo B. Veteran
Joined: 09 Feb 2005 Posts: 1771 Location: PB, Germany
|
Posted: Tue Mar 21, 2017 7:02 am Post subject: Restarting socks proxy |
|
|
A Restarting Socks Proxy
I try to create some restarting socks proxy that restarts when the link is lost like on network switches or suspend to ram. I wonder that there is no packaged solution yet.
The only thing working so far: Code: | while true;do logger "Launching SOCKS...";ssh -N -D 8080 gw;done |
Trying to put that into some script that can be run with autostart of the Window Manager fails even if backgrounded and disowned. It is killed after the script is finished due to STDIN binding. Trying -n for redirecting stdin from /dev/null results in an infinite loop restarting ssh as it quits after started. This is normal with -n but this way I can't check if it is alive.
Code: | #!/usr/bin/env bash
(
while sleep 1; do
logger "Launching SOCKS..."
ssh -CNn -D 8080 gw
done
) &
disown |
More advanced checks for keeping ssh alive is done by autossh, but this doesn't work as documented:
Code: | # autossh -M 20000 -f -N -g -D 8080 gw | This quits right after launching ssh, so it does not check the connection status anymore. So I tried combinations of
Code: | # autossh -M 20000 -N -g -D 8080 gw & | or Code: | # autossh -M 20000 -CNn -D 8080 gw & |
This first of those is staying alive but cannot be put inside a script as well as it quits after script is finished. The second one is dying as well inside a script.
Looking around I only found few solutions for this like https://github.com/PHLAK/Soxy. But investigating the script, that AUTO_RECONNECT does only restart on triggering status like polling by a cron job.
Best solution would be an init script or some script connected to Networkmanger itself.
Doesn't some of the real socks proxies like net-proxy/dante provide a solution? _________________ HP ZBook Power 15.6" G8 i7-11800H|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770 |
|