Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Lib/ftplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,10 @@ def makeport(self):
def makepasv(self):
"""Internal: Does the PASV or EPSV handshake -> (address, port)"""
if self.af == socket.AF_INET:
untrusted_host, port = parse227(self.sendcmd('PASV'))
try:
untrusted_host, port = parse227(self.sendcmd('PASV'))
except error_reply:
untrusted_host, port = parse229(self.sendcmd('EPSV'), self.sock.getpeername())
if self.trust_server_pasv_ipv4_address:
host = untrusted_host
else:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enhancement to support FTP connection with NAT scenario.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try to come up with a better NEWS entry here for tomorrow but otherwise thank you.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Enhancement to support FTP connection with NAT scenario.
Support "229 Entering Extended Passive Mode" response in :meth:`ftplib.FTP.sendcmd`.

As per @ZeroIntensity's suggestion.

Loading