Display XOR mask in configuration screens

This commit is contained in:
Davide De Rosa 2021-07-23 17:27:01 +02:00
parent d31c647935
commit 165555bcad
3 changed files with 28 additions and 10 deletions

View File

@ -123,6 +123,15 @@ extension OpenVPN.ConfigurationBuilder {
let V = L10n.Core.Global.Values.self
return (randomizeEndpoint ?? false) ? V.enabled : V.disabled
}
public var uiDescriptionForXOR: String {
let V = L10n.Core.Global.Values.self
guard let mask = xorMask, mask != 0 else {
return V.disabled
}
return String(format: "0x%02x", UInt8(mask))
}
}
extension NetworkChoice: CustomStringConvertible {

View File

@ -102,10 +102,6 @@ class ConfigurationViewController: UIViewController, StrongTableHost {
model.set(rows, forSection: .compression)
}
if !isServerPushed {
model.add(.tls)
}
rows = []
if let _ = configuration.keepAliveInterval {
rows.append(.keepAlive)
@ -123,13 +119,11 @@ class ConfigurationViewController: UIViewController, StrongTableHost {
} else {
model.add(.communication)
model.add(.compression)
if !isServerPushed {
model.add(.tls)
}
model.add(.tls)
model.add(.other)
model.set([.cipher, .digest], forSection: .communication)
model.set([.compressionFraming, .compressionAlgorithm], forSection: .compression)
model.set([.keepAlive, .renegSeconds, .randomEndpoint], forSection: .other)
model.set([.keepAlive, .renegSeconds, .randomEndpoint, .xorMask], forSection: .other)
}
if isEditable {
model.set([.resetOriginal], forSection: .reset)
@ -254,6 +248,8 @@ extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegat
case compressionAlgorithm
case xorMask
case keepAlive
case renegSeconds
@ -311,7 +307,7 @@ extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegat
cell.leftText = V.CompressionAlgorithm.caption
cell.rightText = configuration.fallbackCompressionAlgorithm.uiDescription
cell.isTappable = (configuration.compressionFraming != .disabled)
case .client:
cell.leftText = V.Client.caption
cell.rightText = configuration.uiDescriptionForClientCertificate
@ -347,6 +343,12 @@ extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegat
cell.rightText = configuration.uiDescriptionForRandomizeEndpoint
cell.accessoryType = .none
cell.isTappable = false
case .xorMask:
cell.leftText = "XOR"
cell.rightText = configuration.uiDescriptionForXOR
cell.accessoryType = .none
cell.isTappable = false
}
return cell
}

View File

@ -71,7 +71,8 @@ class ConfigurationViewController: NSViewController, ProfileCustomization {
.eku,
.keepAlive,
.renegSeconds,
.randomEndpoint
.randomEndpoint,
.xorMask
]
private var rowMenus: [RowType: NSMenu] = [:]
@ -147,6 +148,7 @@ class ConfigurationViewController: NSViewController, ProfileCustomization {
rowMenus[.keepAlive] = NSMenu.withString(configuration.uiDescriptionForKeepAlive)
rowMenus[.renegSeconds] = NSMenu.withString(configuration.uiDescriptionForRenegotiatesAfter)
rowMenus[.randomEndpoint] = NSMenu.withString(configuration.uiDescriptionForRandomizeEndpoint)
rowMenus[.xorMask] = NSMenu.withString(configuration.uiDescriptionForXOR)
}
// MARK: Actions
@ -183,6 +185,8 @@ extension ConfigurationViewController: NSTableViewDataSource, NSTableViewDelegat
case renegSeconds
case randomEndpoint
case xorMask
}
func numberOfRows(in tableView: NSTableView) -> Int {
@ -225,6 +229,9 @@ extension ConfigurationViewController: NSTableViewDataSource, NSTableViewDelegat
case .randomEndpoint:
return V.RandomEndpoint.caption
case .xorMask:
return "XOR"
}
case Columns.value: