Comments (7)
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.
That would really be great. Thanks so much for the hard work you do on this project.
from ftpd.
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.
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.
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.
Thanks so much for adding these features! We're now using the nat_ip
config option in production. Sincerely appreciated.
from ftpd.
@drewbug It made my day that you are using this feature in production. Thanks!
from ftpd.
Related Issues (20)
- Unable to reuse same port after stopping server HOT 6
- #stop causes "Errno::ENOTCONN: Socket is not connected" in OSX HOT 8
- Connection Hangs on "ls" HOT 3
- Add more handlers
- Tests fail under Ruby >= 2.2.3 HOT 2
- Can I hooking filesystem operations HOT 4
- [IMPROVEMENT] Cmd Size and exotic filesystem
- forwarding to private method XXX HOT 3
- FTPPermError 550 Access Denied. HOT 2
- FTP base path lack of trailing `/` results in denial of service and disclosure of the local file system path HOT 1
- add bindir in gemspec HOT 2
- ftpd windows version , the ftp server will crash if input 'dir' HOT 1
- Using ruby 2.4 fails HOT 3
- Modernize usage of File.dirname(__FILE__) to support symlinks HOT 1
- CPU usage pegged at 100% HOT 9
- rake test:features seems to be broken HOT 2
- Issue with TLS protocol
- Error Connection reset by peer @ io_fillbuf - fd:158
- Update testing to use newer Ruby versions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ftpd.