Smarter listenport selection.

Now if we aren't given an explicit port, we always initiate the port search
at 12300 and count upward looking for an available port.

Normally the kernel will assign us a random port, but that's not ideal
in our case because we'd like to use the same port numbers whenever
possible; that avoids piling up crap inside iptables in the (hopefully
unlikely) event that we die without cleaning up correctly.
This commit is contained in:
Avery Pennarun
2010-05-01 21:50:43 -04:00
parent ad459e2918
commit 9f514d7a15
3 changed files with 38 additions and 6 deletions

View File

@ -66,10 +66,10 @@ elif opt.iptables:
parse_subnets(extra[1:])))
else:
if len(extra) < 1:
o.fatal('at least one argument expected')
o.fatal('at least one subnet expected')
remotename = extra[0]
if remotename == '' or remotename == '-':
remotename = None
sys.exit(client.main(parse_ipport(opt.listen or '0.0.0.0:1234'),
sys.exit(client.main(parse_ipport(opt.listen or '0.0.0.0:0'),
remotename,
parse_subnets(extra)))