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

Adding MODE command support #460

Merged
merged 2 commits into from
Jun 2, 2024
Merged

Adding MODE command support #460

merged 2 commits into from
Jun 2, 2024

Conversation

fclairamb
Copy link
Owner

@fclairamb fclairamb commented Jun 2, 2024

We're only accepting the "Stream" mode though. But at least it's official.

To address #451

We're not handling deflate mode though.

To address #451
Copy link

codecov bot commented Jun 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.73%. Comparing base (d2b3c25) to head (3880fc0).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #460      +/-   ##
==========================================
+ Coverage   86.68%   86.73%   +0.04%     
==========================================
  Files          11       11              
  Lines        1720     1726       +6     
==========================================
+ Hits         1491     1497       +6     
  Misses        155      155              
  Partials       74       74              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fclairamb fclairamb changed the title Adding MODE support Adding MODE command support Jun 2, 2024
@fclairamb fclairamb enabled auto-merge (squash) June 2, 2024 19:42
@fclairamb fclairamb merged commit 117fcb6 into main Jun 2, 2024
5 checks passed
@fclairamb fclairamb deleted the feat/mode-support branch June 2, 2024 19:43
@drakkan
Copy link
Collaborator

drakkan commented Jun 2, 2024

@fclairamb thank you. I also had this change locally

rom 06190249a0885db147cc63dba04d292e8043c181 Mon Sep 17 00:00:00 2001
From: Nicola Murino <[email protected]>
Date: Tue, 30 Apr 2024 19:19:08 +0200
Subject: [PATCH] add support for MODE type

---
 handle_misc.go | 13 +++++++++++++
 server.go      |  1 +
 2 files changed, 14 insertions(+)

diff --git a/handle_misc.go b/handle_misc.go
index 097b3014..a5a3dee4 100644
--- a/handle_misc.go
+++ b/handle_misc.go
@@ -284,6 +284,19 @@ func (c *clientHandler) handleTYPE(param string) error {
 	return nil
 }
 
+func (c *clientHandler) handleMODE(param string) error {
+	param = strings.ToUpper(param)
+	switch param {
+	case "S":
+		c.writeMessage(StatusOK, "Transfer mode set to 'S'")
+	case "B", "C", "Z":
+		c.writeMessage(StatusNotImplementedParam, "Unimplemented MODE type")
+	default:
+		c.writeMessage(StatusSyntaxErrorParameters, "Unrecognized MODE type")
+	}
+	return nil
+}
+
 func (c *clientHandler) handleQUIT(_ string) error {
 	c.transferWg.Wait()
 
diff --git a/server.go b/server.go
index 0c0c2612..25f0dd23 100644
--- a/server.go
+++ b/server.go
@@ -91,6 +91,7 @@ var commandsMap = map[string]*CommandDescription{ //nolint:gochecknoglobals
 	"EPSV": {Fn: (*clientHandler).handlePASV},
 	"PORT": {Fn: (*clientHandler).handlePORT},
 	"EPRT": {Fn: (*clientHandler).handlePORT},
+	"MODE": {Fn: (*clientHandler).handleMODE},
 }
 
 var specialAttentionCommands = []string{"ABOR", "STAT", "QUIT"} //nolint:gochecknoglobals

But I never wrote a test case and then forgot about it, sorry

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

Successfully merging this pull request may close these issues.

None yet

2 participants