Skip to content

Commit

Permalink
feat guess remote/listen port
Browse files Browse the repository at this point in the history
  • Loading branch information
tintinweb committed Mar 17, 2016
1 parent e1cbc79 commit 7e5272f
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions striptls/striptls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <host>:<port>")
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]))
Expand Down

0 comments on commit 7e5272f

Please sign in to comment.