Documentation
¶
Overview ¶
Package httpd implements REST API and Web interface for SFTPGo. REST API allows to manage users and quota and to get real time reports for the active connections with possibility of forcibly closing a connection. The OpenAPI 3 schema for the exposed API can be found inside the source tree: https://github.com/freshvolk/sftpgo/tree/master/api/schema/openapi.yaml A basic Web interface to manage users and connections is provided too
Index ¶
- func AddUser(user dataprovider.User, expectedStatusCode int) (dataprovider.User, []byte, error)
- func CloseConnection(connectionID string, expectedStatusCode int) ([]byte, error)
- func Dumpdata(outputFile, indent string, expectedStatusCode int) (map[string]interface{}, []byte, error)
- func GetConnections(expectedStatusCode int) ([]sftpd.ConnectionStatus, []byte, error)
- func GetHTTPRouter() http.Handler
- func GetProviderStatus(expectedStatusCode int) (map[string]interface{}, []byte, error)
- func GetQuotaScans(expectedStatusCode int) ([]sftpd.ActiveQuotaScan, []byte, error)
- func GetUserByID(userID int64, expectedStatusCode int) (dataprovider.User, []byte, error)
- func GetUsers(limit int64, offset int64, username string, expectedStatusCode int) ([]dataprovider.User, []byte, error)
- func GetVersion(expectedStatusCode int) (utils.VersionInfo, []byte, error)
- func Loaddata(inputFile, scanQuota, mode string, expectedStatusCode int) (map[string]interface{}, []byte, error)
- func ReloadTLSCertificate()
- func RemoveUser(user dataprovider.User, expectedStatusCode int) ([]byte, error)
- func SetBaseURLAndCredentials(url, username, password string)
- func SetDataProvider(provider dataprovider.Provider)
- func StartQuotaScan(user dataprovider.User, expectedStatusCode int) ([]byte, error)
- func UpdateUser(user dataprovider.User, expectedStatusCode int) (dataprovider.User, []byte, error)
- type Conf
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddUser ¶
func AddUser(user dataprovider.User, expectedStatusCode int) (dataprovider.User, []byte, error)
AddUser adds a new user and checks the received HTTP Status code against expectedStatusCode.
func CloseConnection ¶
CloseConnection closes an active connection identified by connectionID
func Dumpdata ¶
func Dumpdata(outputFile, indent string, expectedStatusCode int) (map[string]interface{}, []byte, error)
Dumpdata requests a backup to outputFile. outputFile is relative to the configured backups_path
func GetConnections ¶
func GetConnections(expectedStatusCode int) ([]sftpd.ConnectionStatus, []byte, error)
GetConnections returns status and stats for active SFTP/SCP connections
func GetHTTPRouter ¶
GetHTTPRouter returns the configured HTTP handler
func GetProviderStatus ¶
GetProviderStatus returns provider status
func GetQuotaScans ¶
func GetQuotaScans(expectedStatusCode int) ([]sftpd.ActiveQuotaScan, []byte, error)
GetQuotaScans gets active quota scans and checks the received HTTP Status code against expectedStatusCode.
func GetUserByID ¶
GetUserByID gets an user by database id and checks the received HTTP Status code against expectedStatusCode.
func GetUsers ¶
func GetUsers(limit int64, offset int64, username string, expectedStatusCode int) ([]dataprovider.User, []byte, error)
GetUsers allows to get a list of users and checks the received HTTP Status code against expectedStatusCode. The number of results can be limited specifying a limit. Some results can be skipped specifying an offset. The results can be filtered specifying an username, the username filter is an exact match
func GetVersion ¶
func GetVersion(expectedStatusCode int) (utils.VersionInfo, []byte, error)
GetVersion returns version details
func Loaddata ¶
func Loaddata(inputFile, scanQuota, mode string, expectedStatusCode int) (map[string]interface{}, []byte, error)
Loaddata restores a backup. New users are added, existing users are updated. Users will be restored one by one and the restore is stopped if a user cannot be added/updated, so it could happen a partial restore
func ReloadTLSCertificate ¶
func ReloadTLSCertificate()
ReloadTLSCertificate reloads the TLS certificate and key from the configured paths
func RemoveUser ¶
func RemoveUser(user dataprovider.User, expectedStatusCode int) ([]byte, error)
RemoveUser removes an existing user and checks the received HTTP Status code against expectedStatusCode.
func SetBaseURLAndCredentials ¶
func SetBaseURLAndCredentials(url, username, password string)
SetBaseURLAndCredentials sets the base url and the optional credentials to use for HTTP requests. Default URL is "http://127.0.0.1:8080" with empty credentials
func SetDataProvider ¶
func SetDataProvider(provider dataprovider.Provider)
SetDataProvider sets the data provider to use to fetch the data about users
func StartQuotaScan ¶
func StartQuotaScan(user dataprovider.User, expectedStatusCode int) ([]byte, error)
StartQuotaScan start a new quota scan for the given user and checks the received HTTP Status code against expectedStatusCode.
func UpdateUser ¶
func UpdateUser(user dataprovider.User, expectedStatusCode int) (dataprovider.User, []byte, error)
UpdateUser updates an existing user and checks the received HTTP Status code against expectedStatusCode.
Types ¶
type Conf ¶
type Conf struct { // The port used for serving HTTP requests. 0 disable the HTTP server. Default: 8080 BindPort int `json:"bind_port" mapstructure:"bind_port"` // The address to listen on. A blank value means listen on all available network interfaces. Default: "127.0.0.1" BindAddress string `json:"bind_address" mapstructure:"bind_address"` // Path to the HTML web templates. This can be an absolute path or a path relative to the config dir TemplatesPath string `json:"templates_path" mapstructure:"templates_path"` // Path to the static files for the web interface. This can be an absolute path or a path relative to the config dir StaticFilesPath string `json:"static_files_path" mapstructure:"static_files_path"` // Path to the backup directory. This can be an absolute path or a path relative to the config dir BackupsPath string `json:"backups_path" mapstructure:"backups_path"` // Path to a file used to store usernames and password for basic authentication. // This can be an absolute path or a path relative to the config dir. // We support HTTP basic authentication and the file format must conform to the one generated using the Apache // htpasswd tool. The supported password formats are bcrypt ($2y$ prefix) and md5 crypt ($apr1$ prefix). // If empty HTTP authentication is disabled AuthUserFile string `json:"auth_user_file" mapstructure:"auth_user_file"` // If files containing a certificate and matching private key for the server are provided the server will expect // HTTPS connections. // Certificate and key files can be reloaded on demand sending a "SIGHUP" signal on Unix based systems and a // "paramchange" request to the running service on Windows. CertificateFile string `json:"certificate_file" mapstructure:"certificate_file"` CertificateKeyFile string `json:"certificate_key_file" mapstructure:"certificate_key_file"` }
Conf httpd daemon configuration
func (Conf) Initialize ¶
Initialize the HTTP server