veeso / suppaftp

a super FTP/FTPS client library for Rust with support for both passive and active mode
Apache License 2.0
112 stars 28 forks source link

[BUG] - LIST command executed timeout. #81

Closed lsk569937453 closed 4 months ago

lsk569937453 commented 4 months ago

Description

I install the suppaftp-cli by the following command.And I try to connect with the ftp server.And I could execute the MLST command,but the LIST command executed timeout.

cargo install suppaftp-cli

Environment

Additional information

PS D:\code\github\rcurl> suppaftp localhost:2121
Failed to set transfer type to binary: Invalid response: [530] 530 Please login with USER and PASS
OK
>> LOGIN
Username:

Password:

OK
>> MLST
Type=dir;Size=4096;Modify=20240520123245; tmp
>> LIST
LIST error: Connection error: The connection attempt failed because the connecting party did not reply properly after a period of time or the connected host was unresponsive 。 (os error 10060)

Add any other context about the problem here.

veeso commented 4 months ago

Please run with -D to enable debug.

Anyway the test unit for LIST passes and it works with other servers such as test.rebex.net:21, so it probably is an issue with the PASSIVE mode on that ftp server not being accepted

lsk569937453 commented 4 months ago
suppaftp localhost:2121 -D
[2024-05-20T21:34:32Z DEBUG suppaftp::sync_ftp] Connecting to server
[2024-05-20T21:34:32Z DEBUG suppaftp::sync_ftp] Established connection with server
[2024-05-20T21:34:32Z DEBUG suppaftp::sync_ftp] Reading server response...
[2024-05-20T21:34:32Z TRACE suppaftp::sync_ftp] CC IN: [50, 50, 48, 32, 102, 116, 112, 115, 101, 114, 118, 101, 114, 13, 10]
[2024-05-20T21:34:32Z TRACE suppaftp::sync_ftp] Code parsed from response: service ready for new user (220)
[2024-05-20T21:34:32Z TRACE suppaftp::sync_ftp] CC IN: [50, 50, 48, 32, 102, 116, 112, 115, 101, 114, 118, 101, 114, 13, 10]
[2024-05-20T21:34:32Z DEBUG suppaftp::sync_ftp] Server READY; response: Some("220 ftpserver")
[2024-05-20T21:34:32Z DEBUG suppaftp::sync_ftp] Setting transfer type I
[2024-05-20T21:34:32Z TRACE suppaftp::sync_ftp] CC OUT: TYPE I
[2024-05-20T21:34:32Z TRACE suppaftp::sync_ftp] CC IN: [53, 51, 48, 32, 80, 108, 101, 97, 115, 101, 32, 108, 111, 103, 105, 110, 32, 119, 105, 116, 104, 32, 85, 83, 69, 82, 32, 97, 110, 100, 32, 80, 65, 83, 83, 13, 10]
[2024-05-20T21:34:32Z TRACE suppaftp::sync_ftp] Code parsed from response: user not logged in (530)
[2024-05-20T21:34:32Z TRACE suppaftp::sync_ftp] CC IN: [53, 51, 48, 32, 80, 108, 101, 97, 115, 101, 32, 108, 111, 103, 105, 110, 32, 119, 105, 116, 104, 32, 85, 83, 69, 82, 32, 97, 110, 100, 32, 80, 65, 83, 83, 13, 10]
Failed to set transfer type to binary: Invalid response: [530] 530 Please login with USER and PASS
OK
>> LOGIN
Username:

Password:

