Add string conversion for tunnel config.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
@@ -63,6 +63,29 @@ extension Peer {
|
||||
}
|
||||
}
|
||||
|
||||
func export() -> String {
|
||||
var exportString = "[Peer]\n"
|
||||
if let publicKey = publicKey {
|
||||
exportString.append("PublicKey=\(publicKey)\n")
|
||||
}
|
||||
if let presharedKey = presharedKey {
|
||||
exportString.append("PresharedKey=\(presharedKey)\n")
|
||||
}
|
||||
if let allowedIPs = allowedIPs {
|
||||
exportString.append("AllowedIPs=\(allowedIPs)\n")
|
||||
}
|
||||
if let endpoint = endpoint {
|
||||
exportString.append("Endpoint=\(endpoint)\n")
|
||||
}
|
||||
if persistentKeepalive > 0 {
|
||||
exportString.append("PersistentKeepalive=\(persistentKeepalive)\n")
|
||||
}
|
||||
|
||||
exportString.append("\n")
|
||||
|
||||
return exportString
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
enum PeerValidationError: Error {
|
||||
|
||||
Reference in New Issue
Block a user