Something went wrong. Try again.
FTP for Zig 0.16: a client, a server, and the wire protocol as a layer you can use on its own, all built on std.Io.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940# SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie <jeff@ocjtech.us># SPDX-License-Identifier: MIT
"""A pyftpdlib server with one read-only anonymous account and one that can write.
Both accounts on one server rather than one each, because pyftpdlib'spermission model is per account and the point is to see the difference: thesame server, the same paths, and a `perm` fact in the machine listing that sayssomething different depending on who asked.
The letters are pyftpdlib's own: `e` enter a directory, `l` list one, `r`retrieve, `a` append, `d` delete, `f` rename, `m` make a directory, `w` store,`M` chmod, `T` set a modification time."""
import sys
from pyftpdlib.authorizers import DummyAuthorizerfrom pyftpdlib.handlers import FTPHandlerfrom pyftpdlib.servers import FTPServer
address, port = "127.0.0.1", int(sys.argv[1])
authorizer = DummyAuthorizer()authorizer.add_anonymous("/srv/pyftpdlib", perm="elr")authorizer.add_user("alice", "hunter2", "/srv/alice", perm="elradfmwMT")
handler = FTPHandlerhandler.authorizer = authorizerhandler.banner = "pyftpdlib for zig-ftp"# Pinned so the test knows where a passive data connection can land, and# because a server behind a firewall has to pin them anyway.handler.passive_ports = range(50000, 50100)# The default, set explicitly because it is the FTP bounce defence: an active# data connection may only go back to the host the control connection came# from.handler.permit_foreign_addresses = False
FTPServer((address, port), handler).serve_forever()