Skip to content

Commit 8e6ea02

Browse files
committed
Add documentation for FTP.prefer_epsv attribute
1 parent b5c8cc6 commit 8e6ea02

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

Doc/library/ftplib.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,22 @@ FTP objects
276276
prints the line to :data:`sys.stdout`.
277277

278278

279+
.. attribute:: FTP.prefer_epsv
280+
281+
A :class:`bool` that controls whether :meth:`makepasv` tries the EPSV
282+
command (RFC 2428) before falling back to PASV on IPv4 connections.
283+
Defaults to ``True``.
284+
285+
EPSV responses contain only a port number and no IP address, making them
286+
transparent to firewall FTP Application Layer Gateways (ALGs) that
287+
commonly intercept and mangle PASV responses. If the server does not
288+
support EPSV, :meth:`makepasv` falls back to PASV automatically.
289+
290+
Set to ``False`` to restore the legacy PASV-first behavior on IPv4.
291+
292+
.. versionadded:: 3.15
293+
294+
279295
.. method:: FTP.set_pasv(val)
280296

281297
Enable "passive" mode if *val* is true, otherwise disable passive mode.

Misc/NEWS.d/next/Library/2026-05-22-12-00-00.gh-issue-127478.EpsvFtp.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
:mod:`ftplib`: :meth:`~ftplib.FTP.makepasv` now prefers EPSV (RFC 2428) over
1+
:mod:`ftplib`: Passive mode data connections now prefer EPSV (RFC 2428) over
22
PASV on IPv4 connections, falling back to PASV if the server does not support
33
EPSV. EPSV is firewall-transparent as it does not embed an IP address in the
44
response, avoiding interference from firewall FTP Application Layer Gateways

0 commit comments

Comments
 (0)