Skip to content

Instantly share code, notes, and snippets.

@romanbsd
Created February 27, 2019 07:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save romanbsd/9acdd96cc37212d1f57a1d588449b5a0 to your computer and use it in GitHub Desktop.
Save romanbsd/9acdd96cc37212d1f57a1d588449b5a0 to your computer and use it in GitHub Desktop.
from ftplib import FTP, parse227, parse229
import socket
class BetterFTP(FTP):
def makepasv(self):
if self.af == socket.AF_INET:
_, port = parse227(self.sendcmd('PASV'))
else:
_, port = parse229(self.sendcmd('EPSV'), self.sock.getpeername())
return self.host, port
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment