summaryrefslogtreecommitdiffhomepage
path: root/Types.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2017-05-05 11:02:58 -0400
committerJoey Hess <joeyh@joeyh.name>2017-05-05 11:03:48 -0400
commitbe53d40694e59f9ef48d8a8106004623bddc703b (patch)
tree9699d7385da6c9276272812d91cb1f913884bb49 /Types.hs
parentb8a8b10ab8f2e593d55b7b1ab0d57817939decc0 (diff)
downloaddebug-me-be53d40694e59f9ef48d8a8106004623bddc703b.tar.gz
add protocol version
This is distinct from the wire protocol version used in the websocket framing of messages. Versioning the high level protocol will let later features be added. The user controls the protocol version, since they send the first several messages. Developers that connect need to avoid using features from newer protocol versions. So, developers and servers will need to support the most recent version, while the user can have an old version of debug-me and it will continue to work. This commit changes the protocol buffer encoding, and is the last such free change. All changes past this point will need to be versioned. This commit was sponsored by Jochen Bartl on Patreon.
Diffstat (limited to 'Types.hs')
-rw-r--r--Types.hs11
1 files changed, 8 insertions, 3 deletions
diff --git a/Types.hs b/Types.hs
index 79ce289..ce986c7 100644
--- a/Types.hs
+++ b/Types.hs
@@ -3,7 +3,7 @@
- Licensed under the GNU AGPL version 3 or higher.
-}
-{-# LANGUAGE DeriveGeneric, FlexibleInstances, FlexibleContexts #-}
+{-# LANGUAGE DeriveGeneric, FlexibleInstances, FlexibleContexts, OverloadedStrings #-}
{- | Main types for debug-me
-
@@ -101,7 +101,7 @@ data ControlAction
, enteredLastAccepted :: Maybe Hash
-- ^ The last Entered value that was accepted.
}
- | SessionKey (PerhapsSigned PublicKey)
+ | SessionKey (PerhapsSigned PublicKey) ProtocolVersion
-- ^ sent by user at start, and later by developer,
-- to indicate their session key
| SessionKeyAccepted PublicKey
@@ -112,12 +112,17 @@ data ControlAction
-- ^ sent by user or developer at any time
deriving (Show, Generic)
+type ProtocolVersion = Val
+
+currentProtocolVersion :: ProtocolVersion
+currentProtocolVersion = Val "1"
+
type SenderName = Val
instance DataSize ControlAction where
dataSize (EnteredRejected h1 h2) = dataSize h1 +
maybe 0 dataSize h2
- dataSize (SessionKey k) = dataSize k
+ dataSize (SessionKey k v) = dataSize k + dataSize v
dataSize (SessionKeyAccepted k) = dataSize k
dataSize (SessionKeyRejected k) = dataSize k
dataSize (ChatMessage s m) = dataSize s + dataSize m