Commit 621997b2 authored by Avery Pennarun's avatar Avery Pennarun

ui-macos: move the noLatencyControl setting to a per-connection setting.

I think some connections you'll want to optimize for latency, and others for
bandwidth.  Probably.

Also, use a dropdown box instead of a checkbox; that way we can make it more
clear what each of the settings means.

While we're here, adjust all the anchor settings for the different display
items so that resizing the dialog box works sensibly.
parent ca7d38dc
This diff is collapsed.
...@@ -136,7 +136,7 @@ class SshuttleController(NSObject): ...@@ -136,7 +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() latencyControlField = objc.IBOutlet()
servers = [] servers = []
conns = {} conns = {}
...@@ -162,14 +162,14 @@ class SshuttleController(NSObject): ...@@ -162,14 +162,14 @@ class SshuttleController(NSObject):
manual_nets = ['0/0'] manual_nets = ['0/0']
else: else:
manual_nets = [] manual_nets = []
noLatencyControl = (server.latencyControl() != models.LAT_INTERACTIVE)
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(), dns = server.useDns(),
nets = manual_nets, nets = manual_nets,
debug = self.debugField.state(), debug = self.debugField.state(),
no_latency_control no_latency_control = noLatencyControl),
= self.noLatencyControlField.state()),
logfunc=logfunc, promptfunc=promptfunc, logfunc=logfunc, promptfunc=promptfunc,
serverobj=server) serverobj=server)
self.conns[host] = conn self.conns[host] = conn
...@@ -286,12 +286,14 @@ class SshuttleController(NSObject): ...@@ -286,12 +286,14 @@ class SshuttleController(NSObject):
autoNets = s.get('autoNets', models.NET_AUTO) autoNets = s.get('autoNets', models.NET_AUTO)
autoHosts = s.get('autoHosts', True) autoHosts = s.get('autoHosts', True)
useDns = s.get('useDns', autoNets == models.NET_ALL) useDns = s.get('useDns', autoNets == models.NET_ALL)
latencyControl = s.get('latencyControl', models.LAT_INTERACTIVE)
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) srv.setUseDns_(useDns)
srv.setLatencyControl_(latencyControl)
sl.append(srv) sl.append(srv)
self.serversController.addObjects_(sl) self.serversController.addObjects_(sl)
self.serversController.setSelectionIndex_(0) self.serversController.setSelectionIndex_(0)
...@@ -310,7 +312,8 @@ class SshuttleController(NSObject): ...@@ -310,7 +312,8 @@ class SshuttleController(NSObject):
nets=nets, nets=nets,
autoNets=s.autoNets(), autoNets=s.autoNets(),
autoHosts=s.autoHosts(), autoHosts=s.autoHosts(),
useDns=s.useDns()) useDns=s.useDns(),
latencyControl=s.latencyControl())
l.append(d) l.append(d)
my.Defaults().setObject_forKey_(l, 'servers') my.Defaults().setObject_forKey_(l, 'servers')
self.fill_menu() self.fill_menu()
...@@ -322,6 +325,11 @@ class SshuttleController(NSObject): ...@@ -322,6 +325,11 @@ class SshuttleController(NSObject):
tf('Determine automatically') tf('Determine automatically')
tf('Custom...') tf('Custom...')
self.latencyControlField.removeAllItems()
tf = self.latencyControlField.addItemWithTitle_
tf('Fast transfer')
tf('Low latency')
# Hmm, even when I mark this as !enabled in the .nib, it still comes # Hmm, even when I mark this as !enabled in the .nib, it still comes
# through as enabled. So let's just disable it here (since we don't # through as enabled. So let's just disable it here (since we don't
# support this feature yet). # support this feature yet).
......
...@@ -58,6 +58,9 @@ NET_ALL = 0 ...@@ -58,6 +58,9 @@ NET_ALL = 0
NET_AUTO = 1 NET_AUTO = 1
NET_MANUAL = 2 NET_MANUAL = 2
LAT_BANDWIDTH = 0
LAT_INTERACTIVE = 1
class SshuttleServer(NSObject): class SshuttleServer(NSObject):
def init(self): def init(self):
self = super(SshuttleServer, self).init() self = super(SshuttleServer, self).init()
...@@ -155,3 +158,9 @@ class SshuttleServer(NSObject): ...@@ -155,3 +158,9 @@ class SshuttleServer(NSObject):
def setUseDns_(self, v): def setUseDns_(self, v):
self._k_useDns = v self._k_useDns = v
config_changed() config_changed()
def latencyControl(self):
return getattr(self, '_k_latencyControl', LAT_INTERACTIVE)
def setLatencyControl_(self, v):
self._k_latencyControl = v
config_changed()
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