summaryrefslogtreecommitdiffhomepage
path: root/Servers.hs
blob: 7edc7aff9d99c40ef541432f9c67009af31f0232 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{- Copyright 2016 Joey Hess <id@joeyh.name>
 -
 - Licensed under the GNU AGPL version 3 or higher.
 -}

module Servers where

import Types.Server
import Servant.Client
import System.Random.Shuffle

serverUrls :: Server -> [BaseUrl]
serverUrls srv = map go (serverAddress srv)
  where
	go (ServerAddress addr port) = BaseUrl Http addr port ""

networkServers :: [Server]
networkServers =
	[ Server (ServerName "keysafe.joeyh.name") Alternate
		[ServerAddress "vzgrspuxbtnlrtup.onion" 4242]
		"Provided by Joey Hess. Digital Ocean VPS, located in Indonesia"

	, Server (ServerName "keysafe.puri.sm") Alternate
		[]
		"Purism server is not yet deployed, but planned."

	-- Provided by https://faelix.net/
	-- Marek Isalski 
	, Server (ServerName "thirdserver") Alternate -- still being vetted
		[ServerAddress "eqi7glyxe5ravak5.onion" 4242]
		"Provided by Marek Isalski at Faelix. Currently located in UK, but planned move to CH"
	]

-- | Shuffles the server list, keeping Recommended first, then
-- Alternate, and finally Untrusted.
shuffleServers :: [Server] -> IO [Server]
shuffleServers l = concat <$> mapM shuf [minBound..maxBound]
  where
	shuf sl = shuffleM (filter (\s -> serverLevel s == sl) l)