From a9e16c5335a638e30abf3a8dfb178c83279d83f3 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sun, 3 Mar 2019 10:40:12 +0100 Subject: [PATCH] Show custom DNS addresses in configuration UI --- .../Scenes/ConfigurationViewController.swift | 22 +++++++++++++++++++ .../Resources/en.lproj/Localizable.strings | 2 ++ Passepartout/Sources/SwiftGen+Strings.swift | 8 +++++++ 3 files changed, 32 insertions(+) diff --git a/Passepartout-iOS/Scenes/ConfigurationViewController.swift b/Passepartout-iOS/Scenes/ConfigurationViewController.swift index af9f4506..57db90f5 100644 --- a/Passepartout-iOS/Scenes/ConfigurationViewController.swift +++ b/Passepartout-iOS/Scenes/ConfigurationViewController.swift @@ -57,11 +57,17 @@ class ConfigurationViewController: UIViewController, TableModelHost { model.add(.reset) } model.add(.tls) + if let _ = configuration.dnsServers { + model.add(.dns) + } model.add(.other) // headers model.setHeader(L10n.Configuration.Sections.Communication.header, for: .communication) model.setHeader(L10n.Configuration.Sections.Tls.header, for: .tls) + if let _ = configuration.dnsServers { + model.setHeader(L10n.Configuration.Sections.Dns.header, for: .dns) + } model.setHeader(L10n.Configuration.Sections.Other.header, for: .other) // footers @@ -75,6 +81,9 @@ class ConfigurationViewController: UIViewController, TableModelHost { model.set([.resetOriginal], in: .reset) } model.set([.client, .tlsWrapping], in: .tls) + if let dnsServers = configuration.dnsServers { + model.set(.dnsServer, count: dnsServers.count, in: .dns) + } model.set([.compressionAlgorithm, .keepAlive, .renegSeconds], in: .other) return model @@ -157,6 +166,8 @@ extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegat case tls + case dns + case other } @@ -173,6 +184,8 @@ extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegat case tlsWrapping + case dnsServer + case compressionAlgorithm case keepAlive @@ -259,6 +272,15 @@ extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegat } cell.accessoryType = .none cell.isTappable = false + + case .dnsServer: + guard let dnsServers = configuration.dnsServers else { + fatalError("Showing DNS section without any custom server") + } + cell.leftText = L10n.Configuration.Cells.DnsServer.caption + cell.rightText = dnsServers[indexPath.row] + cell.accessoryType = .none + cell.isTappable = false case .compressionAlgorithm: cell.leftText = L10n.Configuration.Cells.CompressionAlgorithm.caption diff --git a/Passepartout/Resources/en.lproj/Localizable.strings b/Passepartout/Resources/en.lproj/Localizable.strings index 8c3bb1ea..fdd69722 100644 --- a/Passepartout/Resources/en.lproj/Localizable.strings +++ b/Passepartout/Resources/en.lproj/Localizable.strings @@ -136,6 +136,7 @@ "configuration.sections.communication.header" = "Communication"; "configuration.sections.reset.footer" = "If you ended up with broken connectivity after changing the communication parameters, tap to revert to the original configuration."; "configuration.sections.tls.header" = "TLS"; +"configuration.sections.dns.header" = "DNS"; "configuration.sections.other.header" = "Other"; "configuration.cells.cipher.caption" = "Cipher"; "configuration.cells.digest.caption" = "Authentication"; @@ -152,6 +153,7 @@ "configuration.cells.tls_wrapping.value.auth" = "Authentication"; "configuration.cells.tls_wrapping.value.crypt" = "Encryption"; "configuration.cells.tls_wrapping.value.disabled" = "Disabled"; +"configuration.cells.dns_server.caption" = "Address"; "configuration.cells.compression_algorithm.caption" = "Compression"; "configuration.cells.compression_algorithm.value.disabled" = "Disabled"; "configuration.cells.keep_alive.caption" = "Keep-alive"; diff --git a/Passepartout/Sources/SwiftGen+Strings.swift b/Passepartout/Sources/SwiftGen+Strings.swift index 65b9fde3..ea12dc8b 100644 --- a/Passepartout/Sources/SwiftGen+Strings.swift +++ b/Passepartout/Sources/SwiftGen+Strings.swift @@ -132,6 +132,10 @@ internal enum L10n { internal static let embedded = L10n.tr("Localizable", "configuration.cells.digest.value.embedded") } } + internal enum DnsServer { + /// Address + internal static let caption = L10n.tr("Localizable", "configuration.cells.dns_server.caption") + } internal enum KeepAlive { /// Keep-alive internal static let caption = L10n.tr("Localizable", "configuration.cells.keep_alive.caption") @@ -178,6 +182,10 @@ internal enum L10n { /// Communication internal static let header = L10n.tr("Localizable", "configuration.sections.communication.header") } + internal enum Dns { + /// DNS + internal static let header = L10n.tr("Localizable", "configuration.sections.dns.header") + } internal enum Other { /// Other internal static let header = L10n.tr("Localizable", "configuration.sections.other.header")