[jira] [Created] (NET-462) FTPClient in PASSIVE_LOCAL_DATA_CONNECTION_MODE cannot work when host have several different IP

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Created] (NET-462) FTPClient in PASSIVE_LOCAL_DATA_CONNECTION_MODE cannot work when host have several different IP

Gary D. Gregory (Jira)
Junsheng Chen created NET-462:
---------------------------------

             Summary: FTPClient in PASSIVE_LOCAL_DATA_CONNECTION_MODE cannot work when host have several different IP
                 Key: NET-462
                 URL: https://issues.apache.org/jira/browse/NET-462
             Project: Commons Net
          Issue Type: Improvement
          Components: FTP
    Affects Versions: 3.1
         Environment: All OS,for example linux or windows and so on
            Reporter: Junsheng Chen
            Priority: Minor
             Fix For: 3.2


When host have several different IP and client setting to PASSIVE_LOCAL_DATA_CONNECTION_MODE,_openDataConnection_ creating socket may use the unexpected ip。
For example, The host have two Ips, one for intra and the another for extern, only the extern one can be connect with the outside。But when in PASSIVE_LOCAL_DATA_CONNECTION_MODE, FTPClient may be select the intra Ip, So it didn't work。
So I change code like this, it can work normally by the specific ip.
Code:
In FTPClient._openDataConnection_(String command, String arg),line 761 change as bellow:
socket = _socketFactory_.createSocket();
           
// add begin
// local as client, transfer data must use the appointed local host
socket.bind(new InetSocketAddress(getHostAddress(), 0));
// add end

After log in success,User can set the ip which he want to use by call the method in FTPClient:
setActiveExternalIPAddress(String ip);


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


Reply | Threaded
Open this post in threaded view
|

[jira] [Updated] (NET-462) FTPClient in PASSIVE_LOCAL_DATA_CONNECTION_MODE cannot work when host have several different IP

