有没有办法在进入被动模式时检测到服务器返回其专用网络地址,并将其转换为公共地址?
我无法访问服务器。

>>> # Python 2.7.3rc2
>>> from ftplib import FTP_TLS
>>> ftps = FTP_TLS()
>>> ftps.set_debuglevel(2)
>>> ftps.connect("example.com", 123)
*get* '220 Welcome to Synchrony Gateway FTP server\r\n'
*resp* '220 Welcome to Synchrony Gateway FTP server'
'220 Welcome to Synchrony Gateway FTP server'

>>> ftps.auth()
*cmd* 'AUTH TLS'
*put* 'AUTH TLS\r\n'
*get* '234 Using authentication type TLS\r\n'
*resp* '234 Using authentication type TLS'
'234 Using authentication type TLS'

>>> ftps.login("foo", "***")
*cmd* 'AUTH TLS'
*put* 'AUTH TLS\r\n'
*get* '234 AUTH command OK, waiting handshake\r\n'
*resp* '234 AUTH command OK, waiting handshake'
*cmd* 'USER foo'
*put* 'USER foo\r\n'
*get* '331 Send password please\r\n'
*resp* '331 Send password please'
*cmd* 'PASS ************'
*put* 'PASS ************\r\n'
*get* '230 User logged in, proceed\r\n'
*resp* '230 User logged in, proceed'
'230 User logged in, proceed'

>>> ftps.prot_p()
*cmd* 'PBSZ 0'
*put* 'PBSZ 0\r\n'
*get* '200 Command okay\r\n'
*resp* '200 Command okay'
*cmd* 'PROT P'
*put* 'PROT P\r\n'
*get* '200 Command okay\r\n'
*resp* '200 Command okay'
'200 Command okay'

>>> ftps.set_pasv(True)
>>> ftps.retrlines("LIST")
*cmd* 'TYPE A'
*put* 'TYPE A\r\n'
*get* '200 Type set to A\r\n'
*resp* '200 Type set to A'
*cmd* 'PASV'
*put* 'PASV\r\n'
*get* '227 Entering Passive Mode (192,168,17,1,195,119)\r\n'
*resp* '227 Entering Passive Mode (192,168,17,1,195,119)'

谢谢。

最佳答案

将服务器配置为在外部IP上进入被动模式。

10-04 10:58