Uploaded image for project: 'Commons Net'
  1. Commons Net
  2. NET-346

FTP should support reporting NATed external IP address

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.2
    • Fix Version/s: 3.1
    • Component/s: FTP
    • Labels:
      None

      Description

      When trying to do an active FTP transfer as client from behind a firewall with NAT, setActiveExternalIPAddress is not sufficient, as you can only report the internal IP of the client (e.g. 192.168.1.2 vs 72.14.X.X)

      FTPClient should support an additional function to set the REPORTABLE external active IP Address

      I created and successfully tested a fix for this:

      ADD PRIVATE MEMBER:
      private InetAddress __reportActiveExternalHost;

      IN __initDefaults():
      __reportActiveExternalHost = null;

      ADD PUBLIC FUNCTIONS:
      private InetAddress getReportHostAddress()
      {
      if (__reportActiveExternalHost != null)

      { return __reportActiveExternalHost ; }

      else if (__activeExternalHost != null)

      { return __activeExternalHost; }

      else

      { // default local address return getLocalAddress(); }

      }

      public void setReportActiveExternalIPAddress(String ipAddress) throws UnknownHostException

      { this.__reportActiveExternalHost = InetAddress.getByName(ipAddress); }

      IN openDataConnection:

      if (isInet6Address)
      {
      if (!FTPReply.isPositiveCompletion(eprt(getReportHostAddress(), server.getLocalPort())))

      { server.close(); return null; }
      }
      else
      {
      if (!FTPReply.isPositiveCompletion(port(getReportHostAddress(), server.getLocalPort())))
      { server.close(); return null; }

      }

      will also attach changed file

      sorry I am not familiar with the correct way to submit patches, although I tried to model this on #NET-285 as much as possible

        Attachments

        1. FTPClient.java
          120 kB
          Kevin Samuel
        2. ftpclient.patch
          3 kB
          Sebb

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              ksamuel Kevin Samuel
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified