Process the next FTP command
| 444 | |
| 445 | // Process the next FTP command |
| 446 | void FtpResponder::ProcessLine() noexcept |
| 447 | { |
| 448 | if (reprap.Debug(Module::Webserver)) |
| 449 | { |
| 450 | debugPrintf("FTP request '%s' (state %d)\n", clientMessage, (int)responderState); |
| 451 | } |
| 452 | |
| 453 | haveCompleteLine = false; |
| 454 | clientPointer = 0; |
| 455 | |
| 456 | switch (responderState) |
| 457 | { |
| 458 | case ResponderState::authenticating: |
| 459 | haveFileToMove = false; |
| 460 | filenameBeingProcessed.Clear(); |
| 461 | |
| 462 | // don't check the user name |
| 463 | if (StringStartsWith(clientMessage, "USER")) |
| 464 | { |
| 465 | outBuf->copy("331 Please specify the password.\r\n"); |
| 466 | Commit(ResponderState::authenticating); |
| 467 | } |
| 468 | // but check the password (if set) |
| 469 | else if (StringStartsWith(clientMessage, "PASS")) |
| 470 | { |
| 471 | const char *_ecv_array const password = GetParameter("PASS"); |
| 472 | if (reprap.NoPasswordSet() || reprap.CheckPassword(password)) |
| 473 | { |
| 474 | currentDirectory.copy("/"); |
| 475 | |
| 476 | outBuf->copy("230 Login successful.\r\n"); |
| 477 | Commit(ResponderState::reading); |
| 478 | } |
| 479 | else |
| 480 | { |
| 481 | outBuf->copy("530 Login incorrect.\r\n"); |
| 482 | Commit(); |
| 483 | } |
| 484 | } |
| 485 | // end connection |
| 486 | else if (StringEqualsIgnoreCase(clientMessage, "QUIT")) |
| 487 | { |
| 488 | outBuf->copy("221 Goodbye.\r\n"); |
| 489 | Commit(); |
| 490 | } |
| 491 | // if it's different, send response 500 to indicate we don't know the code (might be AUTH or so) |
| 492 | else |
| 493 | { |
| 494 | outBuf->copy("500 Unknown login command.\r\n"); |
| 495 | Commit(ResponderState::authenticating); |
| 496 | } |
| 497 | break; |
| 498 | |
| 499 | case ResponderState::reading: |
| 500 | // get system type |
| 501 | if (StringEqualsIgnoreCase(clientMessage, "SYST")) |
| 502 | { |
| 503 | outBuf->copy("215 UNIX Type: L8\r\n"); |
nothing calls this directly
no test coverage detected