httpd

package
v0.0.0-...-9964dcd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2020 License: GPL-3.0 Imports: 30 Imported by: 0

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

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

func CloseConnection(connectionID string, expectedStatusCode int) ([]byte, error)

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

func GetHTTPRouter() http.Handler

GetHTTPRouter returns the configured HTTP handler

func GetProviderStatus

func GetProviderStatus(expectedStatusCode int) (map[string]interface{}, []byte, error)

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

func GetUserByID(userID int64, expectedStatusCode int) (dataprovider.User, []byte, error)

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

func (c Conf) Initialize(configDir string) error

Initialize the HTTP server

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL