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),