Added support for SSH ports other than 22.
This commit is contained in:
parent
d0c9ea6aa4
commit
2781209eb0
2 changed files with 19 additions and 2 deletions
|
@ -1,7 +1,15 @@
|
|||
{
|
||||
// host and port of the SSH server that's going to act as the proxy
|
||||
"host": "rusty.wafe.eu",
|
||||
"port": 10022,
|
||||
|
||||
// username I'm allowed to use on that server
|
||||
"user": "tunnel",
|
||||
|
||||
// a list of associations
|
||||
"mapping": [
|
||||
|
||||
// local port 22 will be available as port 39999 on the above server
|
||||
{
|
||||
"remote": 39999,
|
||||
"local": 22
|
||||
|
|
|
@ -10,6 +10,16 @@ def load_cfg(path):
|
|||
with open(path) as f:
|
||||
return json.loads(jsmin.jsmin(f.read()))
|
||||
|
||||
def safe_get(d, k, alt):
|
||||
"""
|
||||
Returns d[k] or alt
|
||||
"""
|
||||
|
||||
if k in d:
|
||||
return d[k]
|
||||
else:
|
||||
return alt
|
||||
|
||||
if __name__ == "__main__":
|
||||
# try config files in the order they are passed to us
|
||||
# first one wins
|
||||
|
@ -24,12 +34,11 @@ if __name__ == "__main__":
|
|||
except Exception as e:
|
||||
print("! cfg file %s failed to load (%s)" %(path, e))
|
||||
|
||||
|
||||
if not cfg:
|
||||
print("! unable to load any configuration")
|
||||
sys.exit(1)
|
||||
|
||||
command = ["/usr/bin/ssh", "-o", "ServerAliveInterval 45", "-o", "ServerAliveCountMax 2", "-o", "ExitOnForwardFailure yes", "-N"]
|
||||
command = ["/usr/bin/ssh", "-o", "ServerAliveInterval 45", "-o", "ServerAliveCountMax 2", "-o", "ExitOnForwardFailure yes", "-N", "-p", safe_get(cfg, "port", 22)]
|
||||
|
||||
for m in cfg["mapping"]:
|
||||
command.append("-R")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue