Commit b406c153 authored by Davide De Rosa's avatar Davide De Rosa
Browse files

Add method to insert custom server into list

parent 4f268512
......@@ -76,6 +76,8 @@ extension Client {
/// Sets the interval before which pings are not repeated.
public var minPingInterval: Int
private(set) var customServers: [Server]
// MARK: Connectivity
/// Notifies connectivity updates e.g. current IP addresses.
......@@ -169,6 +171,7 @@ extension Client {
)
serversUpdateWhenNetworkDownDelay = 10000
verifiesServersSignature = true
customServers = []
enablesServerPings = false
minPingInterval = 120000
......@@ -197,7 +200,7 @@ extension Client {
#endif
}
// MARK: Web
// MARK: WebServices
/**
Sets base URL for web services in a determined environment.
......@@ -209,6 +212,17 @@ extension Client {
baseUrls[environment] = url
}
// MARK: Server
/**
Inserts a custom server on top on the server list.
- Parameter server: The server.
*/
public func addCustomServer(_ server: Server) {
customServers.append(server)
}
// MARK: VPN
/**
......
......@@ -31,18 +31,9 @@ class DefaultServerProvider: ServerProvider, ConfigurationAccess, DatabaseAccess
return accessedDatabase.plain.cachedServers
}
set {
accessedDatabase.plain.cachedServers = newValue
if accessedConfiguration.isDevelopment {
let chipotle = Server(
name: "chipotle251",
country: "US",
hostname: "chipotle251.privateinternetaccess.com",
bestOpenVPNAddressForTCP: nil,
bestOpenVPNAddressForUDP: Server.Address(hostname: "108.61.57.211", port: 8080),
pingAddress: nil
)
accessedDatabase.plain.cachedServers.insert(chipotle, at: 0)
}
var servers = newValue
servers.insert(contentsOf: accessedConfiguration.customServers, at: 0)
accessedDatabase.plain.cachedServers = servers
Macros.postNotification(.PIAServerDidUpdateCurrentServers, [
.servers: newValue
......
Supports Markdown
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