Show custom DNS addresses in configuration UI

This commit is contained in:
Davide De Rosa 2019-03-03 10:40:12 +01:00
parent e4a0e20207
commit a9e16c5335
3 changed files with 32 additions and 0 deletions

View File

@ -57,11 +57,17 @@ class ConfigurationViewController: UIViewController, TableModelHost {
model.add(.reset) model.add(.reset)
} }
model.add(.tls) model.add(.tls)
if let _ = configuration.dnsServers {
model.add(.dns)
}
model.add(.other) model.add(.other)
// headers // headers
model.setHeader(L10n.Configuration.Sections.Communication.header, for: .communication) model.setHeader(L10n.Configuration.Sections.Communication.header, for: .communication)
model.setHeader(L10n.Configuration.Sections.Tls.header, for: .tls) 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) model.setHeader(L10n.Configuration.Sections.Other.header, for: .other)
// footers // footers
@ -75,6 +81,9 @@ class ConfigurationViewController: UIViewController, TableModelHost {
model.set([.resetOriginal], in: .reset) model.set([.resetOriginal], in: .reset)
} }
model.set([.client, .tlsWrapping], in: .tls) 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) model.set([.compressionAlgorithm, .keepAlive, .renegSeconds], in: .other)
return model return model
@ -157,6 +166,8 @@ extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegat
case tls case tls
case dns
case other case other
} }
@ -173,6 +184,8 @@ extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegat
case tlsWrapping case tlsWrapping
case dnsServer
case compressionAlgorithm case compressionAlgorithm
case keepAlive case keepAlive
@ -259,6 +272,15 @@ extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegat
} }
cell.accessoryType = .none cell.accessoryType = .none
cell.isTappable = false 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: case .compressionAlgorithm:
cell.leftText = L10n.Configuration.Cells.CompressionAlgorithm.caption cell.leftText = L10n.Configuration.Cells.CompressionAlgorithm.caption

View File

@ -136,6 +136,7 @@
"configuration.sections.communication.header" = "Communication"; "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.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.tls.header" = "TLS";
"configuration.sections.dns.header" = "DNS";
"configuration.sections.other.header" = "Other"; "configuration.sections.other.header" = "Other";
"configuration.cells.cipher.caption" = "Cipher"; "configuration.cells.cipher.caption" = "Cipher";
"configuration.cells.digest.caption" = "Authentication"; "configuration.cells.digest.caption" = "Authentication";
@ -152,6 +153,7 @@
"configuration.cells.tls_wrapping.value.auth" = "Authentication"; "configuration.cells.tls_wrapping.value.auth" = "Authentication";
"configuration.cells.tls_wrapping.value.crypt" = "Encryption"; "configuration.cells.tls_wrapping.value.crypt" = "Encryption";
"configuration.cells.tls_wrapping.value.disabled" = "Disabled"; "configuration.cells.tls_wrapping.value.disabled" = "Disabled";
"configuration.cells.dns_server.caption" = "Address";
"configuration.cells.compression_algorithm.caption" = "Compression"; "configuration.cells.compression_algorithm.caption" = "Compression";
"configuration.cells.compression_algorithm.value.disabled" = "Disabled"; "configuration.cells.compression_algorithm.value.disabled" = "Disabled";
"configuration.cells.keep_alive.caption" = "Keep-alive"; "configuration.cells.keep_alive.caption" = "Keep-alive";

View File

@ -132,6 +132,10 @@ internal enum L10n {
internal static let embedded = L10n.tr("Localizable", "configuration.cells.digest.value.embedded") 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 { internal enum KeepAlive {
/// Keep-alive /// Keep-alive
internal static let caption = L10n.tr("Localizable", "configuration.cells.keep_alive.caption") internal static let caption = L10n.tr("Localizable", "configuration.cells.keep_alive.caption")
@ -178,6 +182,10 @@ internal enum L10n {
/// Communication /// Communication
internal static let header = L10n.tr("Localizable", "configuration.sections.communication.header") 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 { internal enum Other {
/// Other /// Other
internal static let header = L10n.tr("Localizable", "configuration.sections.other.header") internal static let header = L10n.tr("Localizable", "configuration.sections.other.header")