[2024-05-20T21:34:41Z DEBUG suppaftp::sync_ftp] Signin in with user 'test'
[2024-05-20T21:34:41Z TRACE suppaftp::sync_ftp] CC OUT: USER test
[2024-05-20T21:34:41Z TRACE suppaftp::sync_ftp] CC IN: [51, 51, 49, 32, 79, 75, 13, 10]
[2024-05-20T21:34:41Z TRACE suppaftp::sync_ftp] Code parsed from response: user name okay, need password (331)
[2024-05-20T21:34:41Z TRACE suppaftp::sync_ftp] CC IN: [51, 51, 49, 32, 79, 75, 13, 10]
[2024-05-20T21:34:41Z DEBUG suppaftp::sync_ftp] Password is required
[2024-05-20T21:34:41Z TRACE suppaftp::sync_ftp] CC OUT: PASS test
[2024-05-20T21:34:41Z TRACE suppaftp::sync_ftp] CC IN: [50, 51, 48, 32, 80, 97, 115, 115, 119, 111, 114, 100, 32, 111, 107, 44, 32, 99, 111, 110, 116, 105, 110, 117, 101, 13, 10]
[2024-05-20T21:34:41Z TRACE suppaftp::sync_ftp] Code parsed from response: user logged in, proceed. Logged out if appropriate. (230)
[2024-05-20T21:34:41Z TRACE suppaftp::sync_ftp] CC IN: [50, 51, 48, 32, 80, 97, 115, 115, 119, 111, 114, 100, 32, 111, 107, 44, 32, 99, 111, 110, 116, 105, 110, 117, 101, 13, 10]
[2024-05-20T21:34:41Z DEBUG suppaftp::sync_ftp] Login OK
OK
>> MLST
[2024-05-20T21:35:07Z DEBUG suppaftp::sync_ftp] Reading working path information
[2024-05-20T21:35:07Z TRACE suppaftp::sync_ftp] CC OUT: MLST
[2024-05-20T21:35:07Z TRACE suppaftp::sync_ftp] CC IN: [50, 53, 48, 45, 70, 105, 108, 101, 32, 100, 101, 116, 97, 105, 108, 115, 13, 10]
[2024-05-20T21:35:07Z TRACE suppaftp::sync_ftp] Code parsed from response: requested file action okay (250)
[2024-05-20T21:35:07Z TRACE suppaftp::sync_ftp] CC IN: [50, 53, 48, 45, 70, 105, 108, 101, 32, 100, 101, 116, 97, 105, 108, 115, 13, 10]
[2024-05-20T21:35:07Z TRACE suppaftp::sync_ftp] CC IN: [32, 84, 121, 112, 101, 61, 100, 105, 114, 59, 83, 105, 122, 101, 61, 52, 48, 57, 54, 59, 77, 111, 100, 105, 102, 121, 61, 50, 48, 50, 52, 48, 53, 50, 48, 49, 50, 51, 50, 52, 53, 59, 32, 116, 109, 112, 13, 10]
[2024-05-20T21:35:07Z TRACE suppaftp::sync_ftp] CC IN: [50, 53, 48, 32, 69, 110, 100, 13, 10]
Type=dir;Size=4096;Modify=20240520123245; tmp
>> LIST
[2024-05-20T21:35:11Z DEBUG suppaftp::sync_ftp] Reading working directory content
[2024-05-20T21:35:11Z DEBUG suppaftp::sync_ftp] PASV command
[2024-05-20T21:35:11Z TRACE suppaftp::sync_ftp] CC OUT: PASV
[2024-05-20T21:35:11Z TRACE suppaftp::sync_ftp] CC IN: [50, 50, 55, 32, 69, 110, 116, 101, 114, 105, 110, 103, 32, 80, 97, 115, 115, 105, 118, 101, 32, 77, 111, 100, 101, 32, 40, 49, 55, 50, 44, 50, 48, 44, 48, 44, 53, 44, 56, 44, 56, 50, 41, 13, 10]
[2024-05-20T21:35:11Z TRACE suppaftp::sync_ftp] Code parsed from response: entering passive mode (227)
[2024-05-20T21:35:11Z TRACE suppaftp::sync_ftp] CC IN: [50, 50, 55, 32, 69, 110, 116, 101, 114, 105, 110, 103, 32, 80, 97, 115, 115, 105, 118, 101, 32, 77, 111, 100, 101, 32, 40, 49, 55, 50, 44, 50, 48, 44, 48, 44, 53, 44, 56, 44, 56, 50, 41, 13, 10]
[2024-05-20T21:35:11Z TRACE suppaftp::sync_ftp] Passive address: 172.20.0.5:2130
[2024-05-20T21:35:11Z TRACE suppaftp::sync_ftp] CC OUT: LIST
LIST error: Connection error: The connection attempt failed because the connecting party did not reply properly after a period of time or the connected host was unresponsive 。 (os error 10060)

When I use the -D,it shows above info.How could I handle this error?

lsk569937453 commented 4 months ago

I have found the error.I use the following docker-compose.xml

  ftp:
    image: wildscamp/vsftpd
    volumes:
      - ./remote:/home/virtual/ftp/remote
    environment:
      PASV_ADDRESS: 127.0.0.1
      VSFTPD_USER_1: "ftp:pass:1001:"
      PASV_MIN_PORT: 30100
      PASV_MAX_PORT: 30109
    ports:
      - "10210:21"
      - "30100-30109:30100-30109"

And I have forgot to config the PASV_ADDRESS.After I have configed the PASV_ADDRESS,everything goes well.