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

Request: Support MODE command #451

Open
tfranssen opened this issue Apr 26, 2024 · 3 comments
Open

Request: Support MODE command #451

tfranssen opened this issue Apr 26, 2024 · 3 comments

Comments

@tfranssen
Copy link

tfranssen commented Apr 26, 2024

I want to use sFTPgo together with a Reolink camera. The camera sends a MODE S command before uploading a file. ftpserverlib does not recognize this and sends an error.

This is how the MODE should be implemented.

MODE FTP command
This command changes the transfer mode. The argument is a single Telnet character code specifying the data transfer modes described in the Section on Transmission Modes.

The following codes are assigned for transfer modes:
S – Stream
B – Block
C – Compressed
Z – Deflate
The default transfer mode is Stream. Mode Z (commonly referred to as “on-the-fly” compression) is defined in an IETF draft.

@tfranssen tfranssen changed the title Request: Request: Support MODE command Apr 26, 2024
@tfranssen
Copy link
Author

tfranssen commented Apr 26, 2024

Added some logging:

Apr 26 12:27:18 ftpS3Gateway sftpgo[3542]: {"level":"debug","time":"2024-04-26T12:27:18.847","sender":"ftpserverlib","server_id":"FTP_0","clientId":"7","clientIp":"*****:22432","message":"Client connected"}
Apr 26 12:27:18 ftpS3Gateway sftpgo[3542]: {"level":"debug","time":"2024-04-26T12:27:18.849","sender":"FTP","connection_id":"FTP_0_7","message":"connection added, local address \"*****:21\", remote address \"*******:22432\", num open connections: 1"}
Apr 26 12:27:18 ftpS3Gateway sftpgo[3542]: {"level":"debug","time":"2024-04-26T12:27:18.849","sender":"ftpserverlib","server_id":"FTP_0","clientId":"7","line":"220 SFTPGo 2.5.6 ready","message":"Sending answer"}
Apr 26 12:27:18 ftpS3Gateway sftpgo[3542]: {"level":"debug","time":"2024-04-26T12:27:18.973","sender":"ftpserverlib","server_id":"FTP_0","clientId":"7","line":"AUTH TLS","message":"Received line"}
Apr 26 12:27:18 ftpS3Gateway sftpgo[3542]: {"level":"debug","time":"2024-04-26T12:27:18.974","sender":"ftpserverlib","server_id":"FTP_0","clientId":"7","line":"550 Cannot get a TLS config: no TLS certificate configured","message":"Sending answer"}
Apr 26 12:27:19 ftpS3Gateway sftpgo[3542]: {"level":"debug","time":"2024-04-26T12:27:19.090","sender":"ftpserverlib","server_id":"FTP_0","clientId":"7","line":"USER wildspotter","message":"Received line"}
Apr 26 12:27:19 ftpS3Gateway sftpgo[3542]: {"level":"debug","time":"2024-04-26T12:27:19.091","sender":"ftpserverlib","server_id":"FTP_0","clientId":"7","line":"331 OK","message":"Sending answer"}
Apr 26 12:27:19 ftpS3Gateway sftpgo[3542]: {"level":"debug","time":"2024-04-26T12:27:19.208","sender":"ftpserverlib","server_id":"FTP_0","clientId":"7","line":"PASS ****","message":"Received line"}
Apr 26 12:27:19 ftpS3Gateway sftpgo[3542]: {"level":"debug","time":"2024-04-26T12:27:19.209","sender":"common","connection_id":"FTP_0_7","message":"connection swapped, close fs error: <nil>"}
Apr 26 12:27:19 ftpS3Gateway sftpgo[3542]: {"level":"info","time":"2024-04-26T12:27:19.209","sender":"FTP","connection_id":"FTP_0_7","message":"User \"wildspotter\" logged in with \"password\" from ip \"*****\""}
Apr 26 12:27:19 ftpS3Gateway sftpgo[3542]: {"level":"debug","time":"2024-04-26T12:27:19.210","sender":"ftpserverlib","server_id":"FTP_0","clientId":"7","line":"230 Password ok, continue","message":"Sending answer"}
Apr 26 12:27:19 ftpS3Gateway sftpgo[3542]: {"level":"debug","time":"2024-04-26T12:27:19.344","sender":"ftpserverlib","server_id":"FTP_0","clientId":"7","line":"PWD","message":"Received line"}
Apr 26 12:27:19 ftpS3Gateway sftpgo[3542]: {"level":"debug","time":"2024-04-26T12:27:19.345","sender":"ftpserverlib","server_id":"FTP_0","clientId":"7","line":"257 \"/\" is the current directory","message":"Sending answer"}
Apr 26 12:27:19 ftpS3Gateway sftpgo[3542]: {"level":"debug","time":"2024-04-26T12:27:19.480","sender":"ftpserverlib","server_id":"FTP_0","clientId":"7","line":"CWD wildspotter","message":"Received line"}
Apr 26 12:27:19 ftpS3Gateway sftpgo[3542]: {"level":"debug","time":"2024-04-26T12:27:19.579","sender":"ftpserverlib","server_id":"FTP_0","clientId":"7","line":"250 CD worked on /wildspotter","message":"Sending answer"}
Apr 26 12:27:19 ftpS3Gateway sftpgo[3542]: {"level":"debug","time":"2024-04-26T12:27:19.708","sender":"ftpserverlib","server_id":"FTP_0","clientId":"7","line":"CWD 2024","message":"Received line"}
Apr 26 12:27:19 ftpS3Gateway sftpgo[3542]: {"level":"debug","time":"2024-04-26T12:27:19.755","sender":"ftpserverlib","server_id":"FTP_0","clientId":"7","line":"250 CD worked on /wildspotter/2024","message":"Sending answer"}
Apr 26 12:27:19 ftpS3Gateway sftpgo[3542]: {"level":"debug","time":"2024-04-26T12:27:19.887","sender":"ftpserverlib","server_id":"FTP_0","clientId":"7","line":"CWD 04","message":"Received line"}
Apr 26 12:27:19 ftpS3Gateway sftpgo[3542]: {"level":"debug","time":"2024-04-26T12:27:19.934","sender":"ftpserverlib","server_id":"FTP_0","clientId":"7","line":"250 CD worked on /wildspotter/2024/04","message":"Sending answer"}
Apr 26 12:27:20 ftpS3Gateway sftpgo[3542]: {"level":"debug","time":"2024-04-26T12:27:20.071","sender":"ftpserverlib","server_id":"FTP_0","clientId":"7","line":"CWD 26","message":"Received line"}
Apr 26 12:27:20 ftpS3Gateway sftpgo[3542]: {"level":"debug","time":"2024-04-26T12:27:20.142","sender":"ftpserverlib","server_id":"FTP_0","clientId":"7","line":"250 CD worked on /wildspotter/2024/04/26","message":"Sending answer"}
Apr 26 12:27:20 ftpS3Gateway sftpgo[3542]: {"level":"debug","time":"2024-04-26T12:27:20.271","sender":"ftpserverlib","server_id":"FTP_0","clientId":"7","line":"TYPE A","message":"Received line"}
Apr 26 12:27:20 ftpS3Gateway sftpgo[3542]: {"level":"debug","time":"2024-04-26T12:27:20.272","sender":"ftpserverlib","server_id":"FTP_0","clientId":"7","line":"200 Type set to ASCII","message":"Sending answer"}
Apr 26 12:27:20 ftpS3Gateway sftpgo[3542]: {"level":"debug","time":"2024-04-26T12:27:20.414","sender":"ftpserverlib","server_id":"FTP_0","clientId":"7","line":"MODE S","message":"Received line"}
Apr 26 12:27:20 ftpS3Gateway sftpgo[3542]: {"level":"warn","time":"2024-04-26T12:27:20.414","sender":"ftpserverlib","server_id":"FTP_0","clientId":"7","command":"MODE","message":"Unknown command"}
Apr 26 12:27:20 ftpS3Gateway sftpgo[3542]: {"level":"debug","time":"2024-04-26T12:27:20.415","sender":"ftpserverlib","server_id":"FTP_0","clientId":"7","line":"500 Unknown command \"MODE\"","message":"Sending answer"}
Apr 26 12:27:20 ftpS3Gateway sftpgo[3542]: {"level":"debug","time":"2024-04-26T12:27:20.547","sender":"ftpserverlib","server_id":"FTP_0","clientId":"7","clean":"false","message":"Client disconnected"}

@tfranssen
Copy link
Author

Maybe just accepting MODE S would be enough for this. I will try to make the changes myself.

@fclairamb
Copy link
Owner

Deflate compression is part of the standard library so that should be fairly easy to support.

fclairamb added a commit that referenced this issue Jun 2, 2024
We're not handling deflate mode though.

To address #451
fclairamb added a commit that referenced this issue Jun 2, 2024
We're only accepting the "Stream" mode though. But at least it's official.

This addresses #451.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants