In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to analyze the source code of FileZilla. The content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.
FileZilla is a fast and reliable FTP client and server-side open source program with a variety of features and intuitive interfaces. Analyze the source code of FileZilla for everyone.
Before further analyzing the code, review the FTP protocol. The following figure is the structure diagram of FTP.
Figure 1
The client and server communicate through two connections:
One is to control the connection, that is, to transmit some control commands, the client issues FTP commands, and the server gives responses, such as USER,PASS commands and so on. In this connection, the port of the FTP server is the well-known port 21, and the connection is initiated by the client, such as ftp 192.168.0.1. It is noted that the user operates through the "user interface". The general user interface refers to the FTP clients such as cuteFTP, or command-line programs such as ftp.exe. Users use ftp commands in the user interface, such as ls, get, cd, etc., these ftp commands are not really commands that interact with the FTP server, and these ftp commands need to be translated by the "user protocol interpreter" into real ftp protocol commands, such as USER, PASS. To interact with the server.
One is the data connection, that is, the real file transfer takes place on this connection. The data connection port on the server side is 20, and the data connection port on the client side is randomly generated. The data connection only exists when the file is transferred, and after the file is transferred, the connection is broken, and if you need to transfer the file again, a data connection will be established again (the client port is random, not necessarily the last one). There are two modes of data connection, one is active, the other is passive. The difference between the two lies in who initiated the data connection.
Let's look at a typical FTP interaction process, using windows's ftp.exe program, first establish a connection, then ls take a look at the file list, download a file with the get command, and * * quit close. The following-d option shows the details of the interaction. Note-- > the line at the beginning of the line is a request from the ftp client to the FTP server, and the line starting with three numbers is the reply from the server, such as the line at the beginning of 220331:
C:\ > ftp-d localhost
Connected to dell.
220-FileZilla Server version 0.9.18 beta
220-written by Tim Kosse (Tim.Kosse@gmx.de)
220 Please visit http://sourceforge.net/projects/filezilla/
User (dell: (none)): robert
-- > USER robert
331 Password required for robert
Password:
-- > PASS test
230 Logged on
Ftp > ls
-> PORT 127pr 0pr 0pr 1pr 4173
200 Port command successful
-- > NLST
150 Opening data channel for directory list.
Manual.txt
226 Transfer OK
Ftp: received 175Bytes and used 0.00Seconds 175000.00Kbytes/sec.
Ftp > get Manual.txt
-> PORT 127pm 0pr 0pr 1pje 4174
200 Port command successful
-- > RETR Manual.txt
150 Opening data channel for file transfer.
226 Transfer OK
Ftp: received 17319 bytes and used 0.09Seconds 192.43Kbytes/sec.
Ftp > quit
-- > QUIT
221 Goodbye
C:\ >
At first, the client sends a request to establish a connection:
C:\ > ftp-d localhost / / establish a connection
Connected to dell. / / the connection has been established
The server then sends a welcome message and asks for a user name:
220-FileZilla Server version 0.9.18 beta
220-written by Tim Kosse (Tim.Kosse@gmx.de)
220 Please visit http://sourceforge.net/projects/filezilla/
User (dell: (none)):
The client enters the user name robert, and then press enter:
-- > USER robert / / ftp.exe generate FTP command: USER, send it to the server
The server requires a password:
331 Password required for robert
Password:
The client enters the password, and then enter:
-- > PASS test / / ftp.exe generate FTP command: PASS, send it to the server
The server passed password authentication:
230 Logged on
The client typed the ls command
Ftp > ls
Ftp.exe generates the FTP command: PORT, which tells the server what the random port of the client is
-> PORT 127 zero 1197 / / 127 zero zero one is the IP address, 4 * 256 + 173 = 1197 is a random port number.
200Port command successful / / Server responds to PORT command
-> NLST / / client issues a NLST command asking for a list of files
150 Opening data channel for directory list. / / the server will establish a data connection between port 20 and port 1197 of the client to transfer data. Note that the result of the ls command is transmitted in the "data connection".
Manual.txt / / there is only one file
226 Transfer OK / / FTP server response, transmission completed
Ftp: received 175Bytes and used 0.00Seconds 175000.00Kbytes/sec. / / transfer result displayed by FTP client
The following client requires that the Manual.txt file be downloaded
Ftp > get Manual.txt
-> PORT 127 zero one 4174 / / tell the server client the new random port 4 * 256 + 174 = 1198
200Port command successful / Server responds to the PORT command
-- > RETR Manual.txt / / tell the server to download the Manual.txt file
150 Opening data channel for file transfer. / / the server will establish a data connection between port 20 and port 1198 of the client to transfer data.
226 Transfer OK / / FTP server response, transmission completed
Ftp: received 17319 bytes and used 0.09Seconds 192.43Kbytes/sec. / / transfer result displayed by FTP client
* client exits
Ftp > quit
-> QUIT / / issue the QUIT command
221 Goodbye / / server * response
If you read the above interaction carefully, you can see that a FTP command entered by the user manually may be processed by ftp.exe as multiple interactions with the FTP server. Such as ls, get command.
On how to carry out FileZilla source code analysis is shared here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.