mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-07 04:53:44 +02:00
add allowManaged, allowGlobal, allowDefault to Network object
This commit is contained in:
parent
9c94d6527a
commit
7e17a2072c
1 changed files with 33 additions and 0 deletions
|
@ -56,6 +56,9 @@ struct PropertyKeys {
|
||||||
static let portErrorKey = "portError"
|
static let portErrorKey = "portError"
|
||||||
static let statusKey = "status"
|
static let statusKey = "status"
|
||||||
static let typeKey = "type"
|
static let typeKey = "type"
|
||||||
|
static let allowManagedKey = "allowManaged"
|
||||||
|
static let allowGlobalKey = "allowGlobal"
|
||||||
|
static let allowDefaultKey = "allowDefault"
|
||||||
}
|
}
|
||||||
|
|
||||||
class Network: NSObject, NSCoding {
|
class Network: NSObject, NSCoding {
|
||||||
|
@ -72,6 +75,9 @@ class Network: NSObject, NSCoding {
|
||||||
var portError: Int = 0
|
var portError: Int = 0
|
||||||
var status: NetworkStatus = .REQUESTING_CONFIGURATION
|
var status: NetworkStatus = .REQUESTING_CONFIGURATION
|
||||||
var type: NetworkType = .PRIVATE
|
var type: NetworkType = .PRIVATE
|
||||||
|
var allowManaged: Bool = true
|
||||||
|
var allowGlobal: Bool = false
|
||||||
|
var allowDefault: Bool = false
|
||||||
var connected: Bool = false // NOT PERSISTED. Set to true if loaded via JSON
|
var connected: Bool = false // NOT PERSISTED. Set to true if loaded via JSON
|
||||||
|
|
||||||
init(jsonData: [String: AnyObject]) {
|
init(jsonData: [String: AnyObject]) {
|
||||||
|
@ -123,6 +129,18 @@ class Network: NSObject, NSCoding {
|
||||||
portError = p.integerValue
|
portError = p.integerValue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let a = jsonData["allowManaged"] as? NSNumber {
|
||||||
|
allowManaged = a.boolValue
|
||||||
|
}
|
||||||
|
|
||||||
|
if let a = jsonData["allowGlobal"] as? NSNumber {
|
||||||
|
allowGlobal = a.boolValue
|
||||||
|
}
|
||||||
|
|
||||||
|
if let a = jsonData["allowDefault"] as? NSNumber {
|
||||||
|
allowDefault = a.boolValue
|
||||||
|
}
|
||||||
|
|
||||||
if let statusStr = jsonData["status"] as? String {
|
if let statusStr = jsonData["status"] as? String {
|
||||||
switch statusStr {
|
switch statusStr {
|
||||||
case "REQUESTING_CONFIGURATION":
|
case "REQUESTING_CONFIGURATION":
|
||||||
|
@ -209,6 +227,18 @@ class Network: NSObject, NSCoding {
|
||||||
if aDecoder.containsValueForKey(PropertyKeys.typeKey) {
|
if aDecoder.containsValueForKey(PropertyKeys.typeKey) {
|
||||||
self.type = NetworkType(rawValue: aDecoder.decodeIntegerForKey(PropertyKeys.typeKey))!
|
self.type = NetworkType(rawValue: aDecoder.decodeIntegerForKey(PropertyKeys.typeKey))!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if aDecoder.containsValueForKey(PropertyKeys.allowManagedKey) {
|
||||||
|
self.allowManaged = aDecoder.decodeBoolForKey(PropertyKeys.allowManagedKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
if aDecoder.containsValueForKey(PropertyKeys.allowGlobalKey) {
|
||||||
|
self.allowGlobal = aDecoder.decodeBoolForKey(PropertyKeys.allowGlobalKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
if aDecoder.containsValueForKey(PropertyKeys.allowDefaultKey) {
|
||||||
|
self.allowDefault = aDecoder.decodeBoolForKey(PropertyKeys.allowDefaultKey)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func encodeWithCoder(aCoder: NSCoder) {
|
func encodeWithCoder(aCoder: NSCoder) {
|
||||||
|
@ -225,5 +255,8 @@ class Network: NSObject, NSCoding {
|
||||||
aCoder.encodeInteger(self.portError, forKey: PropertyKeys.portErrorKey)
|
aCoder.encodeInteger(self.portError, forKey: PropertyKeys.portErrorKey)
|
||||||
aCoder.encodeInteger(self.status.rawValue, forKey: PropertyKeys.statusKey)
|
aCoder.encodeInteger(self.status.rawValue, forKey: PropertyKeys.statusKey)
|
||||||
aCoder.encodeInteger(self.type.rawValue, forKey: PropertyKeys.typeKey)
|
aCoder.encodeInteger(self.type.rawValue, forKey: PropertyKeys.typeKey)
|
||||||
|
aCoder.encodeBool(self.allowManaged, forKey: PropertyKeys.allowManagedKey)
|
||||||
|
aCoder.encodeBool(self.allowGlobal, forKey: PropertyKeys.allowGlobalKey)
|
||||||
|
aCoder.encodeBool(self.allowDefault, forKey: PropertyKeys.allowDefaultKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue