Skip to content

Commit 6e32d14

Browse files
committed
add -e/-d support
1 parent bdad253 commit 6e32d14

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/firewall.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ def do_wait():
470470

471471
def pfctl(args, stdin = None):
472472
argv = ['pfctl'] + list(args.split(" "))
473-
debug1('>> %s' % ' '.join(argv))
473+
debug1('>> %s\n' % ' '.join(argv))
474474

475475
p = ssubprocess.Popen(argv, stdin = ssubprocess.PIPE,
476476
stdout = ssubprocess.PIPE,
@@ -515,10 +515,19 @@ def do_pf(port, dnsport, family, subnets, udp):
515515
if not '\nanchor "sshuttle" all\n' in pf_status:
516516
pf_add_anchor_rule(PF_PASS, "sshuttle")
517517

518-
o = pfctl('-a sshuttle -f /dev/stdin -E', rules)
519-
_pf_context['Xtoken'] = re.search(r'Token : (.+)', o[1]).group(1)
518+
pfctl('-a sshuttle -f /dev/stdin', rules)
519+
if sys.platform == "darwin":
520+
o = pfctl('-E')
521+
_pf_context['Xtoken'] = re.search(r'Token : (.+)', o[1]).group(1)
522+
elif 'INFO:\nStatus: Disabled' in pf_status:
523+
pfctl('-e')
524+
_pf_context['started_by_sshuttle'] = True
520525
else:
521-
pfctl('-a sshuttle -F all -X %s' % _pf_context['Xtoken'])
526+
pfctl('-a sshuttle -F all')
527+
if sys.platform == "darwin":
528+
pfctl('-X %s' % _pf_context['Xtoken'])
529+
elif _pf_context['started_by_sshuttle']:
530+
pfctl('-d')
522531

523532

524533
def program_exists(name):

0 commit comments

Comments
 (0)