2019-01-03 22:23:50 +00:00
|
|
|
package dlnaflags
|
|
|
|
|
|
|
|
import (
|
2019-07-28 17:47:38 +00:00
|
|
|
"github.com/rclone/rclone/fs/config/flags"
|
|
|
|
"github.com/rclone/rclone/fs/rc"
|
2019-01-03 22:23:50 +00:00
|
|
|
"github.com/spf13/pflag"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Help contains the text for the command line help and manual.
|
|
|
|
var Help = `
|
|
|
|
### Server options
|
|
|
|
|
|
|
|
Use --addr to specify which IP address and port the server should
|
|
|
|
listen on, eg --addr 1.2.3.4:8000 or --addr :8080 to listen to all
|
|
|
|
IPs.
|
|
|
|
|
2019-05-26 18:51:22 +00:00
|
|
|
Use --name to choose the friendly server name, which is by
|
|
|
|
default "rclone (hostname)".
|
|
|
|
|
|
|
|
Use --log-trace in conjunction with -vv to enable additional debug
|
|
|
|
logging of all UPNP traffic.
|
2019-01-03 22:23:50 +00:00
|
|
|
`
|
|
|
|
|
|
|
|
// Options is the type for DLNA serving options.
|
|
|
|
type Options struct {
|
2019-05-26 18:51:22 +00:00
|
|
|
ListenAddr string
|
|
|
|
FriendlyName string
|
|
|
|
LogTrace bool
|
2019-01-03 22:23:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// DefaultOpt contains the defaults options for DLNA serving.
|
|
|
|
var DefaultOpt = Options{
|
2019-05-26 18:51:22 +00:00
|
|
|
ListenAddr: ":7879",
|
|
|
|
FriendlyName: "",
|
|
|
|
LogTrace: false,
|
2019-01-03 22:23:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Opt contains the options for DLNA serving.
|
|
|
|
var (
|
|
|
|
Opt = DefaultOpt
|
|
|
|
)
|
|
|
|
|
|
|
|
func addFlagsPrefix(flagSet *pflag.FlagSet, prefix string, Opt *Options) {
|
|
|
|
rc.AddOption("dlna", &Opt)
|
|
|
|
flags.StringVarP(flagSet, &Opt.ListenAddr, prefix+"addr", "", Opt.ListenAddr, "ip:port or :port to bind the DLNA http server to.")
|
2019-05-26 18:51:22 +00:00
|
|
|
flags.StringVarP(flagSet, &Opt.FriendlyName, prefix+"name", "", Opt.FriendlyName, "name of DLNA server")
|
|
|
|
flags.BoolVarP(flagSet, &Opt.LogTrace, prefix+"log-trace", "", Opt.LogTrace, "enable trace logging of SOAP traffic")
|
2019-01-03 22:23:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// AddFlags add the command line flags for DLNA serving.
|
|
|
|
func AddFlags(flagSet *pflag.FlagSet) {
|
|
|
|
addFlagsPrefix(flagSet, "", &Opt)
|
|
|
|
}
|