0

That's how I programmatically Connect to an FTP server: Python code

ftp = ftplib.FTP (settings.FTP_IP)
ftp.login (settings.FTP_LOGIN, settings.FTP_PASS)
# ...
# here I upload files to the server
# ...
ftp.quit ()

But just as things with IPv4. But how to connect to the server via IPv6? I watched some liby, tried to put them in the shell, connect, but alas, it did not work.

Tell me if anyone has dealt with this.

Dmitriy
  • 211
  • 2
  • 10

1 Answers1

0

After looking at the code of ftplib.py, it seems to me that the code is absolutely ready for IPv6.

The library knows about EPSV and EPRT and uses them where appropriate.

E.g.,

def makepasv(self):
    if self.af == socket.AF_INET:
        host, port = parse227(self.sendcmd('PASV'))
    else:
        host, port = parse229(self.sendcmd('EPSV'), self.sock.getpeername())
    return host, port

shows that it sends a PASV or an EPSV depending on which IP version we use.

glglgl
  • 89,107
  • 13
  • 149
  • 217