Gary D. Gregory (Jira)

     [ https://issues.apache.org/jira/browse/NET-462?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bogdan Drozdowski updated NET-462:
----------------------------------

    Attachment: ftp-bindlocal.diff

The attached patch fixes this by adding a new field in FTPClient. By calling setPassiveLocalIPAddress(), you can set the local address to bind to. The field will be used in the same place as in your code (but it is a separate value from what getHostAddress returns).
In the meantime, you can create and install your own SocketFactory in the FTPClient. You can take DefaultSocketFactory class as an example and make you own factory, which will create sockes already bound to your local address. This will work even with the older versions of Commons-Net.
               

> FTPClient in PASSIVE_LOCAL_DATA_CONNECTION_MODE cannot work when host have several different IP
> -----------------------------------------------------------------------------------------------
>
>                 Key: NET-462
>                 URL: https://issues.apache.org/jira/browse/NET-462
>             Project: Commons Net
>          Issue Type: Improvement
>          Components: FTP
>    Affects Versions: 3.1
>         Environment: All OS,for example linux or windows and so on
>            Reporter: Junsheng Chen
>            Priority: Minor
>              Labels: ActiveIp, FTPClient, PASSIVE_LOCAL_DATA_CONNECTION_MODE
>             Fix For: 3.2
>
>         Attachments: ftp-bindlocal.diff
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> When host have several different IP and client setting to PASSIVE_LOCAL_DATA_CONNECTION_MODE,_openDataConnection_ creating socket may use the unexpected ip。
> For example, The host have two Ips, one for intra and the another for extern, only the extern one can be connect with the outside。But when in PASSIVE_LOCAL_DATA_CONNECTION_MODE, FTPClient may be select the intra Ip, So it didn't work。
> So I change code like this, it can work normally by the specific ip.
> Code:
> In FTPClient._openDataConnection_(String command, String arg),line 761 change as bellow:
> socket = _socketFactory_.createSocket();
>            
> // add begin
> // local as client, transfer data must use the appointed local host
> socket.bind(new InetSocketAddress(getHostAddress(), 0));
> // add end
> After log in success,User can set the ip which he want to use by call the method in FTPClient:
> setActiveExternalIPAddress(String ip);

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


Reply | Threaded
Open this post in threaded view
|

[jira] [Resolved] (NET-462) FTPClient in PASSIVE_LOCAL_DATA_CONNECTION_MODE cannot work when host have several different IP

Gary D. Gregory (Jira)
In reply to this post by Gary D. Gregory (Jira)

     [ https://issues.apache.org/jira/browse/NET-462?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sebb resolved NET-462.
----------------------

    Resolution: Fixed

Thanks, patch applied with minor changes; also added method

setPassiveLocalIPAddress(InetAddress inetAddress)

for completeness
               

> FTPClient in PASSIVE_LOCAL_DATA_CONNECTION_MODE cannot work when host have several different IP
> -----------------------------------------------------------------------------------------------
>
>                 Key: NET-462
>                 URL: https://issues.apache.org/jira/browse/NET-462
>             Project: Commons Net
>          Issue Type: Improvement
>          Components: FTP
>    Affects Versions: 3.1
>         Environment: All OS,for example linux or windows and so on
>            Reporter: Junsheng Chen
>            Priority: Minor
>              Labels: ActiveIp, FTPClient, PASSIVE_LOCAL_DATA_CONNECTION_MODE
>             Fix For: 3.2
>
>         Attachments: ftp-bindlocal.diff
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> When host have several different IP and client setting to PASSIVE_LOCAL_DATA_CONNECTION_MODE,_openDataConnection_ creating socket may use the unexpected ip。
> For example, The host have two Ips, one for intra and the another for extern, only the extern one can be connect with the outside。But when in PASSIVE_LOCAL_DATA_CONNECTION_MODE, FTPClient may be select the intra Ip, So it didn't work。
> So I change code like this, it can work normally by the specific ip.
> Code:
> In FTPClient._openDataConnection_(String command, String arg),line 761 change as bellow:
> socket = _socketFactory_.createSocket();
>            
> // add begin
> // local as client, transfer data must use the appointed local host
> socket.bind(new InetSocketAddress(getHostAddress(), 0));
> // add end
> After log in success,User can set the ip which he want to use by call the method in FTPClient:
> setActiveExternalIPAddress(String ip);

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (NET-462) FTPClient in PASSIVE_LOCAL_DATA_CONNECTION_MODE cannot work when host have several different IP

Gary D. Gregory (Jira)
In reply to this post by Gary D. Gregory (Jira)

    [ https://issues.apache.org/jira/browse/NET-462?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13411093#comment-13411093 ]

Sebb commented on NET-462:
--------------------------

URL: http://svn.apache.org/viewvc?rev=1359960&view=rev
Log:
NET-462 FTPClient in PASSIVE_LOCAL_DATA_CONNECTION_MODE cannot work when host have several different IP

Modified:
    commons/proper/net/trunk/src/changes/changes.xml
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPClient.java

               

> FTPClient in PASSIVE_LOCAL_DATA_CONNECTION_MODE cannot work when host have several different IP
> -----------------------------------------------------------------------------------------------
>
>                 Key: NET-462
>                 URL: https://issues.apache.org/jira/browse/NET-462
>             Project: Commons Net
>          Issue Type: Improvement
>          Components: FTP
>    Affects Versions: 3.1
>         Environment: All OS,for example linux or windows and so on
>            Reporter: Junsheng Chen
>            Priority: Minor
>              Labels: ActiveIp, FTPClient, PASSIVE_LOCAL_DATA_CONNECTION_MODE
>             Fix For: 3.2
>
>         Attachments: ftp-bindlocal.diff
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> When host have several different IP and client setting to PASSIVE_LOCAL_DATA_CONNECTION_MODE,_openDataConnection_ creating socket may use the unexpected ip。
> For example, The host have two Ips, one for intra and the another for extern, only the extern one can be connect with the outside。But when in PASSIVE_LOCAL_DATA_CONNECTION_MODE, FTPClient may be select the intra Ip, So it didn't work。
> So I change code like this, it can work normally by the specific ip.
> Code:
> In FTPClient._openDataConnection_(String command, String arg),line 761 change as bellow:
> socket = _socketFactory_.createSocket();
>            
> // add begin
> // local as client, transfer data must use the appointed local host
> socket.bind(new InetSocketAddress(getHostAddress(), 0));
> // add end
> After log in success,User can set the ip which he want to use by call the method in FTPClient:
> setActiveExternalIPAddress(String ip);

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira