// Package webdavd implements the WebDAV protocol package webdavd import ( "path/filepath" "github.com/drakkan/sftpgo/logger" "github.com/drakkan/sftpgo/utils" ) type ctxReqParams int const ( requestIDKey ctxReqParams = iota requestStartKey ) const ( logSender = "webdavd" ) var ( server *webDavServer ) // Configuration defines the configuration for the WevDAV server type Configuration struct { // The port used for serving FTP requests BindPort int `json:"bind_port" mapstructure:"bind_port"` // The address to listen on. A blank value means listen on all available network interfaces. BindAddress string `json:"bind_address" mapstructure:"bind_address"` // 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"` } // Initialize configures and starts the WebDav server func (c *Configuration) Initialize(configDir string) error { var err error logger.Debug(logSender, "", "initializing WevDav server with config %+v", *c) server, err = newServer(c, configDir) if err != nil { return err } return server.listenAndServe() } // ReloadTLSCertificate reloads the TLS certificate and key from the configured paths func ReloadTLSCertificate() error { if server != nil && server.certMgr != nil { return server.certMgr.LoadCertificate(logSender) } return nil } func getConfigPath(name, configDir string) string { if !utils.IsFileInputValid(name) { return "" } if len(name) > 0 && !filepath.IsAbs(name) { return filepath.Join(configDir, name) } return name }