From 903fd02eb29a7bbef685466c5f70b3c16a243fb7 Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Wed, 24 Oct 2018 19:01:33 +0530 Subject: [PATCH] Model: MTU should be a 16-bit integer --- WireGuard/WireGuard/Model/Configuration.swift | 2 +- WireGuard/WireGuard/UI/TunnelViewModel.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/WireGuard/WireGuard/Model/Configuration.swift b/WireGuard/WireGuard/Model/Configuration.swift index 3cc59af..8ef93e6 100644 --- a/WireGuard/WireGuard/Model/Configuration.swift +++ b/WireGuard/WireGuard/Model/Configuration.swift @@ -18,7 +18,7 @@ struct InterfaceConfiguration: Codable { var privateKey: Data var addresses: [IPAddressRange] = [] var listenPort: UInt16? = nil - var mtu: UInt64? = nil + var mtu: UInt16? = nil var dns: [DNSServer] = [] var publicKey: Data { diff --git a/WireGuard/WireGuard/UI/TunnelViewModel.swift b/WireGuard/WireGuard/UI/TunnelViewModel.swift index cb678d1..bc826d5 100644 --- a/WireGuard/WireGuard/UI/TunnelViewModel.swift +++ b/WireGuard/WireGuard/UI/TunnelViewModel.swift @@ -134,11 +134,11 @@ class TunnelViewModel { } } if let mtuString = scratchpad[.mtu] { - if let mtu = UInt64(mtuString) { + if let mtu = UInt16(mtuString) { config.mtu = mtu } else { fieldsWithError.insert(.mtu) - errorMessages.append("Interface's MTU should be a number") + errorMessages.append("Interface's MTU should be a 16-bit integer (0 to 65535)") } } if let dnsString = scratchpad[.dns] {