From 65bf544883d736760000c9d00eccdbcacac1b838 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 2 Apr 2019 01:53:28 +0100 Subject: [PATCH] fix validating data --- home.admin/config.scripts/internet.sshtunnel.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/home.admin/config.scripts/internet.sshtunnel.py b/home.admin/config.scripts/internet.sshtunnel.py index 31e437e..8809eeb 100755 --- a/home.admin/config.scripts/internet.sshtunnel.py +++ b/home.admin/config.scripts/internet.sshtunnel.py @@ -45,17 +45,18 @@ if sys.argv[1] == "on": # sys.exit(1) # check server address - ssh_server = sys.argv[2] - if ssh_server.count("@") != 1: + if len(sys.argv) < 3: + print("[USER]@[SERVER] missing - use 'internet.sshtunnel.py -h' for help") + sys.exit(1) + if sys.argv[2].count("@") != 1: print("[USER]@[SERVER] wrong - use 'internet.sshtunnel.py -h' for help") sys.exit(1) + ssh_server = sys.argv[2] - # check minimal forwardings + # genenate additional parameter for autossh (forwarding ports) if len(sys.argv) < 4: print("[INTERNAL-PORT]:[EXTERNAL-PORT] missing - run 'internet.sshtunnel.py off' first") sys.exit(1) - - # genenate additional parameter for autossh (forwarding ports) additional_parameters="" i = 3 while i < len(sys.argv):