Skip to content

gh-127478: Enhancement to support FTP connection with NAT scenario #127477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Prev Previous commit
Update ftplib.py
  • Loading branch information
yugandhar2587 committed Dec 2, 2024
commit d6cc6ff4877368c17c91b977da9980e2ccd58273
5 changes: 3 additions & 2 deletions Lib/ftplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,11 @@ def makeport(self):
def makepasv(self):
"""Internal: Does the PASV or EPSV handshake -> (address, port)"""
if self.af == socket.AF_INET:
pasv_response = self.sendcmd('PASV')
try:
untrusted_host, port = parse227(self.sendcmd('PASV'))
untrusted_host, port = parse227(pasv_response)
except error_reply:
untrusted_host, port = parse229(self.sendcmd('EPSV'), self.sock.getpeername())
untrusted_host, port = parse229(pasv_response, self.sock.getpeername())
if self.trust_server_pasv_ipv4_address:
host = untrusted_host
else:
Expand Down
Loading