Commit 9f54f2d6 authored by Jose Blaya's avatar Jose Blaya

handle nil addresses

parent 340ea499
......@@ -248,6 +248,9 @@ extension Server {
}
public func bestAddress() -> ServerAddressIP? {
guard !addresses().isEmpty else {
return nil
}
let availableServer = addresses().first(where: {$0.available})
if availableServer == nil {
addresses().map({$0.reset()})
......@@ -257,6 +260,9 @@ extension Server {
}
public func bestAddressForOVPN(tcp: Bool) -> ServerAddressIP? {
guard !ovpnAddresses(tcp: tcp).isEmpty else {
return nil
}
let availableServer = ovpnAddresses(tcp: tcp).first(where: {$0.available})
if availableServer == nil {
ovpnAddresses(tcp: tcp).map({$0.reset()})
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment