aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2018-10-23 15:51:19 +0530
committerRoopesh Chander <roop@roopc.net>2018-10-27 15:13:01 +0530
commitb2f2756d9ca2b23b37f7c7147242a340bba04319 (patch)
treecd88297b4b736f6d31c69e297f79963587aa37c7 /WireGuard/WireGuard
parentTunnel creation: Refactor by creating a separate view model (diff)
downloadwireguard-apple-b2f2756d9ca2b23b37f7c7147242a340bba04319.tar.xz
wireguard-apple-b2f2756d9ca2b23b37f7c7147242a340bba04319.zip
Model: listenPort and persistentKeepAlive should be 16-bit integers
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard/WireGuard')
-rw-r--r--WireGuard/WireGuard/Model/Configuration.swift4
-rw-r--r--WireGuard/WireGuard/UI/TunnelViewModel.swift8
2 files changed, 6 insertions, 6 deletions
diff --git a/WireGuard/WireGuard/Model/Configuration.swift b/WireGuard/WireGuard/Model/Configuration.swift
index ce71630..b135ddd 100644
--- a/WireGuard/WireGuard/Model/Configuration.swift
+++ b/WireGuard/WireGuard/Model/Configuration.swift
@@ -22,7 +22,7 @@ struct InterfaceConfiguration: Codable {
var name: String
var privateKey: Data
var addresses: [IPAddressRange] = []
- var listenPort: UInt64? = nil
+ var listenPort: UInt16? = nil
var mtu: UInt64? = nil
var dns: String? = nil
@@ -46,7 +46,7 @@ struct PeerConfiguration: Codable {
}
var allowedIPs: [IPAddressRange] = []
var endpoint: Endpoint?
- var persistentKeepAlive: UInt64?
+ var persistentKeepAlive: UInt16?
init(publicKey: Data) {
self.publicKey = publicKey
diff --git a/WireGuard/WireGuard/UI/TunnelViewModel.swift b/WireGuard/WireGuard/UI/TunnelViewModel.swift
index 6b6285c..13c831f 100644
--- a/WireGuard/WireGuard/UI/TunnelViewModel.swift
+++ b/WireGuard/WireGuard/UI/TunnelViewModel.swift
@@ -109,11 +109,11 @@ class TunnelViewModel {
config.addresses = addresses
}
if let listenPortString = scratchpad[.listenPort] {
- if let listenPort = UInt64(listenPortString) {
+ if let listenPort = UInt16(listenPortString) {
config.listenPort = listenPort
} else {
fieldsWithError.insert(.listenPort)
- errorMessages.append("Interface's listen port should be a number")
+ errorMessages.append("Interface's listen port should be a 16-bit integer (0 to 65535)")
}
}
if let mtuString = scratchpad[.mtu] {
@@ -231,11 +231,11 @@ class TunnelViewModel {
}
}
if let persistentKeepAliveString = scratchpad[.persistentKeepAlive] {
- if let persistentKeepAlive = UInt64(persistentKeepAliveString) {
+ if let persistentKeepAlive = UInt16(persistentKeepAliveString) {
config.persistentKeepAlive = persistentKeepAlive
} else {
fieldsWithError.insert(.persistentKeepAlive)
- errorMessages.append("Peer's persistent keepalive should be a number")
+ errorMessages.append("Peer's persistent keepalive should be a 16-bit integer (0 to 65535)")
}
}