From 7e5272f49965da23cbe5a0f0f75c667a27a12368 Mon Sep 17 00:00:00 2001 From: tintinweb Date: Thu, 17 Mar 2016 23:55:22 +0100 Subject: [PATCH] feat guess remote/listen port --- striptls/striptls.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/striptls/striptls.py b/striptls/striptls.py index 89c4383..134ec87 100644 --- a/striptls/striptls.py +++ b/striptls/striptls.py @@ -1357,11 +1357,21 @@ def main(): if not options.remote: parser.error("mandatory option: remote") else: - options.remote = options.remote.strip().split(":") - options.remote = (options.remote[0], int(options.remote[1])) + if ":" not in options.remote and ":" in options.listen: + # no port in remote, but there is one in listen. use this one + options.remote = (options.remote.strip(), int(options.listen.strip().split(":")[1])) + logger.warning("no remote port specified - falling back to %s:%d (listen port)"%options.remote) + elif ":" in options.remote: + options.remote = options.remote.strip().split(":") + options.remote = (options.remote[0], int(options.remote[1])) + else: + parser.error("neither remote nor listen is in the format :") if not options.listen: - logger.warning("no listen port specified - falling back to 0.0.0.0:%d"%options.remote[1]) + logger.warning("no listen port specified - falling back to 0.0.0.0:%d (remote port)"%options.remote[1]) options.listen = ("0.0.0.0",options.remote[1]) + elif ":" not in options.listen: + options.listen = (options.listen.strip(), options.remote[1]) + logger.warning("no listen port specified - falling back to %s:%d (remote port)"%options.listen) else: options.listen = options.listen.strip().split(":") options.listen = (options.listen[0], int(options.listen[1]))