summaryrefslogtreecommitdiffhomepage
path: root/Servers.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2016-09-22 10:40:06 -0400
committerJoey Hess <joeyh@joeyh.name>2016-09-22 10:44:55 -0400
commit3923667ebdb24680dbb415bd688a8c0326df2212 (patch)
tree81a6648827130f013053994ba6ec65ddb3cfd772 /Servers.hs
parent281bc63549a49c173b85d7b80b4b703aab9d3a52 (diff)
downloadkeysafe-3923667ebdb24680dbb415bd688a8c0326df2212.tar.gz
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.
Diffstat (limited to 'Servers.hs')
-rw-r--r--Servers.hs20
1 files changed, 13 insertions, 7 deletions
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")
+ []
]