Revert "Parser: Interface name can be added after parsing"
This reverts commit d3a9e79149
.
Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
parent
3082863fd1
commit
4855eafb39
|
@ -21,13 +21,15 @@ class WgQuickConfigFileParser {
|
||||||
|
|
||||||
// Based on the parser written by Eric Kuck <eric@bluelinelabs.com> in commit 5ef1656
|
// Based on the parser written by Eric Kuck <eric@bluelinelabs.com> in commit 5ef1656
|
||||||
|
|
||||||
static func parse(_ text: String) throws -> TunnelConfiguration {
|
static func parse(_ text: String, name: String) throws -> TunnelConfiguration {
|
||||||
|
|
||||||
|
assert(!name.isEmpty)
|
||||||
|
|
||||||
func collate(interfaceAttributes attributes: [String:String]) -> InterfaceConfiguration? {
|
func collate(interfaceAttributes attributes: [String:String]) -> InterfaceConfiguration? {
|
||||||
// required wg fields
|
// required wg fields
|
||||||
guard let privateKeyString = attributes["PrivateKey"] else { return nil }
|
guard let privateKeyString = attributes["PrivateKey"] else { return nil }
|
||||||
guard let privateKey = Data(base64Encoded: privateKeyString), privateKey.count == 32 else { return nil }
|
guard let privateKey = Data(base64Encoded: privateKeyString), privateKey.count == 32 else { return nil }
|
||||||
var interface = InterfaceConfiguration(name: "", privateKey: privateKey)
|
var interface = InterfaceConfiguration(name: name, privateKey: privateKey)
|
||||||
// other wg fields
|
// other wg fields
|
||||||
if let listenPortString = attributes["ListenPort"] {
|
if let listenPortString = attributes["ListenPort"] {
|
||||||
guard let listenPort = UInt16(listenPortString) else { return nil }
|
guard let listenPort = UInt16(listenPortString) else { return nil }
|
||||||
|
|
Loading…
Reference in New Issue