summaryrefslogtreecommitdiffhomepage
path: root/Types
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 /Types
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 'Types')
-rw-r--r--Types/Server.hs23
1 files changed, 21 insertions, 2 deletions
diff --git a/Types/Server.hs b/Types/Server.hs
index dd06909..e1b4191 100644
--- a/Types/Server.hs
+++ b/Types/Server.hs
@@ -3,14 +3,33 @@
- Licensed under the GNU AGPL version 3 or higher.
-}
+{-# LANGUAGE DeriveGeneric #-}
+
module Types.Server where
+import Data.Aeson
+import GHC.Generics
import Network.Wai.Handler.Warp (Port)
type HostName = String
+-- | Server address can use either tor .onion addresses, or regular
+-- hostnames. Using tor is highly recommended, to avoid correlation
+-- attacks.
+data ServerAddress = ServerAddress HostName Port
+ deriving (Show)
+
+-- | Name used in queuing uploads to the server. Should remain stable
+-- across keysafe versions.
+newtype ServerName = ServerName String
+ deriving (Show, Generic)
+
+instance ToJSON ServerName
+instance FromJSON ServerName
+
data Server = Server
- { serverName :: HostName
- , serverPort :: Port
+ { serverName :: ServerName
+ , serverAddress :: [ServerAddress]
+ -- ^ A server may have multiple addresses, or no current address.
}
deriving (Show)