Config
#struct ConfigThe configuration of an FTP server.
| Name | Type | Description |
|---|---|---|
host | str = "0.0.0.0" | The address to listen on; 0.0.0.0 means every interface. |
port | int = 21 | The port to listen on; 21 by default, and 0 lets the system choose one. |
root | str = "." | The directory the clients see as /; nothing above it can be reached. |
allow_anonymous | bool = false | Lets clients log in as the anonymous user without a password; off by default. |
anonymous_user | str = "anonymous" | The name that counts as anonymous; anonymous by default. |
user | str = "" | The name of the one account that may log in with a password. |
password | str = "" | The password of that account. |
passive_start | int = 40000 | The first port of the range used for passive data connections; 40000 by default. |
passive_end | int = 40100 | The last port of that range; 40100 by default. |
tls_enabled | bool = false | Turns on FTPS; it needs cert_file and key_file as well. |
cert_file | str = "" | The path of the certificate in PEM form. |
key_file | str = "" | The path of the private key in PEM form. |
implicit_tls | bool = false | Expects TLS from the first byte of the connection, as implicit FTPS does. |
require_tls | bool = false | Refuses login until the connection has been encrypted. |
import ftpd
func main:
mut cfg := ftpd.NewConfig()
println cfg.host, cfg.port, cfg.root
println cfg.allow_anonymous, cfg.anonymous_user
println cfg.user == "", cfg.password == ""
println cfg.passive_start, cfg.passive_end
println cfg.tls_enabled, cfg.implicit_tls, cfg.require_tls
println cfg.cert_file == "", cfg.key_file == ""
cfg.user = "reports"
cfg.allow_anonymous = true
println cfg.user, cfg.allow_anonymous
end0.0.0.0 21 . false anonymous true true 40000 40100 false false false true true reports true