mirror of
https://github.com/rclone/rclone.git
synced 2025-02-02 03:29:51 +01:00
dlna: add SSDP AnnounceInterval flag option
The current default AnnounceInterval is too short, causing the multicast domain to be flooded with NOTIFY announcements, which may prevent other dlna devices from sleeping. This change allows users to set the announcement interval, and it's default value also increased to 12 minutes. Even within the interval, rclone can still passively respond to M-SEARCH requests from other devices.
This commit is contained in:
parent
4a35aff33c
commit
13b65104eb
@ -118,7 +118,7 @@ func newServer(f fs.Fs, opt *dlnaflags.Options) (*server, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s := &server{
|
s := &server{
|
||||||
AnnounceInterval: 10 * time.Second,
|
AnnounceInterval: opt.AnnounceInterval,
|
||||||
FriendlyName: friendlyName,
|
FriendlyName: friendlyName,
|
||||||
RootDeviceUUID: makeDeviceUUID(friendlyName),
|
RootDeviceUUID: makeDeviceUUID(friendlyName),
|
||||||
Interfaces: interfaces,
|
Interfaces: interfaces,
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
package dlnaflags
|
package dlnaflags
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/rclone/rclone/fs/config/flags"
|
"github.com/rclone/rclone/fs/config/flags"
|
||||||
"github.com/rclone/rclone/fs/rc"
|
"github.com/rclone/rclone/fs/rc"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
@ -24,18 +26,20 @@ logging of all UPNP traffic.
|
|||||||
|
|
||||||
// Options is the type for DLNA serving options.
|
// Options is the type for DLNA serving options.
|
||||||
type Options struct {
|
type Options struct {
|
||||||
ListenAddr string
|
ListenAddr string
|
||||||
FriendlyName string
|
FriendlyName string
|
||||||
LogTrace bool
|
LogTrace bool
|
||||||
InterfaceNames []string
|
InterfaceNames []string
|
||||||
|
AnnounceInterval time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultOpt contains the defaults options for DLNA serving.
|
// DefaultOpt contains the defaults options for DLNA serving.
|
||||||
var DefaultOpt = Options{
|
var DefaultOpt = Options{
|
||||||
ListenAddr: ":7879",
|
ListenAddr: ":7879",
|
||||||
FriendlyName: "",
|
FriendlyName: "",
|
||||||
LogTrace: false,
|
LogTrace: false,
|
||||||
InterfaceNames: []string{},
|
InterfaceNames: []string{},
|
||||||
|
AnnounceInterval: 12 * time.Minute,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Opt contains the options for DLNA serving.
|
// Opt contains the options for DLNA serving.
|
||||||
@ -49,6 +53,7 @@ func addFlagsPrefix(flagSet *pflag.FlagSet, prefix string, Opt *Options) {
|
|||||||
flags.StringVarP(flagSet, &Opt.FriendlyName, prefix+"name", "", Opt.FriendlyName, "Name of DLNA server")
|
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")
|
flags.BoolVarP(flagSet, &Opt.LogTrace, prefix+"log-trace", "", Opt.LogTrace, "Enable trace logging of SOAP traffic")
|
||||||
flags.StringArrayVarP(flagSet, &Opt.InterfaceNames, prefix+"interface", "", Opt.InterfaceNames, "The interface to use for SSDP (repeat as necessary)")
|
flags.StringArrayVarP(flagSet, &Opt.InterfaceNames, prefix+"interface", "", Opt.InterfaceNames, "The interface to use for SSDP (repeat as necessary)")
|
||||||
|
flags.DurationVarP(flagSet, &Opt.AnnounceInterval, prefix+"announce-interval", "", Opt.AnnounceInterval, "The interval between SSDP announcements")
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddFlags add the command line flags for DLNA serving.
|
// AddFlags add the command line flags for DLNA serving.
|
||||||
|
@ -32,6 +32,11 @@ IPs.
|
|||||||
Use `--name` to choose the friendly server name, which is by
|
Use `--name` to choose the friendly server name, which is by
|
||||||
default "rclone (hostname)".
|
default "rclone (hostname)".
|
||||||
|
|
||||||
|
Use `--announce-interval` to specify the interval at which SSDP server
|
||||||
|
announce devices and services. Larger active announcement intervals help
|
||||||
|
keep the multicast domain clean, this value does not affect unicast
|
||||||
|
responses to `M-SEARCH` requests from other devices.
|
||||||
|
|
||||||
Use `--log-trace` in conjunction with `-vv` to enable additional debug
|
Use `--log-trace` in conjunction with `-vv` to enable additional debug
|
||||||
logging of all UPNP traffic.
|
logging of all UPNP traffic.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user