From 84e20ac39aa0407bbc6a5a17523d7be3678bb251 Mon Sep 17 00:00:00 2001 From: fvanroie <15969459+fvanroie@users.noreply.github.com> Date: Sun, 6 Feb 2022 18:18:12 +0100 Subject: [PATCH] No credential size limit and anonymous login --- lib/SimpleFTPServer/FtpServer.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/SimpleFTPServer/FtpServer.cpp b/lib/SimpleFTPServer/FtpServer.cpp index 7aee1029..4ad53c04 100644 --- a/lib/SimpleFTPServer/FtpServer.cpp +++ b/lib/SimpleFTPServer/FtpServer.cpp @@ -70,9 +70,9 @@ void FtpServer::end() ftpServer.end(); dataServer.end(); - cmdStage = FTP_Stop; + cmdStage = FTP_Init; transferStage = FTP_Close; - dataConn = FTP_NoConn; + dataConn = FTP_NoConn; } void FtpServer::begin(const char* _user, const char* _pass, const char* _welcomeMessage) @@ -118,12 +118,16 @@ void FtpServer::begin(const char* _user, const char* _pass, const char* _welcome void FtpServer::credentials(const char* _user, const char* _pass) { + this->user = user; + this->pass = _pass; + + /* if(strlen(_user) > 0 && strlen(_user) < FTP_CRED_SIZE) // strcpy( user, _user ); this->user = user; if(strlen(_pass) > 0 && strlen(_pass) < FTP_CRED_SIZE) // strcpy( pass, _pass ); - this->pass = _pass; + this->pass = _pass; */ } void FtpServer::iniVariables() @@ -313,10 +317,14 @@ bool FtpServer::processCommand() if(cmdStage != FTP_Pass) { client.println(F("503 ")); cmdStage = FTP_Stop; - } - if(!strcmp(parameter, pass)) { + } else if(!strcmp(parameter, pass)) { DEBUG_PRINTLN(F(" Authentication Ok. Waiting for commands.")); + client.println(F("230 Ok")); + cmdStage = FTP_Cmd; + } else if(!strcmp("anonymous", user)) { + DEBUG_PRINTLN(F(" Anonymous login. Waiting for commands.")); + client.println(F("230 Ok")); cmdStage = FTP_Cmd; } else {