Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not pass key to control port of xftp server #1074

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/Simplex/FileTransfer/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,13 @@ xftpServer cfg@XFTPServerConfig {xftpPort, transportConfig, inactiveClientExpira
| Just auth == user = CPRUser
| otherwise = CPRNone
CPStatsRTS -> E.tryAny getRTSStats >>= either (hPrint h) (hPrint h)
CPDelete fileId fKey -> withUserRole $ unliftIO u $ do
CPDelete fileId -> withUserRole $ unliftIO u $ do
fs <- asks store
r <- runExceptT $ do
let asSender = ExceptT . atomically $ getFile fs SFSender fileId
let asRecipient = ExceptT . atomically $ getFile fs SFRecipient fileId
(fr, fKey') <- asSender `catchError` const asRecipient
if fKey == fKey'
then ExceptT $ deleteServerFile_ fr
else throwError AUTH
(fr, _) <- asSender `catchError` const asRecipient
ExceptT $ deleteServerFile_ fr
liftIO . hPutStrLn h $ either (\e -> "error: " <> show e) (\() -> "ok") r
CPHelp -> hPutStrLn h "commands: stats-rts, delete, help, quit"
CPQuit -> pure ()
Expand Down
6 changes: 3 additions & 3 deletions src/Simplex/FileTransfer/Server/Control.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import qualified Data.Attoparsec.ByteString.Char8 as A
import Data.ByteString (ByteString)
import qualified Simplex.Messaging.Crypto as C

Check warning on line 8 in src/Simplex/FileTransfer/Server/Control.hs

View workflow job for this annotation

GitHub Actions / build-ubuntu-20.04-9.6.3

The qualified import of ‘Simplex.Messaging.Crypto’ is redundant

Check warning on line 8 in src/Simplex/FileTransfer/Server/Control.hs

View workflow job for this annotation

GitHub Actions / build-ubuntu-22.04-9.6.3

The qualified import of ‘Simplex.Messaging.Crypto’ is redundant
import Simplex.Messaging.Encoding.String
import Simplex.Messaging.Protocol (BasicAuth)

Expand All @@ -14,7 +14,7 @@
data ControlProtocol
= CPAuth BasicAuth
| CPStatsRTS
| CPDelete ByteString C.APublicAuthKey
| CPDelete ByteString
| CPHelp
| CPQuit
| CPSkip
Expand All @@ -23,15 +23,15 @@
strEncode = \case
CPAuth tok -> "auth " <> strEncode tok
CPStatsRTS -> "stats-rts"
CPDelete fId fKey -> strEncode (Str "delete", fId, fKey)
CPDelete fId -> strEncode (Str "delete", fId)
CPHelp -> "help"
CPQuit -> "quit"
CPSkip -> ""
strP =
A.takeTill (== ' ') >>= \case
"auth" -> CPAuth <$> _strP
"stats-rts" -> pure CPStatsRTS
"delete" -> CPDelete <$> _strP <*> _strP
"delete" -> CPDelete <$> _strP
"help" -> pure CPHelp
"quit" -> pure CPQuit
"" -> pure CPSkip
Expand Down
Loading