diff options
author | Avery Pennarun <apenwarr@gmail.com> | 2010-05-07 20:02:04 -0400 |
---|---|---|
committer | Avery Pennarun <apenwarr@gmail.com> | 2010-05-07 20:02:04 -0400 |
commit | 7043195043d5a1885235833804ae7f90404e4a46 (patch) | |
tree | 700616b6192336147d09e2744693a7cc0b53ed11 /firewall.py | |
parent | 77935bd110d901e9e50b1e62aa74b0d27d33c35e (diff) |
Add -N (--auto-nets) option for auto-discovering subnets.
Now if you do
./sshuttle -Nr username@myservername
It'll automatically route the "local" subnets (ie., stuff in the routing
table) from myservername. This is (hopefully a reasonable default setting
for most people.
Diffstat (limited to 'firewall.py')
-rw-r--r-- | firewall.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/firewall.py b/firewall.py index b4bef1f..8ac5b9a 100644 --- a/firewall.py +++ b/firewall.py @@ -140,7 +140,7 @@ def program_exists(name): # exit. In case that fails, it's not the end of the world; future runs will # supercede it in the transproxy list, at least, so the leftover rules # are hopefully harmless. -def main(port, subnets): +def main(port): assert(port > 0) assert(port <= 65535) @@ -173,8 +173,21 @@ def main(port, subnets): line = sys.stdin.readline(128) if not line: return # parent died; nothing to do - if line != 'GO\n': - raise Fatal('firewall: expected GO but got %r' % line) + + subnets = [] + if line != 'ROUTES\n': + raise Fatal('firewall: expected ROUTES but got %r' % line) + while 1: + line = sys.stdin.readline(128) + if not line: + raise Fatal('firewall: expected route but got %r' % line) + elif line == 'GO\n': + break + try: + (ip,width) = line.strip().split(',', 1) + except: + raise Fatal('firewall: expected route or GO but got %r' % line) + subnets.append((ip, int(width))) try: if line: debug1('firewall manager: starting transproxy.\n') |