pyftpdlib的API

pyftpdlib.authorizers.DummyAuthorizer
add_anonymous(homedir, **kwargs)
remove_user(username)
add_user(username,password,homedir,perm=”elr”,msg_login=”Login successful.”, msg_quit=”Goodbye.”)
Read permissions:
“e” = change directory (CWD, CDUP commands)
“l” = list files (LIST, NLST, STAT, MLSD, MLST, SIZE commands)
“r” = retrieve file from the server (RETR command)
Write permissions:
“a” = append data to an existing file (APPE command)
“d” = delete file or directory (DELE, RMD commands)
“f” = rename file or directory (RNFR, RNTO commands)
“m” = create directory (MKD command)
“w” = store a file to the server (STOR, STOU commands)
“M” = change mode/permission (SITE CHMOD command) New in 0.7.0
class pyftpdlib.handlers.FTPHandler(conn, server)
timeout
客户端长时间没反应,就断开连接,默认300秒
banner
连接时给客户端返回的信息,可以自己设置
max_login_attempts
要是一直登陆错误,就断开(防止暴力攻击)
permit_foreign_addresses
是否启用FXP特性,也就是文件交换协议,从此FTP服务器到另外的FTP服务器,默认False
masquerade_address
伪装IP,也就是被动模式,用于NAT之后,比喻服务器在防火墙、路由器后面的情况,默认不开启
passive_ports
被动传输时指定端口,参数是一个整数列表,默认关闭
use_gmt_times
使用格林尼治时间,默认是True
tcp_no_delay
默认是True,废除拥塞控制,以加快速度
on_connect()
客户端连接时调用
on_disconnect()
客户端断开时调用
on_login(username)
用户登录时调用
on_login_failed(username, password)
用户登录失败时调用
on_file_sent(file)
传输成功时调用,file就是文件名
on_file_received(file)
接受成功时候调用,file就是文件名
on_incomplete_file_sent(file)
没有被完整发送的时候调用
on_incomplete_file_received(file)
没有完整接受的时候调用
class pyftpdlib.handlers.DTPHandler(sock_obj, cmd_channel)
sock_obj 是新建的socket类实例,cmd_channel是pyftpdlib.handlers.FTPHandler的类实例

timeout

ac_in_buffer_size

ac_out_buffer_size

数据接受或者传输时候的缓冲大小,默认65536字节

class pyftpdlib.handlers.ThrottledDTPHandler(sock_obj, cmd_channel)
read_limit
默认是0,代表不限制接受速度
write_limit
默认是0,不限制发送速度
class pyftpdlib.servers.FTPServer(address_or_socket, handler, ioloop=None, backlog=100)
max_cons
最大连接数,默认是512
max_cons_per_ip
每个IP的最大连接数,默认值是0,代表没有限制
serve_forever(timeout=None, blocking=True, handle_exit=True)
启动服务器
close()
关闭当前连接
close_all()
关闭所有的连接
class pyftpdlib.filesystems.AbstractedFS(root, cmd_channel)
root
用户的主目录
cwd
用户的当前工作目录

validpath(path)

检查path是否属于用户的目录,如果不是,就返回False

open(filename, mode)

封装了open()函数

mkdir(path)

chdir(path)
listdir(path)
rmdir(path)
remove(path)
rename(src, dst)
chmod(path, mode)
stat(path)
lstat(path)
readlink(path)
功能和os模块相同

isfile(path)
islink(path)
isdir(path)
getsize(path)
getmtime(path)
realpath(path)

lexists(path)
功能和os.path模块相同

mkstemp(suffix=”, prefix=”, dir=None, mode=’wb’)

封装了 tempfile.mkstemp.

class pyftpdlib.handlers.TLS_FTPHandler(conn, server)
用于实现身份验证,采用openssl, PyOpenSSL模块需要先安装

certfile

包含证书的文件路径,必须指定

keyfile

私钥的路径

tls_control_required

默认False,,为True的时候,建立加密控制通道,但要先认证

tls_data_required

默认False,,为True的时候,建立加密数据传输通道,但要先确定端口

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值