aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/Shared/Model
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-12-21 23:34:56 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2018-12-21 23:34:56 +0100
commit7b9d4cb9e35a88f13face71543ce4773102fe224 (patch)
tree90810e67570a1bd2b520f352b50117925d3b1fab /WireGuard/Shared/Model
parentproviderConfiguration is now a WgQuickConfig (diff)
downloadwireguard-apple-7b9d4cb9e35a88f13face71543ce4773102fe224.tar.xz
wireguard-apple-7b9d4cb9e35a88f13face71543ce4773102fe224.zip
Nuke trailing spaces
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'WireGuard/Shared/Model')
-rw-r--r--WireGuard/Shared/Model/DNSServer.swift4
-rw-r--r--WireGuard/Shared/Model/Endpoint.swift4
-rw-r--r--WireGuard/Shared/Model/IPAddressRange.swift10
-rw-r--r--WireGuard/Shared/Model/InterfaceConfiguration.swift2
-rw-r--r--WireGuard/Shared/Model/PeerConfiguration.swift2
5 files changed, 11 insertions, 11 deletions
diff --git a/WireGuard/Shared/Model/DNSServer.swift b/WireGuard/Shared/Model/DNSServer.swift
index 9078b598..710c656c 100644
--- a/WireGuard/Shared/Model/DNSServer.swift
+++ b/WireGuard/Shared/Model/DNSServer.swift
@@ -6,7 +6,7 @@ import Network
struct DNSServer {
let address: IPAddress
-
+
init(address: IPAddress) {
self.address = address
}
@@ -16,7 +16,7 @@ extension DNSServer {
var stringRepresentation: String {
return "\(address)"
}
-
+
init?(from addressString: String) {
if let addr = IPv4Address(addressString) {
address = addr
diff --git a/WireGuard/Shared/Model/Endpoint.swift b/WireGuard/Shared/Model/Endpoint.swift
index b29a5a8d..03de1318 100644
--- a/WireGuard/Shared/Model/Endpoint.swift
+++ b/WireGuard/Shared/Model/Endpoint.swift
@@ -7,7 +7,7 @@ import Network
struct Endpoint {
let host: NWEndpoint.Host
let port: NWEndpoint.Port
-
+
init(host: NWEndpoint.Host, port: NWEndpoint.Port) {
self.host = host
self.port = port
@@ -25,7 +25,7 @@ extension Endpoint {
return "[\(address)]:\(port)"
}
}
-
+
init?(from string: String) {
// Separation of host and port is based on 'parse_endpoint' function in
// https://git.zx2c4.com/WireGuard/tree/src/tools/config.c
diff --git a/WireGuard/Shared/Model/IPAddressRange.swift b/WireGuard/Shared/Model/IPAddressRange.swift
index 28f3d005..7d3e5eca 100644
--- a/WireGuard/Shared/Model/IPAddressRange.swift
+++ b/WireGuard/Shared/Model/IPAddressRange.swift
@@ -7,7 +7,7 @@ import Network
struct IPAddressRange {
let address: IPAddress
var networkPrefixLength: UInt8
-
+
init(address: IPAddress, networkPrefixLength: UInt8) {
self.address = address
self.networkPrefixLength = networkPrefixLength
@@ -18,13 +18,13 @@ extension IPAddressRange {
var stringRepresentation: String {
return "\(address)/\(networkPrefixLength)"
}
-
+
init?(from string: String) {
guard let parsed = IPAddressRange.parseAddressString(string) else { return nil }
address = parsed.0
networkPrefixLength = parsed.1
}
-
+
private static func parseAddressString(_ string: String) -> (IPAddress, UInt8)? {
let endOfIPAddress = string.lastIndex(of: "/") ?? string.endIndex
let addressString = String(string[string.startIndex ..< endOfIPAddress])
@@ -36,7 +36,7 @@ extension IPAddressRange {
} else {
return nil
}
-
+
let maxNetworkPrefixLength: UInt8 = address is IPv4Address ? 32 : 128
var networkPrefixLength: UInt8
if endOfIPAddress < string.endIndex { // "/" was located
@@ -48,7 +48,7 @@ extension IPAddressRange {
} else {
networkPrefixLength = maxNetworkPrefixLength
}
-
+
return (address, networkPrefixLength)
}
}
diff --git a/WireGuard/Shared/Model/InterfaceConfiguration.swift b/WireGuard/Shared/Model/InterfaceConfiguration.swift
index 9094d149..ff804a6a 100644
--- a/WireGuard/Shared/Model/InterfaceConfiguration.swift
+++ b/WireGuard/Shared/Model/InterfaceConfiguration.swift
@@ -10,7 +10,7 @@ struct InterfaceConfiguration {
var listenPort: UInt16?
var mtu: UInt16?
var dns = [DNSServer]()
-
+
init(name: String?, privateKey: Data) {
self.name = name
self.privateKey = privateKey
diff --git a/WireGuard/Shared/Model/PeerConfiguration.swift b/WireGuard/Shared/Model/PeerConfiguration.swift
index a113821d..2e969e6c 100644
--- a/WireGuard/Shared/Model/PeerConfiguration.swift
+++ b/WireGuard/Shared/Model/PeerConfiguration.swift
@@ -17,7 +17,7 @@ struct PeerConfiguration {
var allowedIPs = [IPAddressRange]()
var endpoint: Endpoint?
var persistentKeepAlive: UInt16?
-
+
init(publicKey: Data) {
self.publicKey = publicKey
if publicKey.count != TunnelConfiguration.keyLength {