config: add create_on_announce option
This option allows the user to specify whether or not to create a new swarm for torrents that do not previously exist within the tracker's storage.
This commit is contained in:
parent
0ecd126ae8
commit
80c068c97a
3 changed files with 4 additions and 1 deletions
|
@ -75,6 +75,7 @@ type WhitelistConfig struct {
|
|||
|
||||
// TrackerConfig is the configuration for tracker functionality.
|
||||
type TrackerConfig struct {
|
||||
CreateOnAnnounce bool `json:"create_on_announce"`
|
||||
PrivateEnabled bool `json:"private_enabled"`
|
||||
FreeleechEnabled bool `json:"freeleech_enabled"`
|
||||
PurgeInactiveTorrents bool `json:"purge_inactive_torrents"`
|
||||
|
@ -107,6 +108,7 @@ type Config struct {
|
|||
// DefaultConfig is a configuration that can be used as a fallback value.
|
||||
var DefaultConfig = Config{
|
||||
TrackerConfig: TrackerConfig{
|
||||
CreateOnAnnounce: true,
|
||||
PrivateEnabled: false,
|
||||
FreeleechEnabled: false,
|
||||
PurgeInactiveTorrents: true,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"create_on_announce": true,
|
||||
"private_enabled": false,
|
||||
"freeleech_enabled": false,
|
||||
"purge_inactive_torrents": true,
|
||||
|
|
|
@ -27,7 +27,7 @@ func (tkr *Tracker) HandleAnnounce(ann *models.Announce, w Writer) (err error) {
|
|||
|
||||
torrent, err := tkr.FindTorrent(ann.Infohash)
|
||||
|
||||
if err == models.ErrTorrentDNE && !tkr.Config.PrivateEnabled {
|
||||
if err == models.ErrTorrentDNE && cfg.CreateOnAnnounce {
|
||||
torrent = &models.Torrent{
|
||||
Infohash: ann.Infohash,
|
||||
Seeders: models.NewPeerMap(true, tkr.Config),
|
||||
|
|
Loading…
Reference in a new issue