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

Returning 502 on REIN #473

Merged
merged 6 commits into from
Sep 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
6 changes: 6 additions & 0 deletions handle_misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,3 +374,9 @@ func (c *clientHandler) handleAVBL(param string) error {

return nil
}

func (c *clientHandler) handleNotImplemented(_ string) error {
c.writeMessage(StatusCommandNotImplemented, "This command hasn't been implemented !")

return nil
}
20 changes: 20 additions & 0 deletions handle_misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,3 +442,23 @@ func TestMode(t *testing.T) {
require.NoError(t, err)
require.Equal(t, StatusNotImplementedParam, returnCode)
}

func TestREIN(t *testing.T) {
server := NewTestServer(t, false)
conf := goftp.Config{
User: authUser,
Password: authPass,
}

client, err := goftp.DialConfig(conf, server.Addr())
require.NoError(t, err, "Couldn't connect")

defer func() { panicOnError(client.Close()) }()

raw, err := client.OpenRawConn()
require.NoError(t, err, "Couldn't open raw connection")

returnCode, _, err := raw.SendCommand("REIN")
require.NoError(t, err)
require.Equal(t, StatusCommandNotImplemented, returnCode)
}
27 changes: 27 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,17 @@ var commandsMap = map[string]*CommandDescription{ //nolint:gochecknoglobals
// Authentication
"USER": {Fn: (*clientHandler).handleUSER, Open: true},
"PASS": {Fn: (*clientHandler).handlePASS, Open: true},
"ACCT": {Fn: (*clientHandler).handleNotImplemented},
"ADAT": {Fn: (*clientHandler).handleNotImplemented},

// TLS handling
"AUTH": {Fn: (*clientHandler).handleAUTH, Open: true},
"PROT": {Fn: (*clientHandler).handlePROT, Open: true},
"PBSZ": {Fn: (*clientHandler).handlePBSZ, Open: true},
"CCC": {Fn: (*clientHandler).handleNotImplemented},
"CONF": {Fn: (*clientHandler).handleNotImplemented},
"ENC": {Fn: (*clientHandler).handleNotImplemented},
"MIC": {Fn: (*clientHandler).handleNotImplemented},

// Misc
"CLNT": {Fn: (*clientHandler).handleCLNT, Open: true},
Expand All @@ -45,14 +51,26 @@ var commandsMap = map[string]*CommandDescription{ //nolint:gochecknoglobals
"QUIT": {Fn: (*clientHandler).handleQUIT, Open: true, SpecialAction: true},
"AVBL": {Fn: (*clientHandler).handleAVBL},
"ABOR": {Fn: (*clientHandler).handleABOR, SpecialAction: true},
"CSID": {Fn: (*clientHandler).handleNotImplemented},
"HELP": {Fn: (*clientHandler).handleNotImplemented},
"HOST": {Fn: (*clientHandler).handleNotImplemented},
"LANG": {Fn: (*clientHandler).handleNotImplemented},
"XRSQ": {Fn: (*clientHandler).handleNotImplemented},
"XSEM": {Fn: (*clientHandler).handleNotImplemented},
"XSEN": {Fn: (*clientHandler).handleNotImplemented},

// File access
"SIZE": {Fn: (*clientHandler).handleSIZE},
"DSIZ": {Fn: (*clientHandler).handleNotImplemented},
"STAT": {Fn: (*clientHandler).handleSTAT, SpecialAction: true},
"MDTM": {Fn: (*clientHandler).handleMDTM},
"MFMT": {Fn: (*clientHandler).handleMFMT},
"MFF": {Fn: (*clientHandler).handleNotImplemented},
"MFCT": {Fn: (*clientHandler).handleNotImplemented},
"RETR": {Fn: (*clientHandler).handleRETR, TransferRelated: true},
"STOR": {Fn: (*clientHandler).handleSTOR, TransferRelated: true},
"STOU": {Fn: (*clientHandler).handleNotImplemented},
"STRU": {Fn: (*clientHandler).handleNotImplemented},
"APPE": {Fn: (*clientHandler).handleAPPE, TransferRelated: true},
"DELE": {Fn: (*clientHandler).handleDELE},
"RNFR": {Fn: (*clientHandler).handleRNFR},
Expand All @@ -69,6 +87,8 @@ var commandsMap = map[string]*CommandDescription{ //nolint:gochecknoglobals
"XSHA256": {Fn: (*clientHandler).handleSHA256},
"XSHA512": {Fn: (*clientHandler).handleSHA512},
"COMB": {Fn: (*clientHandler).handleCOMB},
"THMB": {Fn: (*clientHandler).handleNotImplemented},
"XRCP": {Fn: (*clientHandler).handleNotImplemented},

// Directory handling
"CWD": {Fn: (*clientHandler).handleCWD},
Expand All @@ -82,16 +102,23 @@ var commandsMap = map[string]*CommandDescription{ //nolint:gochecknoglobals
"MLST": {Fn: (*clientHandler).handleMLST},
"MKD": {Fn: (*clientHandler).handleMKD},
"RMD": {Fn: (*clientHandler).handleRMD},
"RMDA": {Fn: (*clientHandler).handleNotImplemented},
"XMKD": {Fn: (*clientHandler).handleMKD},
"XRMD": {Fn: (*clientHandler).handleRMD},
"SMNT": {Fn: (*clientHandler).handleNotImplemented},
"XCUP": {Fn: (*clientHandler).handleNotImplemented},

// Connection handling
"TYPE": {Fn: (*clientHandler).handleTYPE},
"MODE": {Fn: (*clientHandler).handleMODE},
"PASV": {Fn: (*clientHandler).handlePASV},
"EPSV": {Fn: (*clientHandler).handlePASV},
"LPSV": {Fn: (*clientHandler).handleNotImplemented},
"SPSV": {Fn: (*clientHandler).handleNotImplemented},
"PORT": {Fn: (*clientHandler).handlePORT},
"LRPT": {Fn: (*clientHandler).handleNotImplemented},
"EPRT": {Fn: (*clientHandler).handlePORT},
"REIN": {Fn: (*clientHandler).handleNotImplemented},
}

var specialAttentionCommands = []string{"ABOR", "STAT", "QUIT"} //nolint:gochecknoglobals
Expand Down
Loading