Parsing: Always error on unrecognized keys
Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
parent
fc03c635c1
commit
94c4922913
|
@ -34,7 +34,7 @@ extension TunnelConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
//swiftlint:disable:next function_body_length cyclomatic_complexity
|
//swiftlint:disable:next function_body_length cyclomatic_complexity
|
||||||
convenience init(fromWgQuickConfig wgQuickConfig: String, called name: String? = nil, ignoreUnrecognizedKeys: Bool = true) throws {
|
convenience init(fromWgQuickConfig wgQuickConfig: String, called name: String? = nil) throws {
|
||||||
var interfaceConfiguration: InterfaceConfiguration?
|
var interfaceConfiguration: InterfaceConfiguration?
|
||||||
var peerConfigurations = [PeerConfiguration]()
|
var peerConfigurations = [PeerConfiguration]()
|
||||||
|
|
||||||
|
@ -71,7 +71,6 @@ extension TunnelConfiguration {
|
||||||
} else {
|
} else {
|
||||||
attributes[key] = value
|
attributes[key] = value
|
||||||
}
|
}
|
||||||
if !ignoreUnrecognizedKeys {
|
|
||||||
let interfaceSectionKeys: Set<String> = ["privatekey", "listenport", "address", "dns", "mtu"]
|
let interfaceSectionKeys: Set<String> = ["privatekey", "listenport", "address", "dns", "mtu"]
|
||||||
let peerSectionKeys: Set<String> = ["publickey", "presharedkey", "allowedips", "endpoint", "persistentkeepalive"]
|
let peerSectionKeys: Set<String> = ["publickey", "presharedkey", "allowedips", "endpoint", "persistentkeepalive"]
|
||||||
if parserState == .inInterfaceSection {
|
if parserState == .inInterfaceSection {
|
||||||
|
@ -83,7 +82,6 @@ extension TunnelConfiguration {
|
||||||
throw ParseError.peerHasUnrecognizedKey(keyWithCase)
|
throw ParseError.peerHasUnrecognizedKey(keyWithCase)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else if lowercasedLine != "[interface]" && lowercasedLine != "[peer]" {
|
} else if lowercasedLine != "[interface]" && lowercasedLine != "[peer]" {
|
||||||
throw ParseError.invalidLine(line)
|
throw ParseError.invalidLine(line)
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ class TunnelEditViewController: NSViewController {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
let tunnelConfiguration = try TunnelConfiguration(fromWgQuickConfig: textView.string, called: nameRow.value, ignoreUnrecognizedKeys: false)
|
let tunnelConfiguration = try TunnelConfiguration(fromWgQuickConfig: textView.string, called: nameRow.value)
|
||||||
let onDemandSetting = ActivateOnDemandSetting.defaultSetting
|
let onDemandSetting = ActivateOnDemandSetting.defaultSetting
|
||||||
tunnelsManager.modify(tunnel: tunnel, tunnelConfiguration: tunnelConfiguration, activateOnDemandSetting: onDemandSetting) { [weak self] error in
|
tunnelsManager.modify(tunnel: tunnel, tunnelConfiguration: tunnelConfiguration, activateOnDemandSetting: onDemandSetting) { [weak self] error in
|
||||||
if let error = error {
|
if let error = error {
|
||||||
|
|
Loading…
Reference in New Issue