Only show pushed server configuration

This commit is contained in:
Davide De Rosa 2019-11-20 00:54:04 +01:00
parent a82454f5cf
commit 0657ae3b92
3 changed files with 55 additions and 12 deletions

View File

@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased
### Fixed
- Only show pushed server configuration.
## 1.9.1 (2019-11-10) ## 1.9.1 (2019-11-10)
### Changed ### Changed

View File

@ -46,12 +46,16 @@ class ConfigurationViewController: UIViewController, StrongTableHost {
return originalConfigurationURL != nil return originalConfigurationURL != nil
} }
var isServerPushed = false
weak var delegate: ConfigurationModificationDelegate? weak var delegate: ConfigurationModificationDelegate?
// MARK: StrongTableHost // MARK: StrongTableHost
lazy var model: StrongTableModel<SectionType, RowType> = { let model: StrongTableModel<SectionType, RowType> = StrongTableModel()
let model: StrongTableModel<SectionType, RowType> = StrongTableModel()
func reloadModel() {
model.clear()
// sections // sections
model.add(.communication) model.add(.communication)
@ -59,7 +63,9 @@ class ConfigurationViewController: UIViewController, StrongTableHost {
if isEditable { if isEditable {
model.add(.reset) model.add(.reset)
} }
model.add(.tls) if !isServerPushed {
model.add(.tls)
}
model.add(.other) model.add(.other)
// headers // headers
@ -74,18 +80,47 @@ class ConfigurationViewController: UIViewController, StrongTableHost {
} }
// rows // rows
model.set([.cipher, .digest], forSection: .communication) if isServerPushed {
var rows: [RowType]
rows = []
if let _ = configuration.cipher {
rows.append(.cipher)
}
if let _ = configuration.digest {
rows.append(.digest)
}
model.set(rows, forSection: .communication)
rows = []
if let _ = configuration.compressionFraming {
rows.append(.compressionFraming)
}
if let _ = configuration.compressionAlgorithm {
rows.append(.compressionAlgorithm)
}
model.set(rows, forSection: .compression)
rows = []
if let _ = configuration.keepAliveInterval {
rows.append(.keepAlive)
}
if let _ = configuration.renegotiatesAfter {
rows.append(.renegSeconds)
}
if let _ = configuration.randomizeEndpoint {
rows.append(.randomEndpoint)
}
model.set(rows, forSection: .other)
} else {
model.set([.cipher, .digest], forSection: .communication)
model.set([.compressionFraming, .compressionAlgorithm], forSection: .compression)
model.set([.keepAlive, .renegSeconds, .randomEndpoint], forSection: .other)
}
if isEditable { if isEditable {
model.set([.resetOriginal], forSection: .reset) model.set([.resetOriginal], forSection: .reset)
} }
model.set([.client, .tlsWrapping, .eku], forSection: .tls) model.set([.client, .tlsWrapping, .eku], forSection: .tls)
model.set([.compressionFraming, .compressionAlgorithm], forSection: .compression)
model.set([.keepAlive, .renegSeconds, .randomEndpoint], forSection: .other)
return model
}()
func reloadModel() {
} }
// MARK: UIViewController // MARK: UIViewController
@ -96,6 +131,7 @@ class ConfigurationViewController: UIViewController, StrongTableHost {
guard let _ = initialConfiguration else { guard let _ = initialConfiguration else {
fatalError("Initial configuration not set") fatalError("Initial configuration not set")
} }
reloadModel()
guard isEditable else { guard isEditable else {
tableView.allowsSelection = false tableView.allowsSelection = false

View File

@ -522,6 +522,7 @@ class ServiceViewController: UIViewController, StrongTableHost {
let vc = StoryboardScene.Main.configurationIdentifier.instantiate() let vc = StoryboardScene.Main.configurationIdentifier.instantiate()
vc.title = caption vc.title = caption
vc.initialConfiguration = $0 vc.initialConfiguration = $0
vc.isServerPushed = true
self?.navigationController?.pushViewController(vc, animated: true) self?.navigationController?.pushViewController(vc, animated: true)
} }
} }