Skip to content

Commit

Permalink
config: add create_on_announce option
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jzelinskie committed Mar 24, 2015
1 parent 0ecd126 commit 80c068c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions example_config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"create_on_announce": true,
"private_enabled": false,
"freeleech_enabled": false,
"purge_inactive_torrents": true,
Expand Down
2 changes: 1 addition & 1 deletion tracker/announce.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 80c068c

Please sign in to comment.