From ac04761e402c39978ee7f3d038bc6556954ec7e8 Mon Sep 17 00:00:00 2001 From: Justin Li Date: Fri, 20 Feb 2015 21:00:22 -0500 Subject: [PATCH 01/14] readme: Add note about 64-bit being required --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5d8c26a..b585e89 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ use-cases). ## Building & Installing -Chihaya requires Go 1.4, [Godep], and a [Go environment] previously setup. +Chihaya requires 64-bit Go 1.4, [Godep], and a [Go environment] previously set up. [Godep]: https://github.com/tools/godep [Go environment]: https://golang.org/doc/code.html From b6c1b3838bc447614e737eeac6ea9ca4198a05eb Mon Sep 17 00:00:00 2001 From: Justin Li Date: Sat, 21 Feb 2015 13:00:23 -0500 Subject: [PATCH 02/14] tracker: Remove impossible code for 'completed' event --- tracker/announce.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/tracker/announce.go b/tracker/announce.go index 74a3bd9..725b591 100644 --- a/tracker/announce.go +++ b/tracker/announce.go @@ -230,20 +230,13 @@ func (tkr *Tracker) handlePeerEvent(ann *models.Announce, p *models.Peer) (snatc } case ann.Event == "completed": - v4seed := t.Seeders.Contains(p.Key()) - v6seed := t.Seeders.Contains(p.Key()) - if t.Leechers.Contains(p.Key()) { err = tkr.leecherFinished(t, p) } else { err = models.ErrBadRequest } - // If one of the dual-stacked peers is already a seeder, they have - // already snatched. - if !(v4seed || v6seed) { - snatched = true - } + snatched = true case t.Leechers.Contains(p.Key()) && ann.Left == 0: // A leecher completed but the event was never received. From c1a4a6ecbb68b73e0d2c56e9a5848f7a5d52a4f2 Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Thu, 19 Mar 2015 23:39:31 -0400 Subject: [PATCH 03/14] dockerfile: initial --- Dockerfile | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2248835 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +# vim: ft=dockerfile +FROM golang +MAINTAINER Jimmy Zelinskie + +# Add files +WORKDIR /go/src/github.com/chihaya/chihaya/ +RUN mkdir -p /go/src/github.com/chihaya/chihaya/ +ADD chihaya.go /go/src/github.com/chihaya/chihaya/ +ADD backend /go/src/github.com/chihaya/chihaya/backend +ADD cmd /go/src/github.com/chihaya/chihaya/cmd +ADD config /go/src/github.com/chihaya/chihaya/config +ADD http /go/src/github.com/chihaya/chihaya/http +ADD stats /go/src/github.com/chihaya/chihaya/stats +ADD tracker /go/src/github.com/chihaya/chihaya/tracker +ADD Godeps /go/src/github.com/chihaya/chihaya/Godeps + +# Install +RUN go get ./... +RUN go install + +# docker run -p 6881:6881 -v $PATH_TO_DIR_WITH_CONF_FILE:/config quay.io/jzelinskie/chihaya +VOLUME ["/config"] +EXPOSE 6881 +CMD ["chihaya", "-config=/config/config.json", "-logtostderr=true"] From 1deca5fd5ed1b806aa9e1f33799bdbcc2e6776dc Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Sun, 22 Mar 2015 18:42:21 -0400 Subject: [PATCH 04/14] readme: add godoc, docker badges [ci skip] --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b585e89..bc9d51c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ -# Chihaya [![Build Status](https://api.travis-ci.org/chihaya/chihaya.svg?branch=master)](https://travis-ci.org/chihaya/chihaya) +# Chihaya + +[![GoDoc](https://godoc.org/github.com/chihaya/chihaya?status.svg)](https://godoc.org/github.com/chihaya/chihaya) +[![Build Status](https://api.travis-ci.org/chihaya/chihaya.svg?branch=master)](https://travis-ci.org/chihaya/chihaya) +[![Docker Repository on Quay.io](https://quay.io/repository/jzelinskie/chihaya/status "Docker Repository on Quay.io")](https://quay.io/repository/jzelinskie/chihaya) Chihaya is a high-performance [BitTorrent tracker] written in the Go programming language. It is still heavily under development and the current From 92866cfacd7b50014e4a59f79fdfe116fb034295 Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Sun, 22 Mar 2015 18:44:09 -0400 Subject: [PATCH 05/14] models: include port in peerkey --- tracker/models/models.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tracker/models/models.go b/tracker/models/models.go index 125ac5f..89df300 100644 --- a/tracker/models/models.go +++ b/tracker/models/models.go @@ -46,8 +46,8 @@ func (e NotFoundError) Error() string { return string(e) } type PeerList []Peer type PeerKey string -func NewPeerKey(peerID string, ip net.IP) PeerKey { - return PeerKey(peerID + "//" + ip.String()) +func NewPeerKey(peerID string, ip net.IP, port string) PeerKey { + return PeerKey(peerID + "//" + ip.String() + ":" + port) } func (pk PeerKey) IP() net.IP { @@ -88,7 +88,7 @@ func (p *Peer) HasIPv6() bool { } func (p *Peer) Key() PeerKey { - return NewPeerKey(p.ID, p.IP) + return NewPeerKey(p.ID, p.IP, string(p.Port)) } // Torrent is a swarm for a given torrent file. From 6188d52de0f3e07f0ed9c20f9512a64b0bb7c4e7 Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Sun, 22 Mar 2015 19:41:57 -0400 Subject: [PATCH 06/14] models: Port method for PeerKey This also adds some more docs for related stuff in the models package. --- tracker/models/models.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tracker/models/models.go b/tracker/models/models.go index 89df300..e48388c 100644 --- a/tracker/models/models.go +++ b/tracker/models/models.go @@ -43,13 +43,18 @@ type NotFoundError ClientError func (e ClientError) Error() string { return string(e) } func (e NotFoundError) Error() string { return string(e) } +// PeerList represents a list of peers: either seeders or leechers. type PeerList []Peer + +// PeerKey is the key used to uniquely identify a peer in a swarm. type PeerKey string +// NewPeerKey creates a properly formatted PeerKey. func NewPeerKey(peerID string, ip net.IP, port string) PeerKey { return PeerKey(peerID + "//" + ip.String() + ":" + port) } +// IP parses and returns the IP address for a given PeerKey. func (pk PeerKey) IP() net.IP { ip := net.ParseIP(strings.Split(string(pk), "//")[1]) if rval := ip.To4(); rval != nil { @@ -58,10 +63,16 @@ func (pk PeerKey) IP() net.IP { return ip } +// PeerID returns the PeerID section of a PeerKey. func (pk PeerKey) PeerID() string { return strings.Split(string(pk), "//")[0] } +// Port returns the port section of the PeerKey. +func (pk PeerKey) Port() string { + return strings.Split(string(pk), "//")[2] +} + // Peer is a participant in a swarm. type Peer struct { ID string `json:"id"` @@ -79,14 +90,19 @@ type Peer struct { LastAnnounce int64 `json:"last_announce"` } +// HasIPv4 determines if a peer's IP address can be represented as an IPv4 +// address. func (p *Peer) HasIPv4() bool { return !p.HasIPv6() } +// HasIPv6 determines if a peer's IP address can be represented as an IPv6 +// address. func (p *Peer) HasIPv6() bool { return len(p.IP) == net.IPv6len } +// Key returns a PeerKey for the given peer. func (p *Peer) Key() PeerKey { return NewPeerKey(p.ID, p.IP, string(p.Port)) } From 0ecd126ae84e483077aad083526ea0f36c87576b Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Mon, 23 Mar 2015 19:57:45 -0400 Subject: [PATCH 07/14] lint: Http -> HTTP --- config/config.go | 10 +++++----- http/http.go | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/config/config.go b/config/config.go index bd7ebc8..2e5c454 100644 --- a/config/config.go +++ b/config/config.go @@ -91,9 +91,9 @@ type TrackerConfig struct { type HTTPConfig struct { ListenAddr string `json:"http_listen_addr"` RequestTimeout Duration `json:"http_request_timeout"` - HttpReadTimeout Duration `json:"http_read_timeout"` - HttpWriteTimeout Duration `json:"http_write_timeout"` - HttpListenLimit int `json:"http_listen_limit"` + HTTPReadTimeout Duration `json:"http_read_timeout"` + HTTPWriteTimeout Duration `json:"http_write_timeout"` + HTTPListenLimit int `json:"http_listen_limit"` } // Config is the global configuration for an instance of Chihaya. @@ -129,8 +129,8 @@ var DefaultConfig = Config{ HTTPConfig: HTTPConfig{ ListenAddr: ":6881", RequestTimeout: Duration{10 * time.Second}, - HttpReadTimeout: Duration{10 * time.Second}, - HttpWriteTimeout: Duration{10 * time.Second}, + HTTPReadTimeout: Duration{10 * time.Second}, + HTTPWriteTimeout: Duration{10 * time.Second}, }, DriverConfig: DriverConfig{ diff --git a/http/http.go b/http/http.go index 967c7ce..ca9be00 100644 --- a/http/http.go +++ b/http/http.go @@ -127,19 +127,19 @@ func Serve(cfg *config.Config, tkr *tracker.Tracker) { } glog.V(0).Info("Starting on ", cfg.ListenAddr) - if cfg.HttpListenLimit != 0 { - glog.V(0).Info("Limiting connections to ", cfg.HttpListenLimit) + if cfg.HTTPListenLimit != 0 { + glog.V(0).Info("Limiting connections to ", cfg.HTTPListenLimit) } grace := &graceful.Server{ Timeout: cfg.RequestTimeout.Duration, ConnState: srv.connState, - ListenLimit: cfg.HttpListenLimit, + ListenLimit: cfg.HTTPListenLimit, Server: &http.Server{ Addr: cfg.ListenAddr, Handler: newRouter(srv), - ReadTimeout: cfg.HttpReadTimeout.Duration, - WriteTimeout: cfg.HttpWriteTimeout.Duration, + ReadTimeout: cfg.HTTPReadTimeout.Duration, + WriteTimeout: cfg.HTTPWriteTimeout.Duration, }, } From 80c068c97aac7a08b2e5176ec0a777b2362464e7 Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Mon, 23 Mar 2015 20:02:13 -0400 Subject: [PATCH 08/14] 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), From 1bf788a99b15d9631052d0a2715bb68605abebb8 Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Mon, 23 Mar 2015 20:43:33 -0400 Subject: [PATCH 09/14] tracker: fix reference to config --- tracker/announce.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tracker/announce.go b/tracker/announce.go index f0ae46d..7c7eb64 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 && cfg.CreateOnAnnounce { + if err == models.ErrTorrentDNE && tkr.Config.CreateOnAnnounce { torrent = &models.Torrent{ Infohash: ann.Infohash, Seeders: models.NewPeerMap(true, tkr.Config), From f083bb84777806ab986827bc7e21e84d953d8510 Mon Sep 17 00:00:00 2001 From: Justin Li Date: Tue, 24 Mar 2015 00:29:32 -0400 Subject: [PATCH 10/14] docs: Start reformatting config documentation --- README.md | 112 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 98 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index bc9d51c..a994ea4 100644 --- a/README.md +++ b/README.md @@ -71,20 +71,104 @@ Copy [`example_config.json`](https://github.com/chihaya/chihaya/blob/master/exam to your choice of location, and update the values as required. The available keys and their default values are as follows: -- `private_enabled: false` – if this is a private tracker -- `freeleech_enabled: false` – for private trackers, whether download stats should be counted for users -- `purge_inactive_torrents: true` – if torrents should be forgotten after some time -- `announce: "30m"` – the announce "interval" value sent to clients -- `min_announce: "15m"` – the announce "min_interval" value sent to clients -- `default_num_want: 50` – the default number of peers to return if the client has not specified -- `torrent_map_shards: 1` – number of torrent maps to use (leave this at 1 in general) -- `allow_ip_spoofing: true` – if peers are allowed to set their own IP, this must be enabled for dual-stack IP support -- `dual_stacked_peers: true` – if peers may have both an IPv4 and IPv6 address, otherwise only one IP per peer will be used -- `real_ip_header: ""` – optionally an HTTP header where the upstream IP is stored, for example `X-Forwarded-For` or `X-Real-IP` -- `respect_af: false` – if responses should only include peers of the same address family as the announcing peer -- `client_whitelist_enabled: false` – if peer IDs should be matched against the whitelist -- `client_whitelist: []` – list of peer ID prefixes to allow -- `http_listen_addr: ":6881"` – listen address for the HTTP server +##### `http_listen_addr` + + type: string + default: ":6881" + +The listen address for the HTTP server. If only a port is specified, the tracker will listen on all interfaces. + +##### `private_enabled` + + type: bool + default: true + +Whether this is a public or private tracker. + +##### `purge_inactive_torrents` + + type: bool + default: true + +If torrents should be forgotten when there are no active peers. This should be set to `false` for private trackers. + +##### `announce` + + type: duration + default: "30m" + +The announce `interval` value sent to clients. This specifies how long clients should wait between regular announces. + +##### `min_announce` + + type: duration + default: "30m" + +The announce `min_interval` value sent to clients. This theoretically specifies the minimum allowed time between announces, but most clients don't really respect it. + +##### `default_num_want` + + type: integer + default: 50 + +The default maximum number of peers to return if the client has not requested a specific number. + +##### `allow_ip_spoofing` + + type: bool + default: true + +Whether peers are allowed to set their own IP via the various supported methods or if these are ignored. This must be enabled for dual-stack IP support, since there is no other way to determine both IPs of a peer otherwise. + +##### `dual_stacked_peers` + + type: bool + default: true + +True if peers may have both an IPv4 and IPv6 address, otherwise only one IP per peer will be used. + +##### `real_ip_header` + + type: string + default: blank + +An optional HTTP header indicating the upstream IP, for example `X-Forwarded-For` or `X-Real-IP`. Use this when running the tracker behind a reverse proxy. + +##### `respect_af` + + type: bool + default: false + +Whether responses should only include peers of the same address family as the announcing peer, or if peers of any family may be returned (i.e. both IPv4 and IPv6). + +##### `client_whitelist_enabled` + + type: bool + default: false + +Enables the peer ID whitelist. + +##### `client_whitelist` + + type: array of strings + default: [] + +List of peer ID prefixes to allow if `client_whitelist_enabled` is set to true. + +##### `freeleech_enabled` + + type: bool + default: false + +For private trackers only, whether download stats should be counted or ignored for users. + +##### `torrent_map_shards` + + type: integer + default: 1 + +Number of internal torrent maps to use. Leave this at 1 in general, however it can potentially improve performance when there are many unique torrents and few peers per torrent. + - `http_request_timeout: "10s"` - `http_read_timeout: "10s"` - `http_write_timeout: "10s"` From 6490c8f51d8c91386d9b158fdf55efa88e6585d2 Mon Sep 17 00:00:00 2001 From: Justin Li Date: Tue, 24 Mar 2015 00:32:59 -0400 Subject: [PATCH 11/14] docs: Add create_on_announce to list of config keys --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index a994ea4..4b0db91 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,13 @@ The listen address for the HTTP server. If only a port is specified, the tracker Whether this is a public or private tracker. +##### `create_on_announce` + + type: bool + default: true + +Whether to register new torrents with the tracker when any client announces (`true`), or to return an error if the torrent doesn't exist (`false`). This should be set to `false` for private trackers in most cases. + ##### `purge_inactive_torrents` type: bool From eefbe64da61ecb5538b44cb1e6fc50786f366ecd Mon Sep 17 00:00:00 2001 From: Justin Li Date: Tue, 24 Mar 2015 00:38:20 -0400 Subject: [PATCH 12/14] docs: Break out config docs into a separate file --- CONFIGURATION.md | 120 +++++++++++++++++++++++++++++++++++++++++++++++ README.md | 116 +-------------------------------------------- 2 files changed, 121 insertions(+), 115 deletions(-) create mode 100644 CONFIGURATION.md diff --git a/CONFIGURATION.md b/CONFIGURATION.md new file mode 100644 index 0000000..19fd4be --- /dev/null +++ b/CONFIGURATION.md @@ -0,0 +1,120 @@ +# Configuration + +Chihaya's behaviour is customized by setting up a JSON configuration file. +Available keys are as follows: + +##### `http_listen_addr` + + type: string + default: ":6881" + +The listen address for the HTTP server. If only a port is specified, the tracker will listen on all interfaces. + +##### `private_enabled` + + type: bool + default: true + +Whether this is a public or private tracker. + +##### `create_on_announce` + + type: bool + default: true + +Whether to register new torrents with the tracker when any client announces (`true`), or to return an error if the torrent doesn't exist (`false`). This should be set to `false` for private trackers in most cases. + +##### `purge_inactive_torrents` + + type: bool + default: true + +If torrents should be forgotten when there are no active peers. This should be set to `false` for private trackers. + +##### `announce` + + type: duration + default: "30m" + +The announce `interval` value sent to clients. This specifies how long clients should wait between regular announces. + +##### `min_announce` + + type: duration + default: "30m" + +The announce `min_interval` value sent to clients. This theoretically specifies the minimum allowed time between announces, but most clients don't really respect it. + +##### `default_num_want` + + type: integer + default: 50 + +The default maximum number of peers to return if the client has not requested a specific number. + +##### `allow_ip_spoofing` + + type: bool + default: true + +Whether peers are allowed to set their own IP via the various supported methods or if these are ignored. This must be enabled for dual-stack IP support, since there is no other way to determine both IPs of a peer otherwise. + +##### `dual_stacked_peers` + + type: bool + default: true + +True if peers may have both an IPv4 and IPv6 address, otherwise only one IP per peer will be used. + +##### `real_ip_header` + + type: string + default: blank + +An optional HTTP header indicating the upstream IP, for example `X-Forwarded-For` or `X-Real-IP`. Use this when running the tracker behind a reverse proxy. + +##### `respect_af` + + type: bool + default: false + +Whether responses should only include peers of the same address family as the announcing peer, or if peers of any family may be returned (i.e. both IPv4 and IPv6). + +##### `client_whitelist_enabled` + + type: bool + default: false + +Enables the peer ID whitelist. + +##### `client_whitelist` + + type: array of strings + default: [] + +List of peer ID prefixes to allow if `client_whitelist_enabled` is set to true. + +##### `freeleech_enabled` + + type: bool + default: false + +For private trackers only, whether download stats should be counted or ignored for users. + +##### `torrent_map_shards` + + type: integer + default: 1 + +Number of internal torrent maps to use. Leave this at 1 in general, however it can potentially improve performance when there are many unique torrents and few peers per torrent. + +- `http_request_timeout: "10s"` +- `http_read_timeout: "10s"` +- `http_write_timeout: "10s"` +- `http_listen_limit: 0` +- `driver: "noop"` +- `stats_buffer_size: 0` +- `include_mem_stats: true` +- `verbose_mem_stats: false` +- `mem_stats_interval: "5s"` + diff --git a/README.md b/README.md index 4b0db91..51b1e56 100644 --- a/README.md +++ b/README.md @@ -69,119 +69,5 @@ $ godep go test -v ./... -bench . Copy [`example_config.json`](https://github.com/chihaya/chihaya/blob/master/example_config.json) to your choice of location, and update the values as required. -The available keys and their default values are as follows: +An explanation of the available keys can be found in [CONFIGURATION.md](https://github.com/chihaya/chihaya/blob/master/CONTRIBUTING.md). -##### `http_listen_addr` - - type: string - default: ":6881" - -The listen address for the HTTP server. If only a port is specified, the tracker will listen on all interfaces. - -##### `private_enabled` - - type: bool - default: true - -Whether this is a public or private tracker. - -##### `create_on_announce` - - type: bool - default: true - -Whether to register new torrents with the tracker when any client announces (`true`), or to return an error if the torrent doesn't exist (`false`). This should be set to `false` for private trackers in most cases. - -##### `purge_inactive_torrents` - - type: bool - default: true - -If torrents should be forgotten when there are no active peers. This should be set to `false` for private trackers. - -##### `announce` - - type: duration - default: "30m" - -The announce `interval` value sent to clients. This specifies how long clients should wait between regular announces. - -##### `min_announce` - - type: duration - default: "30m" - -The announce `min_interval` value sent to clients. This theoretically specifies the minimum allowed time between announces, but most clients don't really respect it. - -##### `default_num_want` - - type: integer - default: 50 - -The default maximum number of peers to return if the client has not requested a specific number. - -##### `allow_ip_spoofing` - - type: bool - default: true - -Whether peers are allowed to set their own IP via the various supported methods or if these are ignored. This must be enabled for dual-stack IP support, since there is no other way to determine both IPs of a peer otherwise. - -##### `dual_stacked_peers` - - type: bool - default: true - -True if peers may have both an IPv4 and IPv6 address, otherwise only one IP per peer will be used. - -##### `real_ip_header` - - type: string - default: blank - -An optional HTTP header indicating the upstream IP, for example `X-Forwarded-For` or `X-Real-IP`. Use this when running the tracker behind a reverse proxy. - -##### `respect_af` - - type: bool - default: false - -Whether responses should only include peers of the same address family as the announcing peer, or if peers of any family may be returned (i.e. both IPv4 and IPv6). - -##### `client_whitelist_enabled` - - type: bool - default: false - -Enables the peer ID whitelist. - -##### `client_whitelist` - - type: array of strings - default: [] - -List of peer ID prefixes to allow if `client_whitelist_enabled` is set to true. - -##### `freeleech_enabled` - - type: bool - default: false - -For private trackers only, whether download stats should be counted or ignored for users. - -##### `torrent_map_shards` - - type: integer - default: 1 - -Number of internal torrent maps to use. Leave this at 1 in general, however it can potentially improve performance when there are many unique torrents and few peers per torrent. - -- `http_request_timeout: "10s"` -- `http_read_timeout: "10s"` -- `http_write_timeout: "10s"` -- `http_listen_limit: 0` -- `driver: "noop"` -- `stats_buffer_size: 0` -- `include_mem_stats: true` -- `verbose_mem_stats: false` -- `mem_stats_interval: "5s"` From f3b264dd533e6593cc70cd4a48d73f4ad5c0af0e Mon Sep 17 00:00:00 2001 From: Justin Li Date: Tue, 24 Mar 2015 00:39:33 -0400 Subject: [PATCH 13/14] docs: Fix link to configuration.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 51b1e56..d10b2db 100644 --- a/README.md +++ b/README.md @@ -69,5 +69,5 @@ $ godep go test -v ./... -bench . Copy [`example_config.json`](https://github.com/chihaya/chihaya/blob/master/example_config.json) to your choice of location, and update the values as required. -An explanation of the available keys can be found in [CONFIGURATION.md](https://github.com/chihaya/chihaya/blob/master/CONTRIBUTING.md). +An explanation of the available keys can be found in [CONFIGURATION.md](https://github.com/chihaya/chihaya/blob/master/CONFIGURATION.md). From b93cc26b98496c3d609098e2abd77c3e401f2c37 Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Thu, 26 Mar 2015 22:11:13 -0400 Subject: [PATCH 14/14] models: properly format port into peerkey string --- tracker/models/models.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tracker/models/models.go b/tracker/models/models.go index e48388c..c9de8e5 100644 --- a/tracker/models/models.go +++ b/tracker/models/models.go @@ -8,6 +8,7 @@ package models import ( "net" + "strconv" "strings" "time" @@ -104,7 +105,7 @@ func (p *Peer) HasIPv6() bool { // Key returns a PeerKey for the given peer. func (p *Peer) Key() PeerKey { - return NewPeerKey(p.ID, p.IP, string(p.Port)) + return NewPeerKey(p.ID, p.IP, strconv.FormatUint(p.Port, 10)) } // Torrent is a swarm for a given torrent file.