From 762618ee5a80dd5c2f9f0d090be5cd6d51f3ad71 Mon Sep 17 00:00:00 2001 From: Jeroen Leenarts Date: Tue, 7 Aug 2018 21:31:43 +0200 Subject: [PATCH] Generate split allowed IPs in protocol configuration. Signed-off-by: Jason A. Donenfeld --- WireGuard/Models/Tunnel+Extension.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/WireGuard/Models/Tunnel+Extension.swift b/WireGuard/Models/Tunnel+Extension.swift index b424cde..bd025cc 100644 --- a/WireGuard/Models/Tunnel+Extension.swift +++ b/WireGuard/Models/Tunnel+Extension.swift @@ -64,8 +64,10 @@ extension Tunnel { if peer.persistentKeepalive > 0 { settingsString += "persistent_keepalive_interval=\(peer.persistentKeepalive)" } - if let allowedIPs = peer.allowedIPs { - settingsString += "allowed_ip=\(allowedIPs)" // TODO: split on , + if let allowedIPs = peer.allowedIPs?.split(separator: ",") { + allowedIPs.forEach { + settingsString += "allowed_ip=\($0.trimmingCharacters(in: .whitespaces))" + } } return settingsString