Reorganize compression section

- Show algorithm.
- Make framing readonly.

Easy way to prevent combination of LZO with new framing.
This commit is contained in:
Davide De Rosa 2019-03-19 11:52:17 +01:00
parent 3b1fbcc807
commit fbbd0b33f2
3 changed files with 79 additions and 40 deletions

View File

@ -58,6 +58,7 @@ class ConfigurationViewController: UIViewController, TableModelHost {
model.add(.reset) model.add(.reset)
} }
model.add(.tls) model.add(.tls)
model.add(.compression)
if let _ = configuration.dnsServers { if let _ = configuration.dnsServers {
model.add(.dns) model.add(.dns)
} }
@ -66,6 +67,7 @@ class ConfigurationViewController: UIViewController, TableModelHost {
// 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)
model.setHeader(L10n.Configuration.Sections.Compression.header, for: .compression)
if let _ = configuration.dnsServers { if let _ = configuration.dnsServers {
model.setHeader(L10n.Configuration.Sections.Dns.header, for: .dns) model.setHeader(L10n.Configuration.Sections.Dns.header, for: .dns)
} }
@ -77,15 +79,16 @@ class ConfigurationViewController: UIViewController, TableModelHost {
} }
// rows // rows
model.set([.cipher, .digest, .compressionFrame], in: .communication) model.set([.cipher, .digest], in: .communication)
if isEditable { if isEditable {
model.set([.resetOriginal], in: .reset) model.set([.resetOriginal], in: .reset)
} }
model.set([.client, .tlsWrapping], in: .tls) model.set([.client, .tlsWrapping], in: .tls)
model.set([.compressionFraming, .compressionAlgorithm], in: .compression)
if let dnsServers = configuration.dnsServers { if let dnsServers = configuration.dnsServers {
model.set(.dnsServer, count: dnsServers.count, in: .dns) model.set(.dnsServer, count: dnsServers.count, in: .dns)
} }
model.set([.compressionAlgorithm, .keepAlive, .renegSeconds], in: .other) model.set([.keepAlive, .renegSeconds], in: .other)
return model return model
}() }()
@ -167,6 +170,8 @@ extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegat
case tls case tls
case compression
case dns case dns
case other case other
@ -177,18 +182,18 @@ extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegat
case digest case digest
case compressionFrame
case resetOriginal case resetOriginal
case client case client
case tlsWrapping case tlsWrapping
case dnsServer case compressionFraming
case compressionAlgorithm case compressionAlgorithm
case dnsServer
case keepAlive case keepAlive
case renegSeconds case renegSeconds
@ -243,10 +248,6 @@ extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegat
cell.isTappable = false cell.isTappable = false
} }
case .compressionFrame:
cell.leftText = L10n.Configuration.Cells.CompressionFrame.caption
cell.rightText = configuration.compressionFraming.cellDescription
case .resetOriginal: case .resetOriginal:
cell.leftText = L10n.Configuration.Cells.ResetOriginal.caption cell.leftText = L10n.Configuration.Cells.ResetOriginal.caption
cell.applyAction(Theme.current) cell.applyAction(Theme.current)
@ -274,6 +275,23 @@ extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegat
cell.accessoryType = .none cell.accessoryType = .none
cell.isTappable = false cell.isTappable = false
case .compressionFraming:
cell.leftText = L10n.Configuration.Cells.CompressionFraming.caption
cell.rightText = configuration.compressionFraming.cellDescription
cell.accessoryType = .none
cell.isTappable = false
case .compressionAlgorithm:
cell.leftText = L10n.Configuration.Cells.CompressionAlgorithm.caption
let V = L10n.Configuration.Cells.CompressionAlgorithm.Value.self
if let compressionAlgorithm = configuration.compressionAlgorithm {
cell.rightText = compressionAlgorithm.cellDescription
} else {
cell.rightText = V.disabled
}
cell.accessoryType = .none
cell.isTappable = false
case .dnsServer: case .dnsServer:
guard let dnsServers = configuration.dnsServers else { guard let dnsServers = configuration.dnsServers else {
fatalError("Showing DNS section without any custom server") fatalError("Showing DNS section without any custom server")
@ -283,12 +301,6 @@ extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegat
cell.accessoryType = .none cell.accessoryType = .none
cell.isTappable = false cell.isTappable = false
case .compressionAlgorithm:
cell.leftText = L10n.Configuration.Cells.CompressionAlgorithm.caption
cell.rightText = L10n.Configuration.Cells.CompressionAlgorithm.Value.disabled // hardcoded because compression unsupported
cell.accessoryType = .none
cell.isTappable = false
case .keepAlive: case .keepAlive:
cell.leftText = L10n.Configuration.Cells.KeepAlive.caption cell.leftText = L10n.Configuration.Cells.KeepAlive.caption
let V = L10n.Configuration.Cells.KeepAlive.Value.self let V = L10n.Configuration.Cells.KeepAlive.Value.self
@ -350,17 +362,17 @@ extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegat
} }
navigationController?.pushViewController(vc, animated: true) navigationController?.pushViewController(vc, animated: true)
case .compressionFrame: // case .compressionFraming:
let vc = OptionViewController<SessionProxy.CompressionFraming>() // let vc = OptionViewController<SessionProxy.CompressionFraming>()
vc.title = settingCell?.leftText // vc.title = settingCell?.leftText
vc.options = [.disabled, .compLZO, .compress] // vc.options = [.disabled, .compLZO, .compress]
vc.selectedOption = configuration.compressionFraming // vc.selectedOption = configuration.compressionFraming
vc.descriptionBlock = { $0.cellDescription } // vc.descriptionBlock = { $0.cellDescription }
vc.selectionBlock = { [weak self] in // vc.selectionBlock = { [weak self] in
self?.configuration.compressionFraming = $0 // self?.configuration.compressionFraming = $0
self?.popAndCheckRefresh() // self?.popAndCheckRefresh()
} // }
navigationController?.pushViewController(vc, animated: true) // navigationController?.pushViewController(vc, animated: true)
case .resetOriginal: case .resetOriginal:
tableView.deselectRow(at: indexPath, animated: true) tableView.deselectRow(at: indexPath, animated: true)
@ -386,7 +398,7 @@ extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegat
private extension SessionProxy.CompressionFraming { private extension SessionProxy.CompressionFraming {
var cellDescription: String { var cellDescription: String {
let V = L10n.Configuration.Cells.CompressionFrame.Value.self let V = L10n.Configuration.Cells.CompressionFraming.Value.self
switch self { switch self {
case .disabled: case .disabled:
return V.disabled return V.disabled
@ -399,3 +411,19 @@ private extension SessionProxy.CompressionFraming {
} }
} }
} }
private extension SessionProxy.CompressionAlgorithm {
var cellDescription: String {
let V = L10n.Configuration.Cells.CompressionAlgorithm.Value.self
switch self {
case .disabled:
return V.disabled
case .LZO:
return V.lzo
case .other:
return V.other
}
}
}

View File

@ -139,15 +139,12 @@
"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.compression.header" = "Compression";
"configuration.sections.dns.header" = "DNS"; "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";
"configuration.cells.digest.value.embedded" = "Embedded"; "configuration.cells.digest.value.embedded" = "Embedded";
"configuration.cells.compression_frame.caption" = "Framing";
"configuration.cells.compression_frame.value.disabled" = "None";
"configuration.cells.compression_frame.value.lzo" = "LZO";
"configuration.cells.compression_frame.value.compress" = "Compress";
"configuration.cells.reset_original.caption" = "Reset configuration"; "configuration.cells.reset_original.caption" = "Reset configuration";
"configuration.cells.client.caption" = "Client certificate"; "configuration.cells.client.caption" = "Client certificate";
"configuration.cells.client.value.enabled" = "Verified"; "configuration.cells.client.value.enabled" = "Verified";
@ -157,8 +154,14 @@
"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.dns_server.caption" = "Address";
"configuration.cells.compression_algorithm.caption" = "Compression"; "configuration.cells.compression_framing.caption" = "Framing";
"configuration.cells.compression_framing.value.disabled" = "None";
"configuration.cells.compression_framing.value.lzo" = "--comp-lzo";
"configuration.cells.compression_framing.value.compress" = "--compress";
"configuration.cells.compression_algorithm.caption" = "Algorithm";
"configuration.cells.compression_algorithm.value.disabled" = "Disabled"; "configuration.cells.compression_algorithm.value.disabled" = "Disabled";
"configuration.cells.compression_algorithm.value.lzo" = "LZO";
"configuration.cells.compression_algorithm.value.other" = "Unsupported";
"configuration.cells.keep_alive.caption" = "Keep-alive"; "configuration.cells.keep_alive.caption" = "Keep-alive";
"configuration.cells.keep_alive.value.seconds" = "%d seconds"; "configuration.cells.keep_alive.value.seconds" = "%d seconds";
"configuration.cells.keep_alive.value.never" = "Disabled"; "configuration.cells.keep_alive.value.never" = "Disabled";

View File

@ -109,23 +109,27 @@ public enum L10n {
} }
} }
public enum CompressionAlgorithm { public enum CompressionAlgorithm {
/// Compression /// Algorithm
public static let caption = L10n.tr("Localizable", "configuration.cells.compression_algorithm.caption") public static let caption = L10n.tr("Localizable", "configuration.cells.compression_algorithm.caption")
public enum Value { public enum Value {
/// Disabled /// Disabled
public static let disabled = L10n.tr("Localizable", "configuration.cells.compression_algorithm.value.disabled") public static let disabled = L10n.tr("Localizable", "configuration.cells.compression_algorithm.value.disabled")
/// LZO
public static let lzo = L10n.tr("Localizable", "configuration.cells.compression_algorithm.value.lzo")
/// Unsupported
public static let other = L10n.tr("Localizable", "configuration.cells.compression_algorithm.value.other")
} }
} }
public enum CompressionFrame { public enum CompressionFraming {
/// Framing /// Framing
public static let caption = L10n.tr("Localizable", "configuration.cells.compression_frame.caption") public static let caption = L10n.tr("Localizable", "configuration.cells.compression_framing.caption")
public enum Value { public enum Value {
/// Compress /// --compress
public static let compress = L10n.tr("Localizable", "configuration.cells.compression_frame.value.compress") public static let compress = L10n.tr("Localizable", "configuration.cells.compression_framing.value.compress")
/// None /// None
public static let disabled = L10n.tr("Localizable", "configuration.cells.compression_frame.value.disabled") public static let disabled = L10n.tr("Localizable", "configuration.cells.compression_framing.value.disabled")
/// LZO /// --comp-lzo
public static let lzo = L10n.tr("Localizable", "configuration.cells.compression_frame.value.lzo") public static let lzo = L10n.tr("Localizable", "configuration.cells.compression_framing.value.lzo")
} }
} }
public enum Digest { public enum Digest {
@ -186,6 +190,10 @@ public enum L10n {
/// Communication /// Communication
public static let header = L10n.tr("Localizable", "configuration.sections.communication.header") public static let header = L10n.tr("Localizable", "configuration.sections.communication.header")
} }
public enum Compression {
/// Compression
public static let header = L10n.tr("Localizable", "configuration.sections.compression.header")
}
public enum Dns { public enum Dns {
/// DNS /// DNS
public static let header = L10n.tr("Localizable", "configuration.sections.dns.header") public static let header = L10n.tr("Localizable", "configuration.sections.dns.header")