mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-28 13:46:36 +00:00
Workaround for PASV with FTP started early
This commit is contained in:
parent
5052186e4a
commit
152d366822
@ -474,8 +474,7 @@ bool FtpServer::processCommand()
|
|||||||
//
|
//
|
||||||
// PORT - Data Port
|
// PORT - Data Port
|
||||||
//
|
//
|
||||||
else if(CommandIs("PORT"))
|
else if(CommandIs("PORT")) {
|
||||||
{
|
|
||||||
data.stop();
|
data.stop();
|
||||||
// get IP of data client
|
// get IP of data client
|
||||||
dataIp[0] = atoi(parameter);
|
dataIp[0] = atoi(parameter);
|
||||||
@ -509,8 +508,7 @@ else if(CommandIs("PORT"))
|
|||||||
//
|
//
|
||||||
// STRU - File Structure
|
// STRU - File Structure
|
||||||
//
|
//
|
||||||
else if(CommandIs("STRU"))
|
else if(CommandIs("STRU")) {
|
||||||
{
|
|
||||||
if(ParameterIs("F")) {
|
if(ParameterIs("F")) {
|
||||||
client.println(F("200 F Ok"));
|
client.println(F("200 F Ok"));
|
||||||
// else if( ParameterIs( "R" ))
|
// else if( ParameterIs( "R" ))
|
||||||
@ -522,8 +520,7 @@ else if(CommandIs("STRU"))
|
|||||||
//
|
//
|
||||||
// TYPE - Data Type
|
// TYPE - Data Type
|
||||||
//
|
//
|
||||||
else if(CommandIs("TYPE"))
|
else if(CommandIs("TYPE")) {
|
||||||
{
|
|
||||||
if(ParameterIs("A")) {
|
if(ParameterIs("A")) {
|
||||||
client.println(F("200 TYPE is now ASCII"));
|
client.println(F("200 TYPE is now ASCII"));
|
||||||
} else if(ParameterIs("I")) {
|
} else if(ParameterIs("I")) {
|
||||||
@ -542,16 +539,14 @@ else if(CommandIs("TYPE"))
|
|||||||
//
|
//
|
||||||
// ABOR - Abort
|
// ABOR - Abort
|
||||||
//
|
//
|
||||||
else if(CommandIs("ABOR"))
|
else if(CommandIs("ABOR")) {
|
||||||
{
|
|
||||||
abortTransfer();
|
abortTransfer();
|
||||||
client.println(F("226 Data connection closed"));
|
client.println(F("226 Data connection closed"));
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// DELE - Delete a File
|
// DELE - Delete a File
|
||||||
//
|
//
|
||||||
else if(CommandIs("DELE"))
|
else if(CommandIs("DELE")) {
|
||||||
{
|
|
||||||
char path[FTP_CWD_SIZE];
|
char path[FTP_CWD_SIZE];
|
||||||
if(haveParameter() && makeExistsPath(path)) {
|
if(haveParameter() && makeExistsPath(path)) {
|
||||||
if(remove(path)) {
|
if(remove(path)) {
|
||||||
@ -572,8 +567,7 @@ else if(CommandIs("DELE"))
|
|||||||
// NLST - Name List
|
// NLST - Name List
|
||||||
// MLSD - Listing for Machine Processing (see RFC 3659)
|
// MLSD - Listing for Machine Processing (see RFC 3659)
|
||||||
//
|
//
|
||||||
else if(CommandIs("LIST") || CommandIs("NLST") || CommandIs("MLSD"))
|
else if(CommandIs("LIST") || CommandIs("NLST") || CommandIs("MLSD")) {
|
||||||
{
|
|
||||||
DEBUG_PRINT("List of file!!");
|
DEBUG_PRINT("List of file!!");
|
||||||
|
|
||||||
if(dataConnect()) {
|
if(dataConnect()) {
|
||||||
@ -596,8 +590,7 @@ else if(CommandIs("LIST") || CommandIs("NLST") || CommandIs("MLSD"))
|
|||||||
//
|
//
|
||||||
// MLST - Listing for Machine Processing (see RFC 3659)
|
// MLST - Listing for Machine Processing (see RFC 3659)
|
||||||
//
|
//
|
||||||
else if(CommandIs("MLST"))
|
else if(CommandIs("MLST")) {
|
||||||
{
|
|
||||||
char path[FTP_CWD_SIZE];
|
char path[FTP_CWD_SIZE];
|
||||||
uint16_t dat, tim;
|
uint16_t dat, tim;
|
||||||
char dtStr[15];
|
char dtStr[15];
|
||||||
@ -629,15 +622,13 @@ else if(CommandIs("MLST"))
|
|||||||
//
|
//
|
||||||
// NOOP
|
// NOOP
|
||||||
//
|
//
|
||||||
else if(CommandIs("NOOP"))
|
else if(CommandIs("NOOP")) {
|
||||||
{
|
|
||||||
client.println(F("200 Zzz..."));
|
client.println(F("200 Zzz..."));
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// RETR - Retrieve
|
// RETR - Retrieve
|
||||||
//
|
//
|
||||||
else if(CommandIs("RETR"))
|
else if(CommandIs("RETR")) {
|
||||||
{
|
|
||||||
char path[FTP_CWD_SIZE];
|
char path[FTP_CWD_SIZE];
|
||||||
if(haveParameter() && makeExistsPath(path)) {
|
if(haveParameter() && makeExistsPath(path)) {
|
||||||
if(!openFile(path, FTP_FILE_READ)) {
|
if(!openFile(path, FTP_FILE_READ)) {
|
||||||
@ -668,8 +659,7 @@ else if(CommandIs("RETR"))
|
|||||||
// STOR - Store
|
// STOR - Store
|
||||||
// APPE - Append
|
// APPE - Append
|
||||||
//
|
//
|
||||||
else if(CommandIs("STOR") || CommandIs("APPE"))
|
else if(CommandIs("STOR") || CommandIs("APPE")) {
|
||||||
{
|
|
||||||
char path[FTP_CWD_SIZE];
|
char path[FTP_CWD_SIZE];
|
||||||
if(haveParameter() && makePath(path)) {
|
if(haveParameter() && makePath(path)) {
|
||||||
bool open;
|
bool open;
|
||||||
@ -710,8 +700,7 @@ else if(CommandIs("STOR") || CommandIs("APPE"))
|
|||||||
//
|
//
|
||||||
// MKD - Make Directory
|
// MKD - Make Directory
|
||||||
//
|
//
|
||||||
else if(CommandIs("MKD"))
|
else if(CommandIs("MKD")) {
|
||||||
{
|
|
||||||
char path[FTP_CWD_SIZE];
|
char path[FTP_CWD_SIZE];
|
||||||
if(haveParameter() && makePath(path)) {
|
if(haveParameter() && makePath(path)) {
|
||||||
if(exists(path)) {
|
if(exists(path)) {
|
||||||
@ -742,8 +731,7 @@ else if(CommandIs("MKD"))
|
|||||||
//
|
//
|
||||||
// RMD - Remove a Directory
|
// RMD - Remove a Directory
|
||||||
//
|
//
|
||||||
else if(CommandIs("RMD"))
|
else if(CommandIs("RMD")) {
|
||||||
{
|
|
||||||
char path[FTP_CWD_SIZE];
|
char path[FTP_CWD_SIZE];
|
||||||
if(haveParameter() && makeExistsPath(path)) {
|
if(haveParameter() && makeExistsPath(path)) {
|
||||||
if(removeDir(path)) {
|
if(removeDir(path)) {
|
||||||
@ -763,8 +751,7 @@ else if(CommandIs("RMD"))
|
|||||||
//
|
//
|
||||||
// RNFR - Rename From
|
// RNFR - Rename From
|
||||||
//
|
//
|
||||||
else if(CommandIs("RNFR"))
|
else if(CommandIs("RNFR")) {
|
||||||
{
|
|
||||||
rnfrName[0] = 0;
|
rnfrName[0] = 0;
|
||||||
if(haveParameter() && makeExistsPath(rnfrName)) {
|
if(haveParameter() && makeExistsPath(rnfrName)) {
|
||||||
DEBUG_PRINT(F(" Ready for renaming "));
|
DEBUG_PRINT(F(" Ready for renaming "));
|
||||||
@ -777,8 +764,7 @@ else if(CommandIs("RNFR"))
|
|||||||
//
|
//
|
||||||
// RNTO - Rename To
|
// RNTO - Rename To
|
||||||
//
|
//
|
||||||
else if(CommandIs("RNTO"))
|
else if(CommandIs("RNTO")) {
|
||||||
{
|
|
||||||
char path[FTP_CWD_SIZE];
|
char path[FTP_CWD_SIZE];
|
||||||
char dirp[FTP_FIL_SIZE];
|
char dirp[FTP_FIL_SIZE];
|
||||||
if(strlen(rnfrName) == 0 || !rnfrCmd) {
|
if(strlen(rnfrName) == 0 || !rnfrCmd) {
|
||||||
@ -834,8 +820,7 @@ else if( CommandIs( "SYST" ))
|
|||||||
//
|
//
|
||||||
// MDTM && MFMT - File Modification Time (see RFC 3659)
|
// MDTM && MFMT - File Modification Time (see RFC 3659)
|
||||||
//
|
//
|
||||||
else if(CommandIs("MDTM") || CommandIs("MFMT"))
|
else if(CommandIs("MDTM") || CommandIs("MFMT")) {
|
||||||
{
|
|
||||||
if(haveParameter()) {
|
if(haveParameter()) {
|
||||||
char path[FTP_CWD_SIZE];
|
char path[FTP_CWD_SIZE];
|
||||||
char* fname = parameter;
|
char* fname = parameter;
|
||||||
@ -875,8 +860,7 @@ else if(CommandIs("MDTM") || CommandIs("MFMT"))
|
|||||||
//
|
//
|
||||||
// SIZE - Size of the file
|
// SIZE - Size of the file
|
||||||
//
|
//
|
||||||
else if(CommandIs("SIZE"))
|
else if(CommandIs("SIZE")) {
|
||||||
{
|
|
||||||
char path[FTP_CWD_SIZE];
|
char path[FTP_CWD_SIZE];
|
||||||
if(haveParameter() && makeExistsPath(path)) {
|
if(haveParameter() && makeExistsPath(path)) {
|
||||||
if(!openFile(path, FTP_FILE_READ)) {
|
if(!openFile(path, FTP_FILE_READ)) {
|
||||||
@ -892,8 +876,7 @@ else if(CommandIs("SIZE"))
|
|||||||
//
|
//
|
||||||
// SITE - System command
|
// SITE - System command
|
||||||
//
|
//
|
||||||
else if(CommandIs("SITE"))
|
else if(CommandIs("SITE")) {
|
||||||
{
|
|
||||||
if(ParameterIs("FREE")) {
|
if(ParameterIs("FREE")) {
|
||||||
uint32_t capa = capacity();
|
uint32_t capa = capacity();
|
||||||
if((capa >> 10) < 1000) { // less than 1 Giga
|
if((capa >> 10) < 1000) { // less than 1 Giga
|
||||||
@ -917,7 +900,8 @@ else if(CommandIs("SITE"))
|
|||||||
//
|
//
|
||||||
// Unrecognized commands ...
|
// Unrecognized commands ...
|
||||||
//
|
//
|
||||||
else client.println(F("500 Unknow command"));
|
else
|
||||||
|
client.println(F("500 Unknow command"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user