Allow adding unvalidated config.
This commit is contained in:
parent
0b2f004f62
commit
42f278ff49
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
|
@ -118,6 +118,7 @@
|
|||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
<connections>
|
||||
<action selector="textfieldDidChange:" destination="06N-KU-LSv" eventType="editingChanged" id="Ike-ou-qa9"/>
|
||||
<outlet property="delegate" destination="06N-KU-LSv" id="TuA-ac-TIy"/>
|
||||
</connections>
|
||||
</textField>
|
||||
|
@ -141,6 +142,7 @@
|
|||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
<connections>
|
||||
<action selector="textfieldDidChange:" destination="06N-KU-LSv" eventType="editingChanged" id="CQd-My-M7G"/>
|
||||
<outlet property="delegate" destination="06N-KU-LSv" id="7YF-mU-HZT"/>
|
||||
</connections>
|
||||
</textField>
|
||||
|
@ -167,6 +169,7 @@
|
|||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
<connections>
|
||||
<action selector="textfieldDidChange:" destination="06N-KU-LSv" eventType="editingChanged" id="d2c-NL-e1I"/>
|
||||
<outlet property="delegate" destination="06N-KU-LSv" id="apT-gO-mcr"/>
|
||||
</connections>
|
||||
</textField>
|
||||
|
@ -190,6 +193,7 @@
|
|||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
<connections>
|
||||
<action selector="textfieldDidChange:" destination="06N-KU-LSv" eventType="editingChanged" id="Vtr-4A-l3g"/>
|
||||
<outlet property="delegate" destination="06N-KU-LSv" id="CUZ-nd-ETQ"/>
|
||||
</connections>
|
||||
</textField>
|
||||
|
@ -210,6 +214,7 @@
|
|||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
<connections>
|
||||
<action selector="textfieldDidChange:" destination="06N-KU-LSv" eventType="editingChanged" id="z45-u7-zCB"/>
|
||||
<outlet property="delegate" destination="06N-KU-LSv" id="YZ0-LC-PjW"/>
|
||||
</connections>
|
||||
</textField>
|
||||
|
@ -235,6 +240,7 @@
|
|||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
<connections>
|
||||
<action selector="textfieldDidChange:" destination="06N-KU-LSv" eventType="editingChanged" id="8gN-mk-GtN"/>
|
||||
<outlet property="delegate" destination="06N-KU-LSv" id="YjV-8W-z5Q"/>
|
||||
</connections>
|
||||
</textField>
|
||||
|
@ -255,6 +261,7 @@
|
|||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
<connections>
|
||||
<action selector="textfieldDidChange:" destination="06N-KU-LSv" eventType="editingChanged" id="fgZ-LJ-ksN"/>
|
||||
<outlet property="delegate" destination="06N-KU-LSv" id="F1E-lK-AsD"/>
|
||||
</connections>
|
||||
</textField>
|
||||
|
@ -277,6 +284,15 @@
|
|||
<constraint firstItem="DIe-hK-tf6" firstAttribute="leading" secondItem="CSX-Am-ix0" secondAttribute="leadingMargin" id="sab-5q-2rU"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
<connections>
|
||||
<outlet property="addressesField" destination="Oh8-qT-kJL" id="8aV-2T-PxV"/>
|
||||
<outlet property="dnsField" destination="ByK-wW-6Q4" id="gZ4-7d-AHM"/>
|
||||
<outlet property="listenPortField" destination="CSv-At-WVr" id="xnx-xz-pqS"/>
|
||||
<outlet property="mtuField" destination="myM-B2-sjT" id="ppo-pV-tMl"/>
|
||||
<outlet property="nameField" destination="6y9-eJ-8fF" id="PKk-lj-jK9"/>
|
||||
<outlet property="privateKeyField" destination="hYd-0L-nnY" id="JLS-5M-E3T"/>
|
||||
<outlet property="publicKeyField" destination="aXZ-aL-pFu" id="Vdo-km-hgS"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="AddPeerTableViewCell" rowHeight="60" id="RyR-s5-lBV" customClass="AddPeerTableViewCell" customModule="WireGuard" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="396" width="375" height="60"/>
|
||||
|
@ -347,6 +363,7 @@
|
|||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
<connections>
|
||||
<action selector="textfieldDidChange:" destination="gzz-88-0IG" eventType="editingChanged" id="taX-Ji-pVu"/>
|
||||
<outlet property="delegate" destination="gzz-88-0IG" id="bkQ-Nc-VH4"/>
|
||||
</connections>
|
||||
</textField>
|
||||
|
@ -367,6 +384,7 @@
|
|||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
<connections>
|
||||
<action selector="textfieldDidChange:" destination="gzz-88-0IG" eventType="editingChanged" id="XeB-bW-Zog"/>
|
||||
<outlet property="delegate" destination="gzz-88-0IG" id="oAu-VZ-2dn"/>
|
||||
</connections>
|
||||
</textField>
|
||||
|
@ -387,6 +405,7 @@
|
|||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
<connections>
|
||||
<action selector="textfieldDidChange:" destination="gzz-88-0IG" eventType="editingChanged" id="k1U-vW-Jom"/>
|
||||
<outlet property="delegate" destination="gzz-88-0IG" id="DXo-0s-9sc"/>
|
||||
</connections>
|
||||
</textField>
|
||||
|
@ -410,6 +429,7 @@
|
|||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
<connections>
|
||||
<action selector="textfieldDidChange:" destination="gzz-88-0IG" eventType="editingChanged" id="bjR-TZ-Sx8"/>
|
||||
<outlet property="delegate" destination="gzz-88-0IG" id="PLB-sa-SBV"/>
|
||||
</connections>
|
||||
</textField>
|
||||
|
@ -430,6 +450,7 @@
|
|||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
<connections>
|
||||
<action selector="textfieldDidChange:" destination="gzz-88-0IG" eventType="editingChanged" id="fQC-Pf-jUQ"/>
|
||||
<outlet property="delegate" destination="gzz-88-0IG" id="sbH-Sb-rcW"/>
|
||||
</connections>
|
||||
</textField>
|
||||
|
@ -450,6 +471,13 @@
|
|||
<constraint firstAttribute="bottomMargin" secondItem="NIK-2J-pTR" secondAttribute="bottom" id="rRD-SV-Wft"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
<connections>
|
||||
<outlet property="allowedIpsField" destination="iiY-Tl-UcH" id="QQK-x0-C3T"/>
|
||||
<outlet property="endpointField" destination="W88-H0-dFZ" id="l0A-57-I5p"/>
|
||||
<outlet property="persistentKeepaliveField" destination="Q8w-jh-0ox" id="thE-f2-vzz"/>
|
||||
<outlet property="preSharedKeyField" destination="wkY-3s-yTK" id="0Tn-cP-uXS"/>
|
||||
<outlet property="publicKeyField" destination="RLw-0o-akQ" id="teS-po-0h2"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
</prototypes>
|
||||
<connections>
|
||||
|
|
|
@ -97,12 +97,10 @@ extension AppCoordinator: TunnelsTableViewControllerDelegate {
|
|||
}
|
||||
|
||||
func configure(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController) {
|
||||
// TODO implement
|
||||
print("configure tunnel \(tunnel)")
|
||||
let editContext = persistentContainer.newBackgroundContext()
|
||||
var backgroundTunnel: Tunnel?
|
||||
editContext.performAndWait {
|
||||
|
||||
backgroundTunnel = editContext.object(with: tunnel.objectID) as? Tunnel
|
||||
}
|
||||
|
||||
|
@ -118,8 +116,14 @@ extension AppCoordinator: TunnelsTableViewControllerDelegate {
|
|||
}
|
||||
|
||||
func delete(tunnel: Tunnel, tunnelsTableViewController: TunnelsTableViewController) {
|
||||
// TODO implement
|
||||
print("delete tunnel \(tunnel)")
|
||||
|
||||
if let moc = tunnel.managedObjectContext {
|
||||
moc.perform {
|
||||
moc.delete(tunnel)
|
||||
moc.saveContextToStore()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ extension Interface {
|
|||
@NSManaged public var dns: String?
|
||||
@NSManaged public var table: String?
|
||||
@NSManaged public var tunnel: Tunnel?
|
||||
@NSManaged public var publicKey: String?
|
||||
@NSManaged public var adresses: NSSet?
|
||||
|
||||
}
|
||||
|
|
|
@ -17,14 +17,32 @@ extension Tunnel {
|
|||
}
|
||||
|
||||
@NSManaged public var title: String?
|
||||
@NSManaged public var peers: NSSet?
|
||||
@NSManaged public var interface: Interface?
|
||||
@NSManaged public var peers: NSOrderedSet?
|
||||
|
||||
}
|
||||
|
||||
// MARK: Generated accessors for peers
|
||||
extension Tunnel {
|
||||
|
||||
@objc(insertObject:inPeersAtIndex:)
|
||||
@NSManaged public func insertIntoPeers(_ value: Peer, at idx: Int)
|
||||
|
||||
@objc(removeObjectFromPeersAtIndex:)
|
||||
@NSManaged public func removeFromPeers(at idx: Int)
|
||||
|
||||
@objc(insertPeers:atIndexes:)
|
||||
@NSManaged public func insertIntoPeers(_ values: [Peer], at indexes: NSIndexSet)
|
||||
|
||||
@objc(removePeersAtIndexes:)
|
||||
@NSManaged public func removeFromPeers(at indexes: NSIndexSet)
|
||||
|
||||
@objc(replaceObjectInPeersAtIndex:withObject:)
|
||||
@NSManaged public func replacePeers(at idx: Int, with value: Peer)
|
||||
|
||||
@objc(replacePeersAtIndexes:withPeers:)
|
||||
@NSManaged public func replacePeers(at indexes: NSIndexSet, with values: [Peer])
|
||||
|
||||
@objc(addPeersObject:)
|
||||
@NSManaged public func addToPeers(_ value: Peer)
|
||||
|
||||
|
@ -32,9 +50,9 @@ extension Tunnel {
|
|||
@NSManaged public func removeFromPeers(_ value: Peer)
|
||||
|
||||
@objc(addPeers:)
|
||||
@NSManaged public func addToPeers(_ values: NSSet)
|
||||
@NSManaged public func addToPeers(_ values: NSOrderedSet)
|
||||
|
||||
@objc(removePeers:)
|
||||
@NSManaged public func removeFromPeers(_ values: NSSet)
|
||||
@NSManaged public func removeFromPeers(_ values: NSOrderedSet)
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="14133" systemVersion="17E202" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
|
||||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="14135" systemVersion="17E202" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
|
||||
<entity name="Address" representedClassName="Address" syncable="YES">
|
||||
<attribute name="address" optional="YES" attributeType="String" syncable="YES"/>
|
||||
<relationship name="interface" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Interface" inverseName="adresses" inverseEntity="Interface" syncable="YES"/>
|
||||
|
@ -10,6 +10,7 @@
|
|||
<attribute name="listenPort" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
|
||||
<attribute name="mtu" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
|
||||
<attribute name="privateKey" attributeType="String" syncable="YES"/>
|
||||
<attribute name="publicKey" attributeType="String" syncable="YES"/>
|
||||
<attribute name="table" optional="YES" attributeType="String" syncable="YES"/>
|
||||
<relationship name="adresses" toMany="YES" deletionRule="Cascade" destinationEntity="Address" inverseName="interface" inverseEntity="Address" syncable="YES"/>
|
||||
<relationship name="tunnel" maxCount="1" deletionRule="Nullify" destinationEntity="Tunnel" inverseName="interface" inverseEntity="Tunnel" syncable="YES"/>
|
||||
|
@ -25,11 +26,11 @@
|
|||
<entity name="Tunnel" representedClassName="Tunnel" syncable="YES">
|
||||
<attribute name="title" optional="YES" attributeType="String" syncable="YES"/>
|
||||
<relationship name="interface" maxCount="1" deletionRule="Cascade" destinationEntity="Interface" inverseName="tunnel" inverseEntity="Interface" syncable="YES"/>
|
||||
<relationship name="peers" toMany="YES" deletionRule="Cascade" destinationEntity="Peer" inverseName="tunnel" inverseEntity="Peer" syncable="YES"/>
|
||||
<relationship name="peers" toMany="YES" deletionRule="Cascade" ordered="YES" destinationEntity="Peer" inverseName="tunnel" inverseEntity="Peer" syncable="YES"/>
|
||||
</entity>
|
||||
<elements>
|
||||
<element name="Address" positionX="-54" positionY="45" width="128" height="75"/>
|
||||
<element name="Interface" positionX="-54" positionY="-9" width="128" height="165"/>
|
||||
<element name="Interface" positionX="-54" positionY="-9" width="128" height="180"/>
|
||||
<element name="Peer" positionX="-36" positionY="9" width="128" height="135"/>
|
||||
<element name="Tunnel" positionX="160" positionY="192" width="128" height="90"/>
|
||||
</elements>
|
||||
|
|
|
@ -61,9 +61,19 @@ class TunnelConfigurationTableViewController: UITableViewController {
|
|||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
switch indexPath.section {
|
||||
case 0:
|
||||
return tableView.dequeueReusableCell(type: InterfaceTableViewCell.self, for: indexPath)
|
||||
let cell = tableView.dequeueReusableCell(type: InterfaceTableViewCell.self, for: indexPath)
|
||||
cell.model = tunnel.interface
|
||||
return cell
|
||||
case 1:
|
||||
return tableView.dequeueReusableCell(type: PeerTableViewCell.self, for: indexPath)
|
||||
let cell = tableView.dequeueReusableCell(type: PeerTableViewCell.self, for: indexPath)
|
||||
if let peer = tunnel.peers?.object(at: indexPath.row) as? Peer {
|
||||
cell.peer = peer
|
||||
} else {
|
||||
let peer = Peer(context: tunnel.managedObjectContext!)
|
||||
tunnel.addToPeers(peer)
|
||||
cell.peer = peer
|
||||
}
|
||||
return cell
|
||||
default:
|
||||
return tableView.dequeueReusableCell(type: AddPeerTableViewCell.self, for: indexPath)
|
||||
}
|
||||
|
@ -104,12 +114,38 @@ class InterfaceTableViewCell: UITableViewCell {
|
|||
}
|
||||
|
||||
extension InterfaceTableViewCell: UITextFieldDelegate {
|
||||
func textFieldDidBeginEditing(_ textField: UITextField) {
|
||||
print("\(textField) \(textField.text)")
|
||||
@IBAction
|
||||
func textfieldDidChange(_ sender: UITextField) {
|
||||
let string = sender.text
|
||||
print(string)
|
||||
|
||||
if sender == nameField {
|
||||
model.tunnel?.title = string
|
||||
} else if sender == privateKeyField {
|
||||
model.privateKey = string
|
||||
} else if sender == publicKeyField {
|
||||
model.publicKey = string
|
||||
} else if sender == addressesField {
|
||||
let address = Address(context: model.managedObjectContext!)
|
||||
address.address = string
|
||||
model.adresses = NSSet(array: [address])
|
||||
} else if sender == listenPortField {
|
||||
if let string = string, let port = Int16(string) {
|
||||
model.listenPort = port
|
||||
}
|
||||
|
||||
} else if sender == dnsField {
|
||||
model.dns = string
|
||||
} else if sender == mtuField {
|
||||
if let string = string, let mtu = Int32(string) {
|
||||
model.mtu = mtu
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
|
||||
print("\(string)")
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -126,12 +162,29 @@ class PeerTableViewCell: UITableViewCell {
|
|||
}
|
||||
|
||||
extension PeerTableViewCell: UITextFieldDelegate {
|
||||
func textFieldDidBeginEditing(_ textField: UITextField) {
|
||||
print("\(textField) \(textField.text)")
|
||||
@IBAction
|
||||
func textfieldDidChange(_ sender: UITextField) {
|
||||
let string = sender.text
|
||||
print(string)
|
||||
|
||||
if sender == publicKeyField {
|
||||
peer.publicKey = string
|
||||
} else if sender == preSharedKeyField {
|
||||
peer.presharedKey = string
|
||||
} else if sender == allowedIpsField {
|
||||
peer.allowedIPs = string
|
||||
} else if sender == endpointField {
|
||||
peer.endpoint = string
|
||||
} else if sender == persistentKeepaliveField {
|
||||
if let string = string, let persistentKeepalive = Int16(string) {
|
||||
peer.persistentKeepalive = persistentKeepalive
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
|
||||
print("\(string)")
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue