From 80c068c97aac7a08b2e5176ec0a777b2362464e7 Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Mon, 23 Mar 2015 20:02:13 -0400 Subject: [PATCH] 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. --- config/config.go | 2 ++ example_config.json | 1 + tracker/announce.go | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index 2e5c454..36b70e8 100644 --- a/config/config.go +++ b/config/config.go @@ -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, diff --git a/example_config.json b/example_config.json index d6e02c1..0340f23 100644 --- a/example_config.json +++ b/example_config.json @@ -1,4 +1,5 @@ { + "create_on_announce": true, "private_enabled": false, "freeleech_enabled": false, "purge_inactive_torrents": true, diff --git a/tracker/announce.go b/tracker/announce.go index 725b591..f0ae46d 100644 --- a/tracker/announce.go +++ b/tracker/announce.go @@ -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),