Merge pull request #373 from mrd0ll4r/php-announces

http: add option for legacy PHP URLs
This commit is contained in:
mrd0ll4r 2017-12-06 15:16:33 +01:00 committed by GitHub
commit 34a6425fd5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View file

@ -36,6 +36,16 @@ chihaya:
# Disabling this should increase performance/decrease load.
enable_request_timing: false
# Whether to listen on /announce.php and /scrape.php in addition to their
# non-.php counterparts.
# This is an option for compatibility with (very) old clients or otherwise
# outdated systems.
# This might be useful to retracker.local users, for more information see
# http://rutracker.wiki/Оптимизация_обмена_битторрент_траффиком_в_локальных_сетях
# and
# http://rutracker.wiki/Retracker.local
enable_legacy_php_urls: false
# When enabled, the IP address used to connect to the tracker will not
# override the value clients advertise as their IP address.
allow_ip_spoofing: false

View file

@ -64,6 +64,7 @@ type Config struct {
WriteTimeout time.Duration `yaml:"write_timeout"`
TLSCertPath string `yaml:"tls_cert_path"`
TLSKeyPath string `yaml:"tls_key_path"`
EnableLegacyPHPURLs bool `yaml:"enable_legacy_php_urls"`
EnableRequestTiming bool `yaml:"enable_request_timing"`
ParseOptions `yaml:",inline"`
}
@ -76,6 +77,7 @@ func (cfg Config) LogFields() log.Fields {
"writeTimeout": cfg.WriteTimeout,
"tlsCertPath": cfg.TLSCertPath,
"tlsKeyPath": cfg.TLSKeyPath,
"enableLegacyPHPURLs": cfg.EnableLegacyPHPURLs,
"enableRequestTiming": cfg.EnableRequestTiming,
"allowIPSpoofing": cfg.AllowIPSpoofing,
"realIPHeader": cfg.RealIPHeader,
@ -177,6 +179,13 @@ func (f *Frontend) handler() http.Handler {
router := httprouter.New()
router.GET("/announce", f.announceRoute)
router.GET("/scrape", f.scrapeRoute)
if f.EnableLegacyPHPURLs {
log.Info("http: enabling legacy PHP URLs")
router.GET("/announce.php", f.announceRoute)
router.GET("/scrape.php", f.scrapeRoute)
}
return router
}