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. --- Types/Server.hs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'Types') 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) -- cgit v1.2.3