"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
lib/http: convert options to new style
Nick Craig-Woodcf25ae69adb0
diff --git a/lib/http/auth.go b/lib/http/auth.goindex 273d9068e..0c1137152 100644--- a/lib/http/auth.go+++ b/lib/http/auth.go@@ -5,6 +5,7 @@ import ("html/template""log"+ "github.com/rclone/rclone/fs""github.com/rclone/rclone/fs/config/flags""github.com/spf13/pflag")@@ -63,14 +64,37 @@ Use ` + "`--{{ .Prefix }}salt`" + ` to change the password hashing salt from the// If a non nil value is returned then it is added to the context under the keytype CustomAuthFn func(user, pass string) (value interface{}, err error)+// AuthConfigInfo descripts the Options in use+var AuthConfigInfo = fs.Options{{+ Name: "htpasswd",+ Default: "",+ Help: "A htpasswd file - if not provided no authentication is done",+}, {+ Name: "realm",+ Default: "",+ Help: "Realm for authentication",+}, {+ Name: "user",+ Default: "",+ Help: "User name for authentication",+}, {+ Name: "pass",+ Default: "",+ Help: "Password for authentication",+}, {+ Name: "salt",+ Default: "dlPL2MqE",+ Help: "Password hashing salt",+}}+// AuthConfig contains options for the http authenticationtype AuthConfig struct {- HtPasswd string // htpasswd file - if not provided no authentication is done- Realm string // realm for authentication- BasicUser string // single username for basic auth if not using Htpasswd- BasicPass string // password for BasicUser- Salt string // password hashing salt- CustomAuthFn CustomAuthFn `json:"-"` // custom Auth (not set by command line flags)+ HtPasswd string `config:"htpasswd"` // htpasswd file - if not provided no authentication is done+ Realm string `config:"realm"` // realm for authentication+ BasicUser string `config:"user"` // single username for basic auth if not using Htpasswd+ BasicPass string `config:"pass"` // password for BasicUser+ Salt string `config:"salt"` // password hashing salt+ CustomAuthFn CustomAuthFn `json:"-" config:"-"` // custom Auth (not set by command line flags)}// AddFlagsPrefix adds flags to the flag set for AuthConfig@@ -88,6 +112,9 @@ func AddAuthFlagsPrefix(flagSet *pflag.FlagSet, prefix string, cfg *AuthConfig)}// DefaultAuthCfg returns a new config which can be customized by command line flags+//+// Note that this needs to be kept in sync with AuthConfigInfo above and+// can be removed when all callers have been converted.func DefaultAuthCfg() AuthConfig {return AuthConfig{Salt: "dlPL2MqE",diff --git a/lib/http/server.go b/lib/http/server.goindex 3e782d2d4..ca76fcf52 100644--- a/lib/http/server.go+++ b/lib/http/server.go@@ -19,6 +19,7 @@ import ("time""github.com/go-chi/chi/v5"+ "github.com/rclone/rclone/fs""github.com/rclone/rclone/fs/config/flags""github.com/rclone/rclone/lib/atexit""github.com/spf13/pflag"@@ -96,20 +97,63 @@ certificate authority certificate.// Middleware function signature required by chi.Router.Use()type Middleware func(http.Handler) http.Handler+// ConfigInfo descripts the Options in use+var ConfigInfo = fs.Options{{+ Name: "addr",+ Default: []string{"127.0.0.1:8080"},+ Help: "IPaddress:Port or :Port to bind server to",+}, {+ Name: "server_read_timeout",+ Default: 1 * time.Hour,+ Help: "Timeout for server reading data",+}, {+ Name: "server_write_timeout",+ Default: 1 * time.Hour,+ Help: "Timeout for server writing data",+}, {+ Name: "max_header_bytes",+ Default: 4096,+ Help: "Maximum size of request header",+}, {+ Name: "cert",+ Default: "",+ Help: "TLS PEM key (concatenation of certificate and CA certificate)",+}, {+ Name: "key",+ Default: "",+ Help: "TLS PEM Private key",+}, {+ Name: "client_ca",+ Default: "",+ Help: "Client certificate authority to verify clients with",+}, {+ Name: "baseurl",+ Default: "",+ Help: "Prefix for URLs - leave blank for root",+}, {+ Name: "min_tls_version",+ Default: "tls1.0",+ Help: "Minimum TLS version that is acceptable",+}, {+ Name: "allow_origin",+ Default: "",+ Help: "Origin which cross-domain request (CORS) can be executed from",+}}+// Config contains options for the http Servertype Config struct {- ListenAddr []string // Port to listen on- BaseURL string // prefix to strip from URLs- ServerReadTimeout time.Duration // Timeout for server reading data- ServerWriteTimeout time.Duration // Timeout for server writing data- MaxHeaderBytes int // Maximum size of request header- TLSCert string // Path to TLS PEM key (concatenation of certificate and CA certificate)- TLSKey string // Path to TLS PEM Private key- TLSCertBody []byte // TLS PEM key (concatenation of certificate and CA certificate) body, ignores TLSCert- TLSKeyBody []byte // TLS PEM Private key body, ignores TLSKey- ClientCA string // Client certificate authority to verify clients with- MinTLSVersion string // MinTLSVersion contains the minimum TLS version that is acceptable.- AllowOrigin string // AllowOrigin sets the Access-Control-Allow-Origin header+ ListenAddr []string `config:"addr"` // Port to listen on+ BaseURL string `config:"baseurl"` // prefix to strip from URLs+ ServerReadTimeout time.Duration `config:"server_read_timeout"` // Timeout for server reading data+ ServerWriteTimeout time.Duration `config:"server_write_timeout"` // Timeout for server writing data+ MaxHeaderBytes int `config:"max_header_bytes"` // Maximum size of request header+ TLSCert string `config:"cert"` // Path to TLS PEM key (concatenation of certificate and CA certificate)+ TLSKey string `config:"key"` // Path to TLS PEM Private key+ TLSCertBody []byte `config:"-"` // TLS PEM key (concatenation of certificate and CA certificate) body, ignores TLSCert+ TLSKeyBody []byte `config:"-"` // TLS PEM Private key body, ignores TLSKey+ ClientCA string `config:"client_ca"` // Client certificate authority to verify clients with+ MinTLSVersion string `config:"min_tls_version"` // MinTLSVersion contains the minimum TLS version that is acceptable.+ AllowOrigin string `config:"allow_origin"` // AllowOrigin sets the Access-Control-Allow-Origin header}// AddFlagsPrefix adds flags for the httplib@@ -132,6 +176,9 @@ func AddHTTPFlagsPrefix(flagSet *pflag.FlagSet, prefix string, cfg *Config) {}// DefaultCfg is the default values used for Config+//+// Note that this needs to be kept in sync with ConfigInfo above and+// can be removed when all callers have been converted.func DefaultCfg() Config {return Config{ListenAddr: []string{"127.0.0.1:8080"},diff --git a/lib/http/template.go b/lib/http/template.goindex e46e06ba8..e36e44b80 100644--- a/lib/http/template.go+++ b/lib/http/template.go@@ -11,6 +11,7 @@ import ("github.com/spf13/pflag"+ "github.com/rclone/rclone/fs""github.com/rclone/rclone/fs/config/flags")@@ -72,9 +73,16 @@ be used to render HTML based on specific conditions.return buf.String()}+// TemplateConfigInfo descripts the Options in use+var TemplateConfigInfo = fs.Options{{+ Name: "template",+ Default: "",+ Help: "User-specified template",+}}+// TemplateConfig for the templating functionalitytype TemplateConfig struct {- Path string+ Path string `config:"template"`}// AddFlagsPrefix for the templating functionality@@ -88,6 +96,9 @@ func AddTemplateFlagsPrefix(flagSet *pflag.FlagSet, prefix string, cfg *Template}// DefaultTemplateCfg returns a new config which can be customized by command line flags+//+// Note that this needs to be kept in sync with TemplateConfigInfo above and+// can be removed when all callers have been converted.func DefaultTemplateCfg() TemplateConfig {return TemplateConfig{}}