亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

Chinaunix

標(biāo)題: :wink: 使用pyftpdlib 時發(fā)生錯誤 [打印本頁]

作者: nmweizi    時間: 2012-11-16 09:22
標(biāo)題: :wink: 使用pyftpdlib 時發(fā)生錯誤
環(huán)境  python 2.7   pyftpdlib 0.7.0  ubuntu 12.04
執(zhí)行python ftps-server.py

用 python 2.7 帶的ftplib就可以
In [1]: from ftplib import FTP_TLS

In [2]: ftps = FTP_TLS('127.0.0.1','user','bbbb')

error_perm: 530 Authentication failed.

使用lftp 登錄  ftps時提示錯誤
lftp ftps://fa:aa@127.0.0.1:21

lftp fa@127.0.0.1:~> ls
ls: Fatal error: gnutls_handshake: A TLS packet with unexpected length was received.
大家?guī)兔纯词裁丛蛄耍?img src="static/image/smiley/default/icon_question.gif" smilieid="63" border="0" alt="" />




















ftps_server.py代碼如下:
  1. from pyftpdlib import ftpserver
  2. from pyftpdlib.contrib.handlers import TLS_FTPHandler,FTPHandler
  3. import md5



  4. class MyHandler(TLS_FTPHandler):

  5.     def on_login(self, username):
  6.         # do something when user login
  7.         print 'username:%s' % username
  8.        
  9.         def on_login_failed(self, username, password):
  10.                 print 'afasfd-----------------------------------'
  11.                 print 'password:%s' % password

  12.     def on_logout(self, username):
  13.         # do something when user logs out
  14.         pass
  15.         
  16.     def on_file_sent(self, file):
  17.         # do something when a file has been sent
  18.         pass

  19.     def on_file_received(self, file):
  20.         # do something when a file has been received
  21.         pass
  22.             
  23.     def on_incomplete_file_sent(self, file):
  24.         # do something when a file is partially sent
  25.         pass

  26.     def on_incomplete_file_received(self, file):
  27.         # remove partially uploaded files
  28.         pass
  29.                
  30.                


  31. authorizer = ftpserver.DummyAuthorizer()
  32. authorizer.add_user('user', '12345', '.', perm='elradfmw')


  33. #authorizer.add_anonymous('.')
  34. handler = MyHandler
  35. handler.certfile = 'keycert.pem'

  36. handler.authorizer = authorizer
  37.     # requires SSL for both control and data channel
  38.     #handler.tls_control_required = True
  39.     #handler.tls_data_required = True
  40. ftpd1 = ftpserver.FTPServer(('127.0.0.1', 21), handler)

  41. ftpd1.serve_forever()
復(fù)制代碼

作者: nmweizi    時間: 2012-11-16 21:23
搞定。
lftp ftp://fa:aa@127.0.0.1:21



不知到為什么會這樣?
那位高人能幫助解釋一下啊




歡迎光臨 Chinaunix (http://www.72891.cn/) Powered by Discuz! X3.2