2022-08-28 13:21:57 +02:00
// Package dlnaflags provides utility functionality to DLNA.
2019-01-03 23:23:50 +01:00
package dlnaflags
import (
2022-10-01 11:18:50 +02:00
"time"
2019-07-28 19:47:38 +02:00
"github.com/rclone/rclone/fs/config/flags"
"github.com/rclone/rclone/fs/rc"
2019-01-03 23:23:50 +01:00
"github.com/spf13/pflag"
)
// Help contains the text for the command line help and manual.
2024-04-05 13:27:33 +02:00
var Help = ` # # # Server options
2019-01-03 23:23:50 +01:00
2020-06-17 00:37:35 +02:00
Use ` + " ` -- addr ` " + ` to specify which IP address and port the server should
2020-10-13 23:49:58 +02:00
listen on , e . g . ` + " ` -- addr 1.2 .3 .4 : 8000 ` or ` -- addr : 8080 ` " + ` to listen to all
2019-01-03 23:23:50 +01:00
IPs .
2020-06-17 00:37:35 +02:00
Use ` + " ` -- name ` " + ` to choose the friendly server name , which is by
2019-05-26 20:51:22 +02:00
default "rclone (hostname)" .
2020-06-17 00:37:35 +02:00
Use ` + " ` -- log - trace ` in conjunction with ` - vv ` " + ` to enable additional debug
2019-05-26 20:51:22 +02:00
logging of all UPNP traffic .
2024-04-05 13:27:33 +02:00
2019-01-03 23:23:50 +01:00
`
// Options is the type for DLNA serving options.
type Options struct {
2022-10-01 11:18:50 +02:00
ListenAddr string
FriendlyName string
LogTrace bool
InterfaceNames [ ] string
AnnounceInterval time . Duration
2019-01-03 23:23:50 +01:00
}
// DefaultOpt contains the defaults options for DLNA serving.
var DefaultOpt = Options {
2022-10-01 11:18:50 +02:00
ListenAddr : ":7879" ,
FriendlyName : "" ,
LogTrace : false ,
InterfaceNames : [ ] string { } ,
AnnounceInterval : 12 * time . Minute ,
2019-01-03 23:23:50 +01:00
}
// Opt contains the options for DLNA serving.
var (
Opt = DefaultOpt
)
func addFlagsPrefix ( flagSet * pflag . FlagSet , prefix string , Opt * Options ) {
rc . AddOption ( "dlna" , & Opt )
2023-07-10 19:34:10 +02:00
flags . StringVarP ( flagSet , & Opt . ListenAddr , prefix + "addr" , "" , Opt . ListenAddr , "The ip:port or :port to bind the DLNA http server to" , prefix )
flags . StringVarP ( flagSet , & Opt . FriendlyName , prefix + "name" , "" , Opt . FriendlyName , "Name of DLNA server" , prefix )
flags . BoolVarP ( flagSet , & Opt . LogTrace , prefix + "log-trace" , "" , Opt . LogTrace , "Enable trace logging of SOAP traffic" , prefix )
flags . StringArrayVarP ( flagSet , & Opt . InterfaceNames , prefix + "interface" , "" , Opt . InterfaceNames , "The interface to use for SSDP (repeat as necessary)" , prefix )
flags . DurationVarP ( flagSet , & Opt . AnnounceInterval , prefix + "announce-interval" , "" , Opt . AnnounceInterval , "The interval between SSDP announcements" , prefix )
2019-01-03 23:23:50 +01:00
}
// AddFlags add the command line flags for DLNA serving.
func AddFlags ( flagSet * pflag . FlagSet ) {
addFlagsPrefix ( flagSet , "" , & Opt )
}