2022-08-28 11:21:57 +00:00
|
|
|
// Package httpflags provides utility functionality to HTTP.
|
2018-02-15 15:01:19 +00:00
|
|
|
package httpflags
|
|
|
|
|
|
|
|
import (
|
2019-07-28 17:47:38 +00:00
|
|
|
"github.com/rclone/rclone/cmd/serve/httplib"
|
|
|
|
"github.com/rclone/rclone/fs/config/flags"
|
|
|
|
"github.com/rclone/rclone/fs/rc"
|
2018-02-15 15:01:19 +00:00
|
|
|
"github.com/spf13/pflag"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Options set by command line flags
|
|
|
|
var (
|
|
|
|
Opt = httplib.DefaultOpt
|
|
|
|
)
|
|
|
|
|
2018-03-05 11:43:05 +00:00
|
|
|
// AddFlagsPrefix adds flags for the httplib
|
|
|
|
func AddFlagsPrefix(flagSet *pflag.FlagSet, prefix string, Opt *httplib.Options) {
|
2018-10-27 22:58:18 +00:00
|
|
|
rc.AddOption(prefix+"http", &Opt)
|
2021-08-16 09:30:01 +00:00
|
|
|
flags.StringVarP(flagSet, &Opt.ListenAddr, prefix+"addr", "", Opt.ListenAddr, "IPaddress:Port or :Port to bind server to")
|
2018-03-05 11:43:05 +00:00
|
|
|
flags.DurationVarP(flagSet, &Opt.ServerReadTimeout, prefix+"server-read-timeout", "", Opt.ServerReadTimeout, "Timeout for server reading data")
|
|
|
|
flags.DurationVarP(flagSet, &Opt.ServerWriteTimeout, prefix+"server-write-timeout", "", Opt.ServerWriteTimeout, "Timeout for server writing data")
|
|
|
|
flags.IntVarP(flagSet, &Opt.MaxHeaderBytes, prefix+"max-header-bytes", "", Opt.MaxHeaderBytes, "Maximum size of request header")
|
|
|
|
flags.StringVarP(flagSet, &Opt.SslCert, prefix+"cert", "", Opt.SslCert, "SSL PEM key (concatenation of certificate and CA certificate)")
|
|
|
|
flags.StringVarP(flagSet, &Opt.SslKey, prefix+"key", "", Opt.SslKey, "SSL PEM Private key")
|
|
|
|
flags.StringVarP(flagSet, &Opt.ClientCA, prefix+"client-ca", "", Opt.ClientCA, "Client certificate authority to verify clients with")
|
|
|
|
flags.StringVarP(flagSet, &Opt.HtPasswd, prefix+"htpasswd", "", Opt.HtPasswd, "htpasswd file - if not provided no authentication is done")
|
2021-12-30 12:27:03 +00:00
|
|
|
flags.StringVarP(flagSet, &Opt.Realm, prefix+"realm", "", Opt.Realm, "Realm for authentication")
|
2021-08-16 09:30:01 +00:00
|
|
|
flags.StringVarP(flagSet, &Opt.BasicUser, prefix+"user", "", Opt.BasicUser, "User name for authentication")
|
|
|
|
flags.StringVarP(flagSet, &Opt.BasicPass, prefix+"pass", "", Opt.BasicPass, "Password for authentication")
|
|
|
|
flags.StringVarP(flagSet, &Opt.BaseURL, prefix+"baseurl", "", Opt.BaseURL, "Prefix for URLs - leave blank for root")
|
|
|
|
flags.StringVarP(flagSet, &Opt.Template, prefix+"template", "", Opt.Template, "User-specified template")
|
2019-08-20 18:47:57 +00:00
|
|
|
|
2018-03-05 11:43:05 +00:00
|
|
|
}
|
|
|
|
|
2018-02-15 15:01:19 +00:00
|
|
|
// AddFlags adds flags for the httplib
|
|
|
|
func AddFlags(flagSet *pflag.FlagSet) {
|
2018-03-05 11:43:05 +00:00
|
|
|
AddFlagsPrefix(flagSet, "", &Opt)
|
2018-02-15 15:01:19 +00:00
|
|
|
}
|