Commit 62e1ac4b authored by Avery Pennarun's avatar Avery Pennarun

ui-macos: add checkboxes for --no-latency-control and --dns options.

parent f2297066
This diff is collapsed.
...@@ -2,7 +2,8 @@ import sys, os, pty ...@@ -2,7 +2,8 @@ import sys, os, pty
from AppKit import * from AppKit import *
import my, models, askpass import my, models, askpass
def sshuttle_args(host, auto_nets, auto_hosts, nets, debug): def sshuttle_args(host, auto_nets, auto_hosts, dns, nets, debug,
no_latency_control):
argv = [my.bundle_path('sshuttle/sshuttle', ''), '-r', host] argv = [my.bundle_path('sshuttle/sshuttle', ''), '-r', host]
assert(argv[0]) assert(argv[0])
if debug: if debug:
...@@ -11,6 +12,10 @@ def sshuttle_args(host, auto_nets, auto_hosts, nets, debug): ...@@ -11,6 +12,10 @@ def sshuttle_args(host, auto_nets, auto_hosts, nets, debug):
argv.append('--auto-nets') argv.append('--auto-nets')
if auto_hosts: if auto_hosts:
argv.append('--auto-hosts') argv.append('--auto-hosts')
if dns:
argv.append('--dns')
if no_latency_control:
argv.append('--no-latency-control')
argv += nets argv += nets
return argv return argv
...@@ -131,6 +136,7 @@ class SshuttleController(NSObject): ...@@ -131,6 +136,7 @@ class SshuttleController(NSObject):
prefsWindow = objc.IBOutlet() prefsWindow = objc.IBOutlet()
serversController = objc.IBOutlet() serversController = objc.IBOutlet()
logField = objc.IBOutlet() logField = objc.IBOutlet()
noLatencyControlField = objc.IBOutlet()
servers = [] servers = []
conns = {} conns = {}
...@@ -159,8 +165,11 @@ class SshuttleController(NSObject): ...@@ -159,8 +165,11 @@ class SshuttleController(NSObject):
conn = Runner(sshuttle_args(host, conn = Runner(sshuttle_args(host,
auto_nets = nets_mode == models.NET_AUTO, auto_nets = nets_mode == models.NET_AUTO,
auto_hosts = server.autoHosts(), auto_hosts = server.autoHosts(),
dns = server.useDns(),
nets = manual_nets, nets = manual_nets,
debug = self.debugField.state()), debug = self.debugField.state(),
no_latency_control
= self.noLatencyControlField.state()),
logfunc=logfunc, promptfunc=promptfunc, logfunc=logfunc, promptfunc=promptfunc,
serverobj=server) serverobj=server)
self.conns[host] = conn self.conns[host] = conn
...@@ -279,13 +288,15 @@ class SshuttleController(NSObject): ...@@ -279,13 +288,15 @@ class SshuttleController(NSObject):
net.setWidth_(width) net.setWidth_(width)
nl.append(net) nl.append(net)
autoNets = s.get('autoNets', 1) autoNets = s.get('autoNets', models.NET_AUTO)
autoHosts = s.get('autoHosts', 1) autoHosts = s.get('autoHosts', True)
useDns = s.get('useDns', autoNets == models.NET_ALL)
srv = models.SshuttleServer.alloc().init() srv = models.SshuttleServer.alloc().init()
srv.setHost_(host) srv.setHost_(host)
srv.setAutoNets_(autoNets) srv.setAutoNets_(autoNets)
srv.setAutoHosts_(autoHosts) srv.setAutoHosts_(autoHosts)
srv.setNets_(nl) srv.setNets_(nl)
srv.setUseDns_(useDns)
sl.append(srv) sl.append(srv)
self.serversController.addObjects_(sl) self.serversController.addObjects_(sl)
self.serversController.setSelectionIndex_(0) self.serversController.setSelectionIndex_(0)
...@@ -303,7 +314,8 @@ class SshuttleController(NSObject): ...@@ -303,7 +314,8 @@ class SshuttleController(NSObject):
d = dict(host=s.host(), d = dict(host=s.host(),
nets=nets, nets=nets,
autoNets=s.autoNets(), autoNets=s.autoNets(),
autoHosts=s.autoHosts()) autoHosts=s.autoHosts(),
useDns=s.useDns())
l.append(d) l.append(d)
my.Defaults().setObject_forKey_(l, 'servers') my.Defaults().setObject_forKey_(l, 'servers')
self.fill_menu() self.fill_menu()
......
...@@ -122,6 +122,7 @@ class SshuttleServer(NSObject): ...@@ -122,6 +122,7 @@ class SshuttleServer(NSObject):
def setAutoNets_(self, v): def setAutoNets_(self, v):
self._k_autoNets = v self._k_autoNets = v
self.setNetsHidden_(-1) self.setNetsHidden_(-1)
self.setUseDns_(v == NET_ALL)
config_changed() config_changed()
def autoHosts(self): def autoHosts(self):
...@@ -129,3 +130,9 @@ class SshuttleServer(NSObject): ...@@ -129,3 +130,9 @@ class SshuttleServer(NSObject):
def setAutoHosts_(self, v): def setAutoHosts_(self, v):
self._k_autoHosts = v self._k_autoHosts = v
config_changed() config_changed()
def useDns(self):
return getattr(self, '_k_useDns', False)
def setUseDns_(self, v):
self._k_useDns = v
config_changed()
redo-ifchange debug.app redo-ifchange debug.app
exec >&2 exec >&2
./debug.app/Contents/MacOS/run ./debug.app/Contents/MacOS/Sshuttle
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment