Summary of the invention
The purpose of the embodiment of the invention is to propose a kind of request and answer method, system and terminal equipment of setting up data channel, is intended to solve in the prior art aggressive mode and only is applicable to that ftp client and FTP service end are with an enterprise network; Under the Passive Mode, the fire compartment wall of server end must be opened the FPDP of certain limit, has very big hidden danger; In addition, the concurrent number of client seriously relies on the quantity available of FPDP, and efficient is low; Speed is slow; In addition, the NAT gateway penetration problem that existing File Transfer Protocol does not provide data channel when setting up is when FTP service end Intranet IP is mapped as public network IP through the NAT gateway; The FTP service end reply to ftp client be net address in the FTP service end, cause ftp client can't set up the technical problem of data channel with the FTP service end.
The embodiment of the invention is achieved in that a kind of requesting method of setting up data channel, may further comprise the steps:
Send the passive work mode order through order control channel;
Receive and resolve the response message of said passive work mode order, and obtain monitoring IP address, listening port and this session label information of data channel;
To said monitoring IP address with listening port request set up data channel and be connected;
Write this session label information that receives, the data transfer of going forward side by side to said data channel after the successful connection.
Another purpose of the embodiment of the invention is to propose a kind of answer method of setting up data channel, may further comprise the steps:
The IP address of sending said passive work mode order is obtained in the order of reception passive work mode;
According to the IP address of sending said passive work mode order, obtain the monitoring IP address and the listening port of data channel;
Generate this session label information, and the response message that monitoring IP address, listening port and this session label information of said data channel are ordered as passive work mode feeds back;
Reply the request of setting up data channel, and set up the connection of data channel;
Obtain this session label information from said data channel, and judge whether this session label information is effective, if then carry out transfer of data.
Another purpose of the embodiment of the invention is to propose a kind of request unit of setting up data channel, and said device comprises: send command module, receive responder module, request link block and first transport module;
Said transmission command module links to each other with said reception responder module, is used for sending the passive work mode order through order control channel;
Said reception responder module links to each other with the request link block with said transmission command module, is used to receive and resolve the response message of said passive work mode order, and obtains monitoring IP address, listening port and this session label information of data channel;
The described request link block links to each other with first transport module with said reception responder module, be used for to said monitoring IP address with listening port request set up data channel and be connected;
Said first transport module links to each other with the described request link block, is used for writing this session label information that receives, the data transfer of going forward side by side to said data channel after the successful connection.
Another purpose of the embodiment of the invention is to propose a kind of answering device of setting up data channel, and said device comprises: receive command module, obtain the IP module, send responder module, reply the link block and second transport module;
Said reception command module links to each other with the said IP of obtaining module, is used to receive the passive work mode order, obtains the IP address of sending said passive work mode order;
The said IP module of obtaining links to each other with the transmission responder module with said reception command module, is used for obtaining the monitoring IP address and the listening port of data channel according to the IP address of sending said passive work mode order;
Said transmission responder module; With the said IP of obtaining module with reply link block and link to each other; Be used to generate this session label information, and the response message that monitoring IP address, listening port and this session label information of said data channel are ordered as passive work mode feeds back;
The said link block of replying links to each other with second transport module with said transmission responder module, is used to reply the request of setting up data channel, and sets up the connection of data channel.
Said second transport module links to each other with the said link block of replying, and is used for obtaining this session label information from said data channel, and judges whether this session label information is effective, if then carry out transfer of data.
Another purpose of the embodiment of the invention is to propose a kind of request and answering system of setting up data channel; Said system comprises: request unit and answering device, described request device comprise the transmission command module, receive responder module, request link block and first transport module; Said answering device comprises the reception command module, obtains the IP module, sends responder module, replys the link block and second transport module.
Said transmission command module links to each other with said reception responder module, is used for sending the passive work mode order through order control channel;
Said reception responder module links to each other with the request link block with said transmission command module, is used to receive and resolve the response message of said passive work mode order, and obtains monitoring IP address, listening port and this session label information of data channel;
The described request link block links to each other with first transport module with said reception responder module, be used for to said monitoring IP address with listening port request set up data channel and be connected;
Said first transport module links to each other with the described request link block, is used for writing this session label information that receives, the data transfer of going forward side by side to said data channel after the successful connection.
Said reception command module links to each other with the said IP of obtaining module, is used to receive the passive work mode order, obtains the IP address of sending said passive work mode order;
The said IP module of obtaining links to each other with the transmission responder module with said reception command module, is used for obtaining the monitoring IP address and the listening port of data channel according to the IP address of sending said passive work mode order;
Said transmission responder module; With the said IP of obtaining module with reply link block and link to each other; Be used to generate this session label information, and the response message that monitoring IP address, listening port and this session label information of said data channel are ordered as passive work mode feeds back;
The said link block of replying links to each other with second transport module with said transmission responder module, is used to reply the request of setting up data channel, and sets up the connection of data channel.
Said second transport module links to each other with the said link block of replying, and is used for obtaining this session label information from said data channel, and judges whether this session label information is effective, if then carry out transfer of data.
Another purpose of the embodiment of the invention is to propose a kind of said terminal equipment of setting up the request unit of data channel that comprises.
Another purpose of the embodiment of the invention is to propose a kind of said server of setting up the answering device of data channel that comprises.
Beneficial effect of the present invention:
The present invention sends the passive work mode order through order control channel, obtains the IP address of sending said passive work mode order, obtains the monitoring IP address and the listening port of data channel; Generate this session label information and reply, resolve the response message of said passive work mode order, and obtain monitoring IP address, listening port and this session label information of said data channel; The connection that data channel is set up in request writes this session label information to data channel, carries out transfer of data; Thereby realization FTP service end uses a data port and a plurality of client to carry out file transfer; Realized being distributed in the IP of a plurality of corporate intranets and the FTP service end of a public network IT system effectively and carried out the file data transmission, and improved the concurrent performance of FTP service end, transmission speed is fast; Efficient is high; Avoid the fire compartment wall of FTP service end must open the FPDP of certain limit, reduced potential safety hazard, improved the fail safe of system; Guarantee the controllability that FPDP is opened, saved port resource.
Embodiment
In order to make the object of the invention, technical scheme and advantage clearer, below in conjunction with accompanying drawing and embodiment, the present invention is further elaborated, for the ease of explanation, only show the part relevant with the embodiment of the invention.Should be appreciated that the specific embodiment that this place is described, only be used to explain the present invention, not in order to restriction the present invention.
The present invention sends the passive work mode order through order control channel, obtains the IP address of sending said passive work mode order, obtains the monitoring IP address and the listening port of data channel; Generate this session label information and reply, resolve the response message of said passive work mode order, and obtain monitoring IP address, listening port and this session label information of said data channel; The connection that data channel is set up in request writes this session label information to data channel, carries out transfer of data; Thereby realization FTP service end uses a data port and a plurality of client to carry out file transfer; Realized being distributed in the IP of a plurality of corporate intranets and the FTP service end of a public network IT system effectively and carried out the file data transmission, and improved the concurrent performance of FTP service end, transmission speed is fast; Efficient is high; Avoid the fire compartment wall of FTP service end must open the FPDP of certain limit, reduced potential safety hazard, improved the fail safe of system; Guarantee the controllability that FPDP is opened, saved port resource.
Embodiment one
A kind of requesting method flow chart of setting up data channel of Fig. 1 embodiment of the invention.Described method may further comprise the steps:
S101 sends the passive work mode order through order control channel;
Ftp client sends passive work mode through control channel and orders the service end to FTP;
S102 receives and resolves the response message that said passive work mode is ordered, and obtains monitoring IP address, listening port and this session identification of data channel;
After ftp client is received the passive work mode command response, resolve the target ip address that extraction will connect, port and this session label information by the text formatting that presets;
Said monitoring IP address and port are the target ip address and the port of the FTP service end that needs be connected;
S103, to said monitoring IP address with listening port request set up data channel and be connected;
After ftp client gets access to the monitoring IP address and listening port of FTP service end data channel, attempt setting up data channel with the FTP service end;
S104 writes this session label information that receives, the data transfer of going forward side by side to said data channel after the successful connection.
Ftp client writes this session label information to said data channel, attempts carrying out transfer of data then; The FTP service end reads this session label information from data channel and carries out the validity judgement, if effectively, promptly allows to continue to receive follow-up data, if data channel is promptly closed in inefficacy at once, forbids that ftp client is to FTP service end transmission data.
The further optimization of technique scheme is,
Said step " is sent the passive work mode order through order control channel " and is also comprised step before:
Set up order control channel;
Obtain authentication result information.
At first ftp client and FTP service end are set up order control channel, accomplish the username and password login authentication of client then;
The port default of said FTP service end order control channel service is 21.
Send the passive work mode order through order control channel in the embodiment of the invention, resolve the response message of said passive work mode order, and obtain monitoring IP address, listening port and this session label information of said data channel; The connection that data channel is set up in request writes this session label information to data channel, carries out transfer of data; Read this session label information from data channel, judge whether this session label information is effective, thereby allow or the forbidden data transmission; Use a data port and a plurality of client to carry out file transfer to realize the FTP service end; Realized being distributed in the IP of a plurality of corporate intranets and the FTP service end of a public network IT system effectively and carried out the file data transmission, and improved the concurrent performance of FTP service end, transmission speed is fast; Efficient is high; Avoid the fire compartment wall of server end must open the FPDP of certain limit, reduced potential safety hazard, improved the fail safe of system; Guarantee the controllability that FPDP is opened, saved port resource.
Embodiment two
Fig. 2 is a kind of answer method flow chart of setting up data channel of the embodiment of the invention.Described method may further comprise the steps:
S201 receives said passive work mode order, obtains the IP address of sending said passive work mode order;
S202 according to the IP address of sending said passive work mode order, obtains the monitoring IP address and the listening port of data channel;
The monitoring IP address of said data channel and listening port the IP address and the port that carry out transfer of data for presetting in advance;
After the FTP service end is received the passive work mode order; Extract the visiting IP address of ftp client and promptly send the IP address of said passive work mode order; The monitoring IP address that feeds back to the data channel that ftp client will connect according to visiting IP address field decision is that the Intranet IP address of NAT gateway still is the public network IP address of NAT gateway; And the listening port of data channel, be specially:
S2021; Whether the IP address of judge sending said passive work mode order is in first address realm that presets (for example first address realm can be 127.0.0.1); If; Then the monitoring IP address of said data channel and listening port are the Intranet IP address and the port of NAT gateway, if not, get into step S2022;
S2022; (for example second address realm can be 10.0.0.0~10.255.255.255) in second address realm that presets in the IP address of judge sending said passive work mode order; If; Then the monitoring IP address of said data channel and listening port are the Intranet IP address and the port of NAT gateway, if not, get into step S2023;
S2023; (for example the three-address scope can be 172.16.0.0~172.31.255.255) in the three-address scope that presets in the IP address of judge sending said passive work mode order; If; Then the monitoring IP address of said data channel and listening port are the Intranet IP address and the port of NAT gateway, if not, get into step S2024;
S2024; Whether the IP address of judge sending said passive work mode order (192.168.0.0~192.168.255.255) in the four-address scope that presets; If; Then the monitoring IP address of said data channel and listening port are the Intranet IP address and the port of NAT gateway, if not, then the monitoring IP address of said data channel and listening port are the public network IP address and the port of NAT gateway.
S203 generates this session label information, and the response message that monitoring IP address, listening port and this session label information of said data channel are ordered as passive work mode feeds back;
Said this session label information is unique numeric string or the character string that the FTP service end is distributed this session; Described this session label information also can be with it corresponding unique numeric string or the character string of FTP service end according to the IP address assignment of sending said passive work mode order;
The FTP service end generates this session label information after receiving the passive work mode order;
The FTP service end is received when the passive work mode order is replied; The monitoring IP address of promptly sending the IP address specified data passage of said passive work mode order according to the visiting IP address of ftp client is that Intranet IP address still is the public network IP address of NAT gateway outlet, and monitoring IP address, listening port and this session label information after will confirming feed back to ftp client with the text formatting that presets;
S204 replys the request of setting up data channel, and sets up the connection of data channel;
The FTP service end is replied the ftp client request of connecting, and accomplishes TCP (Transmission Control Protocol, transmission control protocol) three-way handshake process, thereby sets up data channel;
S205 obtains this session label information from said data channel, and judges whether this session label information is effective, if then carry out transfer of data; If, do not close the connection of said data channel by force;
When judging that this session label information whether effectively, if the FTP service end then allows said data channel to carry out transfer of data; If, do not close the connection of said data channel by force.
Obtain this session label information from said data channel; And judge whether this session label information is effective; If then the data channel connection authentication of firm foundation is passed through, thereby is allowed said data channel to carry out transfer of data; If not (if the FTP service end judge said this session label information invalid or etc. this session label information to be read overtime), then the data channel of firm foundation is connected and closes by force;
Said judge this session label information whether effectively process be: judge whether this session label information that gets access to from said data channel is unique numeric string or the character string of distributing to the IP address of sending said passive work mode order originally;
Said judge this session label information whether effectively process be: judge that whether this session label information of getting access to from said data channel is this session label information of feeding back as the response message that sends the IP address that said passive work mode orders together with the monitoring IP address of said data channel and listening port originally; If the FTP service end then allows said data channel to carry out transfer of data; If, do not close the connection of said data channel by force.
When ftp client when order control channel is sent the file download command, the FTP service end promptly sends to ftp client to said file through said data channel, thus the download of completion file.
The further optimization of technique scheme is said step " receives the passive work mode order, obtains and send the IP address that said passive work mode is ordered " and also comprises before:
The bind command listening port is set up order control channel;
Carry out login authentication, and feedback authentication result information;
Said order listening port is defaulted as 21 ports;
At first ftp client and FTP service end are set up order control channel, accomplish the username and password login authentication of client then;
Said FTP service end order control channel serve port is defaulted as 21.
The further optimization of technique scheme is,
Before first address realm that whether is presetting in the IP address of judge sending said passive work mode order; The four-address scope that at first will send the IP address of said passive work mode order and first address realm that presets, second address realm that presets, the three-address scope that presets and preset converts the decimal system or hexadecimal into, is specially:
Convert the IP address of sending said passive work mode order and first address realm that presets, second address realm that presets, the three-address scope that presets and the four-address scope that presets into the decimal system or hexadecimal numerical value;
With the IP address of the said passive work mode order of the said decimal system or hexadecimal transmission and the said decimal system perhaps hexadecimal first address realm that presets, second address realm that presets, the three-address scope that presets and the four-address scope that presets compare, obtain the monitoring IP address of said data channel and Intranet IP address that listening port is the NAT gateway or the public network IP address of NAT gateway;
For ease of understanding, illustrate, wherein said IP address 127.0.0.1 converts decimal system numerical value into and is: 2130706432;
Said IP address 10.0.0.0~10.255.255.255 converts decimal system numerical value into: 167772160~184549375;
Said IP address 172.16.0.0~172.31.255.255 converts decimal system numerical value into: 2886729728~2887778303;
Said IP address 192.168.0.0~192.168.255.255 converts decimal system numerical value into: 3232235520~3232301055;
If sending the IP address of said passive work mode order is 127.0.0.1, then converts decimal system numerical value into and be: 2130706432,
That is to say before first address realm that whether is presetting in the IP address of judging said passive work mode order; At first with the IP address of described passive work mode order and first address realm that presets, second address realm that presets, the three-address scope that presets, the four-address scope that presets; Convert the decimal system or hexadecimal into; And then compare; Be execution in step S2021 to S2024; In execution in step S2021 to S2024 process, carry out carrying out the decimal system or hexadecimal numeric ratio exactly when the IP address is judged relatively so accordingly, confirm the monitoring IP address of said data channel and Intranet IP address and the port that listening port is the NAT gateway at last.
Send the IP address that said passive work mode is ordered through receiving the passive work mode order, obtaining in the embodiment of the invention, according to the IP address of sending said passive work mode order; Obtain the monitoring IP address and the listening port of data channel, generate this session label information, and the response message that monitoring IP address, listening port and this session label information of said data channel are ordered as passive work mode feeds back; Reply and set up the connection of data channel, obtain said this session label information, judge whether effective this session mark information is known from said data channel; If, then carry out transfer of data, in answering, add this session label information; Thereby realization FTP service end uses a data port and a plurality of client to carry out file transfer; Realized being distributed in the IP of a plurality of corporate intranets and the FTP service end of a public network IT system effectively and carried out the file data transmission, and improved the concurrent performance of FTP service end, transmission speed is fast; Efficient is high; Avoid the fire compartment wall of FTP service end must open the FPDP of certain limit, reduced potential safety hazard, improved the fail safe of system; Guarantee the controllability that FPDP is opened, saved port resource; Secondly according to the IP address of sending said passive work mode order through a plurality of condition judgment are carried out in the IP address; Confirm whether ftp client is in the same network segment with the FTP service end; If the together individual network segment is promptly informed the Intranet IP address and the port of ftp client NAT gateway,, realized the NAT gateway penetration when data channel is set up if not the public network IP address and the port of promptly informing ftp client NAT gateway with a network segment; Further improved the concurrent performance of FTP service end; Further guaranteed the controllability that FPDP is opened, saved port resource, the agreement of having avoided defining between enterprise separately causes system to lack open and increase system development complexity; Shorten the construction cycle, practice thrift cost; With the IP address transition is the decimal system or hexadecimal numerical value, and the said decimal system or hexadecimal numerical value are compared, and obtains the monitoring IP address and the listening port of data channel, and efficient relatively further improves.
Embodiment three
Fig. 3 is a kind of structural representation of setting up the request unit of data channel of the embodiment of the invention.
Said device comprises: send command module, receive responder module, request link block and first transport module;
Said transmission command module links to each other with said reception responder module, is used for sending the passive work mode order through order control channel;
Ftp client sends passive work mode through control channel and orders the service end to FTP;
Said reception responder module links to each other with the request link block with said transmission command module, is used to receive and resolve the response message of said passive work mode order, and obtains monitoring IP address, listening port and this session label information of data channel;
After ftp client is received the passive work mode command response, resolve the target ip address that extraction will connect, port and this session label information by the text formatting that presets;
Said monitoring IP address and port are the target ip address and the port of the FTP service end that needs be connected;
The described request link block links to each other with first transport module with said reception responder module, be used for to said monitoring IP address with listening port request set up data channel and be connected;
After ftp client gets access to the monitoring IP address and listening port of FTP service end data channel, attempt setting up data channel with the FTP service end;
Said first transport module links to each other with the described request link block, is used for writing this session label information that receives, the data transfer of going forward side by side to said data channel after the successful connection.
Ftp client writes this session label information to said data channel, attempts carrying out transfer of data then; The FTP service end reads this session label information from data channel and carries out the validity judgement, if effectively, promptly allows to continue to receive follow-up data, if data channel is promptly closed in inefficacy at once, forbids that ftp client is to FTP service end transmission data.
The further optimization of said apparatus is that said device also comprises the first passage module and obtains authentication module:
Said first passage module links to each other with the said authentication module that obtains, and is used for setting up order control channel;
The said authentication module that obtains links to each other with the transmission command module with said first passage module, is used to obtain authentication result information.
At first ftp client and FTP service end are set up order control channel (FTP service end order control channel serve port is defaulted as 21), accomplish the username and password debarkation authentication of client then.
Send the passive work mode order through sending command module through order control channel in the embodiment of the invention, resolve the response message of said passive work mode order through receiving responder module, and obtain monitoring IP address, listening port and this session label information of said data channel; Through the connection of asking the link block request to set up data channel; Write this session label information through first transport module to data channel, the data transfer of going forward side by side adds this session label information in request process; Thereby realization FTP service end uses a data port and a plurality of client to carry out file transfer; Realized being distributed in the IP of a plurality of corporate intranets and the FTP service end of a public network IT system effectively and carried out the file data transmission, and improved the concurrent performance of FTP service end, transmission speed is fast; Efficient is high; Avoid the fire compartment wall of FTP service end end must open the FPDP of certain limit, reduced potential safety hazard, improved the fail safe of system.
Embodiment four
Fig. 4 is a kind of structural representation of setting up answering device first preferred embodiment of data channel of the present invention.
Said device comprises: receive command module, obtain the IP module, send responder module, reply the link block and second transport module;
Said reception command module links to each other with the said IP of obtaining module, is used to receive the passive work mode order, obtains the IP address of sending said passive work mode order;
The said IP module of obtaining links to each other with the transmission responder module with said reception command module, is used for obtaining the monitoring IP address and the listening port of data channel according to the IP address of sending said passive work mode order;
After the FTP service end is received the passive work mode order; Extract the visiting IP address of client and promptly send the IP address of said passive work mode order; The monitoring IP address that feeds back to the data channel that client will connect according to visiting IP address field decision is that the Intranet IP address of NAT gateway still is the public network IP address of NAT gateway, and the listening port of data channel.
Said transmission responder module; With the said IP of obtaining module with reply link block and link to each other; Be used to generate this session label information, and the response message that monitoring IP address, listening port and this session label information of said data channel are ordered as passive work mode feeds back;
Said this session label information is unique numeric string or the character string that server end distributes when carrying out this session;
Described this session label information also can be with it corresponding unique numeric string or the character string of FTP service end according to the IP address assignment of sending said passive work mode order;
The FTP service end generates this session label information after receiving the passive work mode order;
The FTP service end receives when passive work mode order is replied, and monitoring IP address, listening port and this session label information of said data channel fed back to ftp client with the text formatting that presets;
The said link block of replying links to each other with second transport module with said transmission responder module, is used to reply the request of setting up data channel, and sets up the connection of data channel.
The FTP service end is replied the ftp client ACK that connects, and accomplishes the TCP three-way handshake process, thereby sets up data channel;
Said second transport module links to each other with the said link block of replying, and is used for obtaining this session label information from said data channel, and judges whether this session label information is effective, if then carry out transfer of data.
When judging that this session label information whether effectively, if the FTP service end then allows said data channel to carry out transfer of data; If, do not close the connection of said data channel by force.
Obtain this session label information from said data channel; And judge whether this session label information is effective; If then the data channel connection authentication of firm foundation is passed through, thereby is allowed said data channel to carry out transfer of data; If not (if the FTP service end judge said this session label information invalid or etc. this session label information to be read overtime), then the data channel of firm foundation is connected and closes by force;
Said judge this session label information whether effectively process be: judge whether this session label information that gets access to from said data channel is unique numeric string or the character string of distributing to the IP address of sending said passive work mode order originally;
Said judge this session label information whether effectively process can also be: judge that whether this session label information of getting access to from said data channel is this session label information of feeding back as the response message that sends the IP address that said passive work mode orders together with the monitoring IP address of said data channel and listening port originally; If the FTP service end then allows said data channel to carry out transfer of data; If, do not close the connection of said data channel by force.
When ftp client when order control channel is sent the file download command, the FTP service end promptly sends to ftp client to said file through said data channel, thus the download of completion file.
The further optimization of said apparatus is that said device also comprises second channel module and authentication feedback module:
Said second channel module links to each other with said authentication feedback module, is used for setting up order control channel with default port 21;
Said authentication feedback module links to each other with the reception command module with said second channel module, is used to carry out authentication, and feedback authentication result information.
At first ftp client and FTP service end are set up order control channel (FTP service end order control channel serve port is defaulted as 21), accomplish the username and password debarkation authentication of client then.
The further optimization of said apparatus is that said device also comprises closes link block, is illustrated in figure 5 as a kind of structural representation of setting up answering device second preferred embodiment of data channel of the present invention;
The said link block of closing links to each other with the said link block of replying, and is invalid if be used for from this session label information that said data channel is obtained, and then closes the connection of said data channel by force.
If the FTP service end judge said this session label information invalid or etc. this session label information to be read overtime, promptly the data channel of firm foundation is connected and closes by force.
The further optimization of said apparatus is; The said IP of obtaining module comprises first judge module, second judge module, the 3rd judge module and the 4th judge module, is illustrated in figure 5 as a kind of structural representation of setting up answering device second preferred embodiment of data channel of the present invention;
Said first judge module; Link to each other with said transmission responder module; Be used to judge that the IP address of sending said passive work mode order is whether in first address realm that presets (for example first address realm can be 127.0.0.1), if then the monitoring IP address of said data channel and listening port are the Intranet IP address and the port of NAT gateway; If, then do not notify second judge module to continue to judge.
Said second judge module; Link to each other with the 3rd judge module with said first judge module, transmission responder module; Be used to judge that whether (for example second address realm can be 10.0.0.0~10.255.255.255), if then the monitoring IP address of said data channel and listening port are the Intranet IP address and the port of NAT gateway in second address realm that presets in the IP address of sending said passive work mode order; If, then do not notify the 3rd judge module to continue to judge.
Said the 3rd judge module; With said second judge module, transmission responder module and the 4th judge module; Be used to judge that whether (for example the three-address scope can be 172.16.0.0~172.31.255.255), if then the monitoring IP address of said data channel and listening port are the Intranet IP address and the port of NAT gateway in the three-address scope that presets in the IP address of sending said passive work mode order; If, then do not notify the 4th judge module to continue to judge.
Said the 4th judge module; Link to each other with the transmission responder module with said the 3rd judge module; Be used to judge that whether (192.168.0.0~192.168.255.255) is if then the monitoring IP address of said data channel and listening port are the Intranet IP address and the port of NAT gateway in the four-address scope that presets in the IP address of sending said passive work mode order; Then the monitoring IP address of said data channel and listening port are the public network IP address and the port of NAT gateway if not.
The further optimization of said apparatus is; Before first the address realm whether said IP of obtaining module also is used for presetting in the IP address of judging the said passive work mode order of transmission; The four-address scope that at first will send the IP address of said passive work mode order and first address realm that presets, second address realm that presets, the three-address scope that presets and preset converts the decimal system or hexadecimal into; With the IP address of the said passive work mode order of the said decimal system or hexadecimal transmission and the said decimal system perhaps hexadecimal first address realm that presets, second address realm that presets, the three-address scope that presets and the four-address scope that presets compare, obtain the monitoring IP address of said data channel and Intranet IP address that listening port is the NAT gateway or the public network IP address of NAT gateway;
For ease of understanding, illustrate, wherein said IP address 127.0.0.1 converts decimal system numerical value into and is: 2130706432;
Said IP address 10.0.0.0~10.255.255.255 converts decimal system numerical value into: 167772160~184549375;
Said IP address 172.16.0.0~172.31.255.255 converts decimal system numerical value into: 2886729728~2887778303;
Said IP address 192.168.0.0~192.168.255.255 converts decimal system numerical value into: 3232235520~3232301055;
If sending the IP address of said passive work mode order is 127.0.0.1, then converts decimal system numerical value into and be: 2130706432, then compare, confirm the monitoring IP address of said data channel and Intranet IP address and the port that listening port is the NAT gateway.
Receive the passive work mode order through receiving command module in the embodiment of the invention, obtain the IP address of sending said passive work mode order through obtaining the IP module, according to the IP address of sending said passive work mode order; Obtain the monitoring IP address and the listening port of data channel, generate this session label information through sending responder module, and the response message that monitoring IP address, listening port and said this session label information of said data channel are ordered as passive work mode feeds back; Reply and set up the connection of data channel through replying link block; Obtain said this session label information through second transport module from said data channel, judge whether this session label information is effective, if; Then carry out transfer of data; In answering, add this session label information, thereby realize that the FTP service end uses a data port and a plurality of client to carry out file transfer, the FTP service end that has realized being distributed in IP and a public network IT system of a plurality of corporate intranets is effectively carried out file data and is transmitted; And improved the concurrent performance of FTP service end; Transmission speed is fast, and efficient is high, has avoided the fire compartment wall of FTP service end must open the FPDP of certain limit; Reduce potential safety hazard, improved the fail safe of system; If to obtain this session label information from said data channel be invalid through closing link block, then close the connection of said data channel by force, further reduce the potential safety hazard of system; Secondly through in first judge module, second judge module, the 3rd judge module and the 4th judge module according to the judgement of the IP address different condition of sending said passive work mode order; Confirm whether ftp client is in the same network segment with the FTP service end; If inform promptly that with a network segment ftp client passes through Intranet IP visit FTP service end FPDP, if not informing promptly that with a network segment ftp client visits FTP service end FPDP through the outlet IP of NAT gateway, has realized the NAT gateway penetration when data channel is set up; Further improved the concurrent performance of FTP service end; Further guaranteed the controllability that FPDP is opened, saved port resource, the agreement of having avoided defining between enterprise separately causes system to lack open and increase system development complexity; Shorten the construction cycle, practice thrift cost; Especially, obtaining the IP module is the decimal system or hexadecimal numerical value with the IP address transition, and the said decimal system or hexadecimal numerical value are compared, and obtains the monitoring IP address and the listening port of data channel, and efficient relatively further improves.
Embodiment five
Fig. 6 is that the embodiment of the invention is set up the request of data channel and the structural representation of answering system.
Said system comprises: request unit and answering device, described request device comprise the transmission command module, receive responder module, request link block and first transport module; Said answering device comprises the reception command module, obtains the IP module, sends responder module, replys the link block and second transport module.
Said transmission command module links to each other with the reception responder module with said reception command module, is used for sending the passive work mode order through order control channel;
Said reception responder module; Link to each other with said transmission command module, request link block and transmission responder module; Be used to receive and resolve the response message of said passive work mode order, and obtain monitoring IP address, listening port and this session label information of data channel;
The described request link block, with said reception responder module, first transport module with reply link block and link to each other, be used for to said monitoring IP address with listening port request set up data channel and be connected;
Said first transport module links to each other with second transport module with the described request link block, is used for writing this session label information that receives, the data transfer of going forward side by side to said data channel after the successful connection.
Said reception command module, with said transmission command module with obtain the IP module and link to each other, be used to receive the passive work mode order, obtain the IP address of sending said passive work mode order;
The said IP module of obtaining links to each other with the transmission responder module with said reception command module, is used for obtaining the monitoring IP address and the listening port of data channel according to the IP address of sending said passive work mode order;
Said transmission responder module; With the said IP of obtaining module with reply link block and link to each other; Be used to generate this session label information, and the response message that monitoring IP address, listening port and this session label information of said data channel are ordered as passive work mode feeds back;
The said link block of replying links to each other with second transport module with said transmission responder module, is used to reply the request of setting up data channel, and sets up the connection of data channel.
Said second transport module links to each other with the said link block of replying, and is used for obtaining this session label information from said data channel, and judges whether this session label information is effective, if then carry out transfer of data.
Said system further optimized be, said system also comprises and closes link block;
The said link block of closing links to each other with the said link block of replying, and is invalid if be used for from this session label information that said data channel is obtained, and then closes the connection of said data channel by force.
If the FTP service end judge said this session label information invalid or etc. this session label information to be read overtime, promptly the data channel of firm foundation is connected and closes by force.
The further optimization of said system is that the said IP of obtaining module comprises first judge module, second judge module, the 3rd judge module and the 4th judge module.
Said first judge module; Link to each other with said transmission responder module; Be used to judge that the IP address of sending said passive work mode order is whether in first address realm that presets (for example first address realm can be 127.0.0.1), if then the monitoring IP address of said data channel and listening port are the Intranet IP address and the port of NAT gateway; If, then do not notify second judge module to continue to judge.
Said second judge module; Link to each other with the 3rd judge module with said first judge module, transmission responder module; Be used to judge that whether (for example second address realm can be 10.0.0.0~10.255.255.255), if then the monitoring IP address of said data channel and listening port are the Intranet IP address and the port of NAT gateway in second address realm that presets in the IP address of sending said passive work mode order; If, then do not notify the 3rd judge module to continue to judge.
Said the 3rd judge module; Link to each other with the 4th judge module with said second judge module, transmission responder module; Be used to judge that whether (for example the three-address scope can be 172.16.0.0~172.31.255.255), if then the monitoring IP address of said data channel and listening port are the Intranet IP address and the port of NAT gateway in the three-address scope that presets in the IP address of sending said passive work mode order; If, then do not notify the 4th judge module to continue to judge.
Said the 4th judge module; Link to each other with the transmission responder module with said the 3rd judge module; Be used to judge that whether (192.168.0.0~192.168.255.255) is if then the monitoring IP address of said data channel and listening port are the Intranet IP address and the port of NAT gateway in the four-address scope that presets in the IP address of sending said passive work mode order; Then the monitoring IP address of said data channel and listening port are the public network IP address and the port of NAT gateway if not.
The further optimization of said system is; Before first the address realm whether said IP of obtaining module also is used for presetting in the IP address of judging the said passive work mode order of transmission; The four-address scope that at first will send the IP address of said passive work mode order and first address realm that presets, second address realm that presets, the three-address scope that presets and preset converts the decimal system or hexadecimal into; With the IP address of the said passive work mode order of the said decimal system or hexadecimal transmission and the said decimal system perhaps hexadecimal first address realm that presets, second address realm that presets, the three-address scope that presets and the four-address scope that presets compare, obtain the monitoring IP address of said data channel and Intranet IP address that listening port is the NAT gateway or the public network IP address of NAT gateway.
For ease of understanding, illustrate, wherein said IP address 127.0.0.1 converts decimal system numerical value into and is: 2130706432;
Said IP address 10.0.0.0~10.255.255.255 converts decimal system numerical value into: 167772160~184549375;
Said IP address 172.16.0.0~172.31.255.255 converts decimal system numerical value into: 2886729728~2887778303;
Said IP address 192.168.0.0~192.168.255.255 converts decimal system numerical value into: 3232235520~3232301055;
If sending the IP address of said passive work mode order is 127.0.0.1, then converts decimal system numerical value into and be: 2130706432, then compare, confirm the monitoring IP address of said data channel and Intranet IP address and the port that listening port is the NAT gateway.
Send the passive work mode order through sending command module through order control channel in the embodiment of the invention, receive said passive work mode order, obtain the IP address of sending said passive work mode order through obtaining the IP module through receiving command module; According to the IP address of sending said passive work mode order, obtain the monitoring IP address and the listening port of data channel, generate this session label information through sending responder module; And monitoring IP address, listening port and this session label information of the said data channel response message as the passive work mode order fed back, resolve the response message of said passive work mode order through receiving responder module, and obtain monitoring IP address, listening port and this session label information of said data channel; Through the connection of asking the link block request to set up data channel; Reply the request of setting up data channel through replying link block, and set up the connection of data channel, write this session label information to data channel through first transport module; The data transfer of going forward side by side; Obtain this session label information through second transport module from said data channel, and judge whether this session identification is effective, if; Then carry out transfer of data; In request process, add this session label information, thereby realize that the FTP service end uses a data port and a plurality of client to carry out file transfer, the FTP service end that has realized being distributed in IP and a public network IT system of a plurality of corporate intranets is effectively carried out file data and is transmitted; And improved the concurrent performance of FTP service end; Transmission speed is fast, and efficient is high, has avoided the fire compartment wall of FTP service end must open the FPDP of certain limit; Reduce potential safety hazard, improved the fail safe of system; If to obtain this session label information from said data channel be invalid through closing link block, then close the connection of said data channel by force, further reduce the potential safety hazard of system; Secondly through in first judge module, second judge module, the 3rd judge module and the 4th judge module according to the judgement of the IP address different condition of sending said passive work mode order; Confirm whether ftp client is in the same network segment with the FTP service end; If the together individual network segment is promptly informed the Intranet IP address and the port of ftp client NAT gateway,, realized the NAT gateway penetration when data channel is set up if not the public network IP address and the port of promptly informing ftp client NAT gateway with a network segment; Further improved the concurrent performance of FTP service end; Further guaranteed the controllability that FPDP is opened, saved port resource, the agreement of having avoided defining between enterprise separately causes system to lack open and increase system development complexity; Shorten the construction cycle, practice thrift cost; Especially, obtaining the IP module is the decimal system or hexadecimal numerical value with the IP address transition, and the said decimal system or hexadecimal numerical value are compared, and obtains the monitoring IP address and the listening port of data channel, and efficient relatively further improves.
The request unit of setting up data channel provided by the invention can be applied to set up on the terminal equipment of request of data channel, for example: PC, PDA, mobile phone etc.
The answering device of setting up data channel provided by the invention can be applied to set up on the server of replying of data channel, for example: PC, server etc.