mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-02-23 18:50:17 +00:00
add allowGlobal, allowDefault, allowManaged options to joining a network
This commit is contained in:
parent
5da4fd2aef
commit
9c94d6527a
@ -30,6 +30,10 @@ class JoinNetworkViewController: NSViewController, NSComboBoxDelegate, NSComboBo
|
||||
@IBOutlet var network: NSComboBox!
|
||||
@IBOutlet var joinButton: NSButton!
|
||||
|
||||
@IBOutlet var allowManagedCheckBox: NSButton!
|
||||
@IBOutlet var allowGlobalCheckBox: NSButton!
|
||||
@IBOutlet var allowDefaultCheckBox:NSButton!
|
||||
|
||||
var values: [String] = [String]()
|
||||
|
||||
override func viewDidLoad() {
|
||||
@ -61,8 +65,10 @@ class JoinNetworkViewController: NSViewController, NSComboBoxDelegate, NSComboBo
|
||||
@IBAction func onJoinClicked(sender: AnyObject?) {
|
||||
let networkString = network.stringValue
|
||||
|
||||
ServiceCom.joinNetwork(networkString)
|
||||
|
||||
ServiceCom.joinNetwork(networkString,
|
||||
allowManaged: allowManagedCheckBox.state == NSOnState,
|
||||
allowGlobal: allowGlobalCheckBox.state == NSOnState,
|
||||
allowDefault: allowDefaultCheckBox.state == NSOnState)
|
||||
network.stringValue = ""
|
||||
|
||||
|
||||
|
@ -6,6 +6,9 @@
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="JoinNetworkViewController" customModule="ZeroTier_One" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="allowDefaultCheckBox" destination="rz3-0a-oNA" id="mYu-Wq-MHW"/>
|
||||
<outlet property="allowGlobalCheckBox" destination="BH2-2O-Qeu" id="alx-Je-q9I"/>
|
||||
<outlet property="allowManagedCheckBox" destination="OQS-QZ-zcY" id="7pz-vO-3IC"/>
|
||||
<outlet property="joinButton" destination="BGy-vd-NQX" id="LGE-2G-7ND"/>
|
||||
<outlet property="network" destination="BQy-d9-BNg" id="Yf7-BG-c84"/>
|
||||
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
|
||||
@ -14,11 +17,11 @@
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<customView id="Hz6-mo-xeY">
|
||||
<rect key="frame" x="0.0" y="0.0" width="369" height="101"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="397" height="123"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<subviews>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="puT-Yk-CWC">
|
||||
<rect key="frame" x="18" y="61" width="107" height="17"/>
|
||||
<rect key="frame" x="18" y="83" width="107" height="17"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Enter Network ID" id="oYH-gS-BX5">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
@ -26,7 +29,7 @@
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="BGy-vd-NQX">
|
||||
<rect key="frame" x="274" y="13" width="81" height="32"/>
|
||||
<rect key="frame" x="302" y="13" width="81" height="32"/>
|
||||
<buttonCell key="cell" type="push" title="Join" bezelStyle="rounded" alignment="center" enabled="NO" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="6Rp-TA-XLl">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
@ -36,15 +39,36 @@
|
||||
</connections>
|
||||
</button>
|
||||
<comboBox verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="BQy-d9-BNg">
|
||||
<rect key="frame" x="131" y="57" width="221" height="26"/>
|
||||
<rect key="frame" x="131" y="79" width="249" height="26"/>
|
||||
<comboBoxCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" usesDataSource="YES" numberOfVisibleItems="5" id="n71-4S-AaI">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</comboBoxCell>
|
||||
</comboBox>
|
||||
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="OQS-QZ-zcY">
|
||||
<rect key="frame" x="18" y="59" width="115" height="18"/>
|
||||
<buttonCell key="cell" type="check" title="Allow Managed" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="QEN-MJ-xaj">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
</button>
|
||||
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="BH2-2O-Qeu">
|
||||
<rect key="frame" x="137" y="59" width="97" height="18"/>
|
||||
<buttonCell key="cell" type="check" title="Allow Global" bezelStyle="regularSquare" imagePosition="left" inset="2" id="epO-Uh-aHN">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
</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">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
</button>
|
||||
</subviews>
|
||||
<point key="canvasLocation" x="249.5" y="361.5"/>
|
||||
<point key="canvasLocation" x="263.5" y="372.5"/>
|
||||
</customView>
|
||||
</objects>
|
||||
</document>
|
||||
|
@ -119,13 +119,23 @@ class ServiceCom: NSObject {
|
||||
}
|
||||
|
||||
|
||||
static func joinNetwork(network: String) {
|
||||
static func joinNetwork(network: String, allowManaged: Bool = true, allowGlobal: Bool = false, allowDefault: Bool = false) {
|
||||
let urlString = baseURL + "/network/\(network)?auth=\(ServiceCom.getKey())"
|
||||
let url = NSURL(string: urlString)
|
||||
|
||||
var jsonDict = [String: AnyObject]()
|
||||
jsonDict["allowManaged"] = NSNumber(bool: allowManaged)
|
||||
jsonDict["allowGlobal"] = NSNumber(bool: allowGlobal)
|
||||
jsonDict["allowDefault"] = NSNumber(bool: allowDefault)
|
||||
|
||||
do {
|
||||
let json = try NSJSONSerialization.dataWithJSONObject(jsonDict, options: NSJSONWritingOptions())
|
||||
|
||||
if let u = url {
|
||||
let request = NSMutableURLRequest(URL: u)
|
||||
request.HTTPMethod = "POST"
|
||||
request.HTTPBody = json
|
||||
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
|
||||
|
||||
let session = NSURLSession.sharedSession()
|
||||
let task = session.dataTaskWithRequest(request) { (data, response, error) in
|
||||
@ -143,6 +153,11 @@ class ServiceCom: NSObject {
|
||||
task.resume()
|
||||
}
|
||||
}
|
||||
catch {
|
||||
NSLog("\(error)")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static func leaveNetwork(network: String) {
|
||||
let urlString = baseURL + "/network/\(network)?auth=\(ServiceCom.getKey())"
|
||||
|
Loading…
x
Reference in New Issue
Block a user