Git Product home page Git Product logo

Comments (7)

wconrad avatar wconrad commented on July 24, 2024

Thank you for the kind words, and the bug report. The way the passive-mode code is written makes me think it would never work behind a NAT, so you must be the first to try: It's not a bug you've found as much as it's missing functionality. Most ftp servers have configuration options that you can use to get them to advertise the IP of your choice for passive mode connections. I think ftpd will need that, too.

For reference, here's the code that establishes the passive mode socket server and advertises the IP, from https://github.com/wconrad/ftpd/blob/6214d4800164304a18651a48d15a06447e317a2b/lib/ftpd/cmd_pasv.rb :

    interface = socket.addr[3]
    self.data_server = TCPServer.new(interface, 0)
    ip = data_server.addr[3]
    port = data_server.addr[1]
    quads = [
      ip.scan(/\d+/),
      port >> 8,
      port & 0xff,
    ].flatten.join(',')
    reply "227 Entering passive mode (#{quads})"

Yeah, that's never going to work behind a NAT firewall. The fix I have in mind will introduce a configuration variable for the advertised IP. The line ip = data_server.addr[3] will change to something like ip = configured_public_ip || data_server.addr[3].

I'll see what I can cook up in the way of a fix. I'm not sure when I'll get to it--hopefully this weekend.

from ftpd.

drewbug avatar drewbug commented on July 24, 2024

That would really be great. Thanks so much for the hard work you do on this project.

from ftpd.

wconrad avatar wconrad commented on July 24, 2024

If you are able to modify your Gemfile to point to a specific branch of ftpd, then could you please test the nat branch using this Gemfile line?

gem 'ftpd', git: "https://github.com/wconrad/ftpd", branch: "nat"

The new configuration item is called #nat_ip. Set it before starting the server, like so:

ftp_server = Ftpd::FtpServer.new(@driver)
ftp_server.nat_ip = "203.0.113.197"
ftp_server.start

If you can't test the branch easily, I'll just publish it as a new gem version and you can try it that way. It's a low risk change that's unlikely to break anything else, so that'd be OK.

Some people running an ftp server behind a firewall need to configure the port range that is used for passive server sockets. I haven't added that option yet. Let me know if you need it.

from ftpd.

wconrad avatar wconrad commented on July 24, 2024

The nat branch now has the option passive_ports which you can use to configure the range of ports to be used for passive-mode sockets.

from ftpd.

wconrad avatar wconrad commented on July 24, 2024

I don't think these "nat" changes will break anything, and the tests show that they probably fix this issue, so I'll merge this branch in and publish a new gem version. The new gem version is coming with another change (frozen strings) that is unlikely to break anyone, but could, so first gem version with these "nat" changes will be 2.0.0.

from ftpd.

drewbug avatar drewbug commented on July 24, 2024

Thanks so much for adding these features! We're now using the nat_ip config option in production. Sincerely appreciated.

from ftpd.

wconrad avatar wconrad commented on July 24, 2024

@drewbug It made my day that you are using this feature in production. Thanks!

from ftpd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.