Skip to content

Commit df3383c

Browse files
authored
Fix defaults for --sourceip and --sourceport (#45)
Use falsy values by default, otherwise the proxy thread will always attempt to bind to 0.0.0.0:8080 which in many cases might be already in use.
1 parent 4c2d718 commit df3383c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tcpproxy.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ def parse_args():
4444
default=8080, help='port to listen on')
4545

4646
parser.add_argument('-si', '--sourceip', dest='source_ip',
47-
default='0.0.0.0', help='IP address the other end will see')
47+
default='', help='IP address the other end will see')
4848

4949
parser.add_argument('-sp', '--sourceport', dest='source_port', type=int,
50-
default=8080, help='source port the other end will see')
50+
default=0, help='source port the other end will see')
5151

5252
parser.add_argument('-pi', '--proxy-ip', dest='proxy_ip', default=None,
5353
help='IP address/host name of proxy')
@@ -268,7 +268,7 @@ def start_proxy_thread(local_socket, args, in_modules, out_modules):
268268
remote_socket.set_proxy(proxy_types[args.proxy_type], args.proxy_ip, args.proxy_port)
269269

270270
try:
271-
if args.source_ip and args.source_port:
271+
if args.source_ip or args.source_port:
272272
remote_socket.bind((args.source_ip, args.source_port))
273273
remote_socket.connect((args.target_ip, args.target_port))
274274
vprint('Connected to %s:%d' % remote_socket.getpeername(), args.verbose)

0 commit comments

Comments
 (0)