httpd

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2020 License: GPL-3.0 Imports: 33 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/drakkan/sftpgo/tree/master/api/schema/openapi.yaml A basic Web interface to manage users and connections is provided too

Index

Constants

View Source
const (

	// MaxRestoreSize defines the max size for the loaddata input file
	MaxRestoreSize = 10485760 // 10 MB

)

Variables

This section is empty.

Functions

func AddFolder

func AddFolder(folder vfs.BaseVirtualFolder, expectedStatusCode int) (vfs.BaseVirtualFolder, []byte, error)

AddFolder adds a new folder and checks the received HTTP Status code against expectedStatusCode

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) ([]common.ConnectionStatus, []byte, error)

GetConnections returns status and stats for active SFTP/SCP connections

func GetFolders

func GetFolders(limit int64, offset int64, mappedPath string, expectedStatusCode int) ([]vfs.BaseVirtualFolder, []byte, error)

GetFolders returns a list of folders 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 a folder path, the folder path filter is an exact match

func GetFoldersQuotaScans

func GetFoldersQuotaScans(expectedStatusCode int) ([]common.ActiveVirtualFolderQuotaScan, []byte, error)

GetFoldersQuotaScans gets active quota scans for folders and checks the received HTTP Status code against expectedStatusCode.

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) ([]common.ActiveQuotaScan, []byte, error)

GetQuotaScans gets active quota scans for users and checks the received HTTP Status code against expectedStatusCode.

func GetUserByID

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

GetUserByID gets a user by database id and checks the received HTTP Status code against expectedStatusCode.

func GetUsers

func GetUsers(limit, offset int64, username string, expectedStatusCode int) ([]dataprovider.User, []byte, error)

GetUsers returns 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 a username, the username filter is an exact match

func GetVersion

func GetVersion(expectedStatusCode int) (version.Info, []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() error

ReloadTLSCertificate reloads the TLS certificate and key from the configured paths

func RemoveFolder

func RemoveFolder(folder vfs.BaseVirtualFolder, expectedStatusCode int) ([]byte, error)

RemoveFolder removes an existing user and checks the received HTTP Status code against expectedStatusCode.

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 RestoreFolders added in v1.2.0

func RestoreFolders(folders []vfs.BaseVirtualFolder, inputFile string, scanQuota int) error

RestoreFolders restores the specified folders

func RestoreUsers added in v1.2.0

func RestoreUsers(users []dataprovider.User, inputFile string, mode, scanQuota int) error

RestoreUsers restores the specified users

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 StartFolderQuotaScan

func StartFolderQuotaScan(folder vfs.BaseVirtualFolder, expectedStatusCode int) ([]byte, error)

StartFolderQuotaScan start a new quota scan for the given folder and checks the received HTTP Status code against expectedStatusCode.

func StartQuotaScan

func StartQuotaScan(user dataprovider.User, expectedStatusCode int) ([]byte, error)

StartQuotaScan starts a new quota scan for the given user and checks the received HTTP Status code against expectedStatusCode.

func UpdateFolderQuotaUsage

func UpdateFolderQuotaUsage(folder vfs.BaseVirtualFolder, mode string, expectedStatusCode int) ([]byte, error)

UpdateFolderQuotaUsage updates the folder used quota limits and checks the received HTTP Status code against expectedStatusCode.

func UpdateQuotaUsage

func UpdateQuotaUsage(user dataprovider.User, mode string, expectedStatusCode int) ([]byte, error)

UpdateQuotaUsage updates the user used quota limits and checks the received HTTP Status code against expectedStatusCode.

func UpdateUser

func UpdateUser(user dataprovider.User, expectedStatusCode int, disconnect string) (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.
	// If both TemplatesPath and StaticFilesPath are empty the built-in web interface will be disabled
	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, enableProfiler bool) error

Initialize configures and starts the HTTP server

Jump to

Keyboard shortcuts

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