webdavd

package
v2.0.0-...-83f77b2 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2022 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Overview

Package webdavd implements the WebDAV protocol

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReloadCertificateMgr

func ReloadCertificateMgr() error

ReloadCertificateMgr reloads the certificate manager

Types

type Binding

type Binding struct {
	// The address to listen on. A blank value means listen on all available network interfaces.
	Address string `json:"address" mapstructure:"address"`
	// The port used for serving requests
	Port int `json:"port" mapstructure:"port"`
	// you also need to provide a certificate for enabling HTTPS
	EnableHTTPS bool `json:"enable_https" mapstructure:"enable_https"`
	// Certificate and matching private key for this specific binding, if empty the global
	// ones will be used, if any
	CertificateFile    string `json:"certificate_file" mapstructure:"certificate_file"`
	CertificateKeyFile string `json:"certificate_key_file" mapstructure:"certificate_key_file"`
	// Defines the minimum TLS version. 13 means TLS 1.3, default is TLS 1.2
	MinTLSVersion int `json:"min_tls_version" mapstructure:"min_tls_version"`
	// set to 1 to require client certificate authentication in addition to basic auth.
	// You need to define at least a certificate authority for this to work
	ClientAuthType int `json:"client_auth_type" mapstructure:"client_auth_type"`
	// TLSCipherSuites is a list of supported cipher suites for TLS version 1.2.
	// If CipherSuites is nil/empty, a default list of secure cipher suites
	// is used, with a preference order based on hardware performance.
	// Note that TLS 1.3 ciphersuites are not configurable.
	// The supported ciphersuites names are defined here:
	//
	// https://github.com/golang/go/blob/master/src/crypto/tls/cipher_suites.go#L52
	//
	// any invalid name will be silently ignored.
	// The order matters, the ciphers listed first will be the preferred ones.
	TLSCipherSuites []string `json:"tls_cipher_suites" mapstructure:"tls_cipher_suites"`
	// Prefix for WebDAV resources, if empty WebDAV resources will be available at the
	// root ("/") URI. If defined it must be an absolute URI.
	Prefix string `json:"prefix" mapstructure:"prefix"`
	// List of IP addresses and IP ranges allowed to set client IP proxy headers
	ProxyAllowed []string `json:"proxy_allowed" mapstructure:"proxy_allowed"`
	// Allowed client IP proxy header such as "X-Forwarded-For", "X-Real-IP"
	ClientIPProxyHeader string `json:"client_ip_proxy_header" mapstructure:"client_ip_proxy_header"`
	// Some client IP headers such as "X-Forwarded-For" can contain multiple IP address, this setting
	// define the position to trust starting from the right. For example if we have:
	// "10.0.0.1,11.0.0.1,12.0.0.1,13.0.0.1" and the depth is 0, SFTPGo will use "13.0.0.1"
	// as client IP, if depth is 1, "12.0.0.1" will be used and so on
	ClientIPHeaderDepth int `json:"client_ip_header_depth" mapstructure:"client_ip_header_depth"`
	// Do not add the WWW-Authenticate header after an authentication error,
	// only the 401 status code will be sent
	DisableWWWAuthHeader bool `json:"disable_www_auth_header" mapstructure:"disable_www_auth_header"`
	// contains filtered or unexported fields
}

Binding defines the configuration for a network listener

func (*Binding) GetAddress

func (b *Binding) GetAddress() string

GetAddress returns the binding address

func (*Binding) IsValid

func (b *Binding) IsValid() bool

IsValid returns true if the binding port is > 0

type Cache

type Cache struct {
	Users     UsersCacheConfig `json:"users" mapstructure:"users"`
	MimeTypes MimeCacheConfig  `json:"mime_types" mapstructure:"mime_types"`
}

Cache configuration

type Configuration

type Configuration struct {
	// Addresses and ports to bind to
	Bindings []Binding `json:"bindings" mapstructure:"bindings"`
	// If files containing a certificate and matching private key for the server are provided you
	// can enable HTTPS connections for the configured bindings
	// 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"`
	// CACertificates defines the set of root certificate authorities to be used to verify client certificates.
	CACertificates []string `json:"ca_certificates" mapstructure:"ca_certificates"`
	// CARevocationLists defines a set a revocation lists, one for each root CA, to be used to check
	// if a client certificate has been revoked
	CARevocationLists []string `json:"ca_revocation_lists" mapstructure:"ca_revocation_lists"`
	// CORS configuration
	Cors CorsConfig `json:"cors" mapstructure:"cors"`
	// Cache configuration
	Cache Cache `json:"cache" mapstructure:"cache"`
}

