Fix PASV command to handle servers returning 0,0,0,0 IP address #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some FTP servers return
0,0,0,0
in PASV responses when they cannot determine their own IP address. This fix ensures the FTP client uses the connection IP address instead of the unusable0,0,0,0
.Problem
When FTP servers can't guess their IP address, they may return
0,0,0,0
in PASV responses like:Previously, the client would attempt to connect to
0.0.0.0
for data connections, which would fail since it's not a valid destination address.Solution
Enhanced the
isBogusDataIP
function to explicitly detect unspecified IP addresses (0.0.0.0
for IPv4,::
for IPv6) and treat them as bogus. When a bogus IP is detected, the client now uses the control connection's IP address for data connections instead.Testing
Added comprehensive tests covering:
0,0,0,0
responsesAll existing tests (40 total) continue to pass, ensuring no regressions were introduced.
Impact
This change improves compatibility with FTP servers that have networking configuration issues or are behind NAT/firewalls where they cannot determine their external IP address. The fix is minimal and surgical, adding only explicit handling for unspecified addresses without changing the existing logic flow.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.