github.com/divyam234/rclone@v1.64.1/cmd/serve/dlna/dlnaflags/dlnaflags.go (about)

     1  // Package dlnaflags provides utility functionality to DLNA.
     2  package dlnaflags
     3  
     4  import (
     5  	"time"
     6  
     7  	"github.com/divyam234/rclone/fs/config/flags"
     8  	"github.com/divyam234/rclone/fs/rc"
     9  	"github.com/spf13/pflag"
    10  )
    11  
    12  // Help contains the text for the command line help and manual.
    13  var Help = `
    14  ### Server options
    15  
    16  Use ` + "`--addr`" + ` to specify which IP address and port the server should
    17  listen on, e.g. ` + "`--addr 1.2.3.4:8000` or `--addr :8080`" + ` to listen to all
    18  IPs.
    19  
    20  Use ` + "`--name`" + ` to choose the friendly server name, which is by
    21  default "rclone (hostname)".
    22  
    23  Use ` + "`--log-trace` in conjunction with `-vv`" + ` to enable additional debug
    24  logging of all UPNP traffic.
    25  `
    26  
    27  // Options is the type for DLNA serving options.
    28  type Options struct {
    29  	ListenAddr       string
    30  	FriendlyName     string
    31  	LogTrace         bool
    32  	InterfaceNames   []string
    33  	AnnounceInterval time.Duration
    34  }
    35  
    36  // DefaultOpt contains the defaults options for DLNA serving.
    37  var DefaultOpt = Options{
    38  	ListenAddr:       ":7879",
    39  	FriendlyName:     "",
    40  	LogTrace:         false,
    41  	InterfaceNames:   []string{},
    42  	AnnounceInterval: 12 * time.Minute,
    43  }
    44  
    45  // Opt contains the options for DLNA serving.
    46  var (
    47  	Opt = DefaultOpt
    48  )
    49  
    50  func addFlagsPrefix(flagSet *pflag.FlagSet, prefix string, Opt *Options) {
    51  	rc.AddOption("dlna", &Opt)
    52  	flags.StringVarP(flagSet, &Opt.ListenAddr, prefix+"addr", "", Opt.ListenAddr, "The ip:port or :port to bind the DLNA http server to", prefix)
    53  	flags.StringVarP(flagSet, &Opt.FriendlyName, prefix+"name", "", Opt.FriendlyName, "Name of DLNA server", prefix)
    54  	flags.BoolVarP(flagSet, &Opt.LogTrace, prefix+"log-trace", "", Opt.LogTrace, "Enable trace logging of SOAP traffic", prefix)
    55  	flags.StringArrayVarP(flagSet, &Opt.InterfaceNames, prefix+"interface", "", Opt.InterfaceNames, "The interface to use for SSDP (repeat as necessary)", prefix)
    56  	flags.DurationVarP(flagSet, &Opt.AnnounceInterval, prefix+"announce-interval", "", Opt.AnnounceInterval, "The interval between SSDP announcements", prefix)
    57  }
    58  
    59  // AddFlags add the command line flags for DLNA serving.
    60  func AddFlags(flagSet *pflag.FlagSet) {
    61  	addFlagsPrefix(flagSet, "", &Opt)
    62  }