Configuration defines the configuration for the WevDAV server

func (*Configuration) Initialize

func (c *Configuration) Initialize(configDir string) error

Initialize configures and starts the WebDAV server

func (*Configuration) ShouldBind

func (c *Configuration) ShouldBind() bool

ShouldBind returns true if there is at least a valid binding

type Connection

type Connection struct {
	*common.BaseConnection
	// contains filtered or unexported fields
}

Connection details for a WebDav connection.

func (*Connection) Disconnect

func (c *Connection) Disconnect() error

Disconnect closes the active transfer

func (*Connection) GetClientVersion

func (c *Connection) GetClientVersion() string

GetClientVersion returns the connected client's version.

func (*Connection) GetCommand

func (c *Connection) GetCommand() string

GetCommand returns the request method

func (*Connection) GetLocalAddress

func (c *Connection) GetLocalAddress() string

GetLocalAddress returns local connection address

func (*Connection) GetRemoteAddress

func (c *Connection) GetRemoteAddress() string

GetRemoteAddress returns the connected client's address

func (*Connection) Mkdir

func (c *Connection) Mkdir(ctx context.Context, name string, perm os.FileMode) error

Mkdir creates a directory using the connection filesystem

func (*Connection) OpenFile

func (c *Connection) OpenFile(ctx context.Context, name string, flag int, perm os.FileMode) (webdav.File, error)

OpenFile opens the named file with specified flag. This method is used for uploads and downloads but also for Stat and Readdir

func (*Connection) RemoveAll

func (c *Connection) RemoveAll(ctx context.Context, name string) error

RemoveAll removes path and any children it contains. If the path does not exist, RemoveAll returns nil (no error).

func (*Connection) Rename

func (c *Connection) Rename(ctx context.Context, oldName, newName string) error

Rename renames a file or a directory

func (*Connection) Stat

func (c *Connection) Stat(ctx context.Context, name string) (os.FileInfo, error)

Stat returns a FileInfo describing the named file/directory, or an error, if any happens

type CorsConfig

type CorsConfig struct {
	AllowedOrigins       []string `json:"allowed_origins" mapstructure:"allowed_origins"`
	AllowedMethods       []string `json:"allowed_methods" mapstructure:"allowed_methods"`
	AllowedHeaders       []string `json:"allowed_headers" mapstructure:"allowed_headers"`
	ExposedHeaders       []string `json:"exposed_headers" mapstructure:"exposed_headers"`
	AllowCredentials     bool     `json:"allow_credentials" mapstructure:"allow_credentials"`
	Enabled              bool     `json:"enabled" mapstructure:"enabled"`
	MaxAge               int      `json:"max_age" mapstructure:"max_age"`
	OptionsPassthrough   bool     `json:"options_passthrough" mapstructure:"options_passthrough"`
	OptionsSuccessStatus int      `json:"options_success_status" mapstructure:"options_success_status"`
	AllowPrivateNetwork  bool     `json:"allow_private_network" mapstructure:"allow_private_network"`
}

CorsConfig defines the CORS configuration

type MimeCacheConfig

type MimeCacheConfig struct {
	Enabled bool `json:"enabled" mapstructure:"enabled"`
	MaxSize int  `json:"max_size" mapstructure:"max_size"`
}

MimeCacheConfig defines the cache configuration for mime types

type ServiceStatus

type ServiceStatus struct {
	IsActive bool      `json:"is_active"`
	Bindings []Binding `json:"bindings"`
}

ServiceStatus defines the service status

func GetStatus

func GetStatus() ServiceStatus

GetStatus returns the server status

type UsersCacheConfig

type UsersCacheConfig struct {
	ExpirationTime int `json:"expiration_time" mapstructure:"expiration_time"`
	MaxSize        int `json:"max_size" mapstructure:"max_size"`
}

UsersCacheConfig defines the cache configuration for users

Jump to

Keyboard shortcuts

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