@@ -470,7 +470,7 @@ def do_wait():
470470
471471def 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 '\n anchor "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:\n Status: 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
524533def program_exists (name ):
0 commit comments