Joined: 09 Feb 2005
|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:
|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.
while sleep 1; do
logger "Launching SOCKS..."
ssh -CNn -D 8080 gw
More advanced checks for keeping ssh alive is done by autossh, but this doesn't work as documented:
This quits right after launching ssh, so it does not check the connection status anymore. So I tried combinations of
|# autossh -M 20000 -f -N -g -D 8080 gw |
|# autossh -M 20000 -N -g -D 8080 gw & |
|# 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?
ppc:PowerBook5,8 15"(1440)-G4/1.67,2G|amd64:HP EliteBook 8560w,i7-2620M,16G|Acer Z5610 (Core2QuadQ8200),8G|amd64-prefix:OpenSuse|HP EliteDesk 800G1 i7-4790|HP Compaq Pro 6300 i7-3770