mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-01-31 16:35:26 +00:00
misc bug fixes related to default routes
This commit is contained in:
parent
1756e8b0f2
commit
3fc11e2278
@ -164,6 +164,9 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
networkName = "\(id) (\(net.name))"
|
||||
}
|
||||
|
||||
if net.allowDefault && net.connected {
|
||||
networkName += " [default]"
|
||||
}
|
||||
let item = NSMenuItem(title: networkName, action: #selector(AppDelegate.toggleNetwork(_:)), keyEquivalent: "")
|
||||
|
||||
if net.connected {
|
||||
|
@ -45,6 +45,10 @@ class JoinNetworkViewController: NSViewController, NSComboBoxDelegate, NSComboBo
|
||||
override func viewWillAppear() {
|
||||
super.viewWillAppear()
|
||||
|
||||
allowManagedCheckBox.state = NSOnState
|
||||
allowGlobalCheckBox.state = NSOffState
|
||||
allowDefaultCheckBox.state = NSOffState
|
||||
|
||||
let defaults = NSUserDefaults.standardUserDefaults()
|
||||
|
||||
let vals = defaults.stringArrayForKey(joinedNetworksKey)
|
||||
|
@ -62,7 +62,7 @@
|
||||
</button>
|
||||
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="rz3-0a-oNA">
|
||||
<rect key="frame" x="238" y="59" width="141" height="18"/>
|
||||
<buttonCell key="cell" type="check" title="Allow Default Route" alternateTitle="Allow override of default route ‘full tunnel'" bezelStyle="regularSquare" imagePosition="left" inset="2" id="Lkd-XI-Kcu">
|
||||
<buttonCell key="cell" type="check" title="Allow Default Route" bezelStyle="regularSquare" imagePosition="left" inset="2" id="Lkd-XI-Kcu">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
|
@ -263,7 +263,7 @@ class Network: NSObject, NSCoding {
|
||||
|
||||
func defaultRouteExists(netList: [Network]) -> Bool {
|
||||
for net in netList {
|
||||
if net.allowDefault {
|
||||
if net.allowDefault && net.connected {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -70,29 +70,33 @@ class NetworkMonitor: NSObject {
|
||||
var networks = self.savedNetworks
|
||||
|
||||
for nw in receivedNetworks {
|
||||
let index = findNetworkWithID(nw.nwid)
|
||||
let index = findSavedNetworkWithID(nw.nwid)
|
||||
|
||||
if index != NSNotFound {
|
||||
networks[index] = nw
|
||||
}
|
||||
networks.sortInPlace({ (left, right) -> Bool in
|
||||
if left.nwid < right.nwid {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
})
|
||||
|
||||
objc_sync_enter(allNetworks)
|
||||
allNetworks = networks
|
||||
objc_sync_exit(allNetworks)
|
||||
|
||||
saveNetworks()
|
||||
|
||||
let nc = NSNotificationCenter.defaultCenter()
|
||||
|
||||
nc.postNotificationName(networkUpdateKey, object: nil, userInfo: ["networks": networks])
|
||||
else {
|
||||
networks.append(nw)
|
||||
}
|
||||
}
|
||||
|
||||
networks.sortInPlace({ (left, right) -> Bool in
|
||||
if left.nwid < right.nwid {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
})
|
||||
|
||||
objc_sync_enter(allNetworks)
|
||||
allNetworks = networks
|
||||
objc_sync_exit(allNetworks)
|
||||
|
||||
saveNetworks()
|
||||
|
||||
let nc = NSNotificationCenter.defaultCenter()
|
||||
|
||||
nc.postNotificationName(networkUpdateKey, object: nil, userInfo: ["networks": networks])
|
||||
}
|
||||
|
||||
private func findNetworkWithID(nwid: UInt64) -> Int {
|
||||
@ -106,6 +110,17 @@ class NetworkMonitor: NSObject {
|
||||
return NSNotFound
|
||||
}
|
||||
|
||||
private func findSavedNetworkWithID(nwid: UInt64) -> Int {
|
||||
for (index, element) in savedNetworks.enumerate() {
|
||||
|
||||
if element.nwid == nwid {
|
||||
return index
|
||||
}
|
||||
}
|
||||
|
||||
return NSNotFound
|
||||
}
|
||||
|
||||
private func saveNetworks() {
|
||||
let file = dataFile()
|
||||
|
||||
|
@ -76,6 +76,21 @@ class ShowNetworksViewController: NSViewController, NSTableViewDelegate, NSTable
|
||||
cell.bridgingField.stringValue = network.bridge ? "ENABLED" : "DISABLED"
|
||||
cell.deviceField.stringValue = network.portDeviceName
|
||||
|
||||
if network.connected {
|
||||
cell.connectedCheckbox.state = NSOnState
|
||||
|
||||
cell.allowDefault.enabled = true
|
||||
cell.allowGlobal.enabled = true
|
||||
cell.allowManaged.enabled = true
|
||||
}
|
||||
else {
|
||||
cell.connectedCheckbox.state = NSOffState
|
||||
|
||||
cell.allowDefault.enabled = false
|
||||
cell.allowGlobal.enabled = false
|
||||
cell.allowManaged.enabled = false
|
||||
}
|
||||
|
||||
|
||||
if network.allowDefault {
|
||||
cell.allowDefault.state = NSOnState
|
||||
@ -101,20 +116,7 @@ class ShowNetworksViewController: NSViewController, NSTableViewDelegate, NSTable
|
||||
cell.addressesField.stringValue += "\n"
|
||||
}
|
||||
|
||||
if network.connected {
|
||||
cell.connectedCheckbox.state = NSOnState
|
||||
|
||||
cell.allowDefault.enabled = true
|
||||
cell.allowGlobal.enabled = true
|
||||
cell.allowManaged.enabled = true
|
||||
}
|
||||
else {
|
||||
cell.connectedCheckbox.state = NSOffState
|
||||
|
||||
cell.allowDefault.enabled = false
|
||||
cell.allowGlobal.enabled = false
|
||||
cell.allowManaged.enabled = false
|
||||
}
|
||||
|
||||
return cell
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user