@@ -470,7 +470,7 @@ def do_wait():
470
470
471
471
def pfctl (args , stdin = None ):
472
472
argv = ['pfctl' ] + list (args .split (" " ))
473
- debug1 ('>> %s' % ' ' .join (argv ))
473
+ debug1 ('>> %s\n ' % ' ' .join (argv ))
474
474
475
475
p = ssubprocess .Popen (argv , stdin = ssubprocess .PIPE ,
476
476
stdout = ssubprocess .PIPE ,
@@ -515,10 +515,19 @@ def do_pf(port, dnsport, family, subnets, udp):
515
515
if not '\n anchor "sshuttle" all\n ' in pf_status :
516
516
pf_add_anchor_rule (PF_PASS , "sshuttle" )
517
517
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:\n Status: Disabled' in pf_status :
523
+ pfctl ('-e' )
524
+ _pf_context ['started_by_sshuttle' ] = True
520
525
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' )
522
531
523
532
524
533
def program_exists (name ):
0 commit comments