Created
February 27, 2019 07:43
-
-
Save romanbsd/9acdd96cc37212d1f57a1d588449b5a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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