From 3923667ebdb24680dbb415bd688a8c0326df2212 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 22 Sep 2016 10:40:06 -0400 Subject: allow servers to have multiple or no addresses This allows the server list to contain 3 servers although only 1 is running so far; uploads to the others will be queued. It also allows a server to be spread amoung multiple addresses, which may be useful later for scaling. This changes BackupRecord serialization, but it's not been in a keysafe release yet, so that's not a problem. This commit was sponsored by Boyd Stephen Smith Jr. on Patreon. --- Servers.hs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'Servers.hs') diff --git a/Servers.hs b/Servers.hs index 0a1e246..8b99fe0 100644 --- a/Servers.hs +++ b/Servers.hs @@ -8,14 +8,20 @@ module Servers where import Types.Server import Servant.Client -serverUrl :: Server -> BaseUrl -serverUrl srv = BaseUrl Http (serverName srv) (serverPort srv) "" +serverUrls :: Server -> [BaseUrl] +serverUrls srv = map go (serverAddress srv) + where + go (ServerAddress addr port) = BaseUrl Http addr port "" --- | These can be either tor .onion addresses, or regular hostnames. --- Using tor is highly recommended, to avoid correlation attacks. networkServers :: IO [Server] networkServers = return - [ Server "vzgrspuxbtnlrtup.onion" 4242 -- keysafe.joeyh.name - , Server "localhost" 4242 - , Server "localhost" 4242 + [ Server (ServerName "keysafe.joeyh.name") + [ServerAddress "vzgrspuxbtnlrtup.onion" 4242] + -- Purism server is not yet deployed, but planned. + , Server (ServerName "keysafe.puri.sm") + [] + -- Unknown yet who will provide this server, but allocate it now + -- so keysafe can start queuing uploads to it. + , Server (ServerName "thirdserver") + [] ] -- cgit v1.2.3