mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-10-23 15:12:26 +00:00
log control port commands, authentication for control port (#1071)
* log control port commands * auth * add auth to xftp, config and commands * log missing auth * put smp save under auth * corrections --------- Co-authored-by: Evgeny Poberezkin <evgeny@poberezkin.com>
This commit is contained in:
1 parent
2712fbc711
commit
5e0123313c
10 files changed
+105
-26
No files matched your search
@@ -7,9 +7,13 @@ import qualified Data.Attoparsec.ByteString.Char8 as A
|
||||
import Data.ByteString (ByteString)
|
||||
import qualified Simplex.Messaging.Crypto as C
|
||||
import Simplex.Messaging.Encoding.String
|
||||
import Simplex.Messaging.Protocol (BasicAuth)
|
||||
|
||||
data CPClientRole = CPRNone | CPRUser | CPRAdmin
|
||||
|
||||
data ControlProtocol
|
||||
= CPStatsRTS
|
||||
= CPAuth BasicAuth
|
||||
| CPStatsRTS
|
||||
| CPDelete ByteString C.APublicAuthKey
|
||||
| CPHelp
|
||||
| CPQuit
|
||||
@@ -17,6 +21,7 @@ data ControlProtocol
|
||||
|
||||
instance StrEncoding ControlProtocol where
|
||||
strEncode = \case
|
||||
CPAuth tok -> "auth " <> strEncode tok
|
||||
CPStatsRTS -> "stats-rts"
|
||||
CPDelete fId fKey -> strEncode (Str "delete", fId, fKey)
|
||||
CPHelp -> "help"
|
||||
@@ -24,6 +29,7 @@ instance StrEncoding ControlProtocol where
|
||||
CPSkip -> ""
|
||||
strP =
|
||||
A.takeTill (== ' ') >>= \case
|
||||
"auth" -> CPAuth <$> _strP
|
||||
"stats-rts" -> pure CPStatsRTS
|
||||
"delete" -> CPDelete <$> _strP <*> _strP
|
||||
"help" -> pure CPHelp
|
||||
|
||||
Reference in new issue
Block a user