@@ -21,184 +21,185 @@ func init() {
2121// Config for Session.
2222type Config struct {
2323 // Database file to save resume data.
24- Database string
24+ Database string `yaml:"database"`
2525 // DataDir is where files are downloaded.
26- DataDir string
26+ DataDir string `yaml:"data-dir"`
2727 // If true, torrent files are saved into <data_dir>/<torrent_id>/<torrent_name>.
2828 // Useful if downloading the same torrent from multiple sources.
29- DataDirIncludesTorrentID bool
29+ DataDirIncludesTorrentID bool `yaml:"data-dir-includes-torrent-id"`
3030 // Host to listen for TCP Acceptor. Port is computed automatically
31- Host string
31+ Host string `yaml:"host"`
3232 // New torrents will be listened at selected port in this range.
33- PortBegin , PortEnd uint16
33+ PortBegin uint16 `yaml:"port-begin"`
34+ PortEnd uint16 `yaml:"port-end"`
3435 // At start, client will set max open files limit to this number. (like "ulimit -n" command)
35- MaxOpenFiles uint64
36+ MaxOpenFiles uint64 `yaml:"max-open-files"`
3637 // Enable peer exchange protocol.
37- PEXEnabled bool
38+ PEXEnabled bool `yaml:"pex-enabled"`
3839 // Resume data (bitfield & stats) are saved to disk at interval to keep IO lower.
39- ResumeWriteInterval time.Duration
40+ ResumeWriteInterval time.Duration `yaml:"resume-write-interval"`
4041 // Peer id is prefixed with this string. See BEP 20. Remaining bytes of peer id will be randomized.
4142 // Only applies to private torrents.
42- PrivatePeerIDPrefix string
43+ PrivatePeerIDPrefix string `yaml:"private-peer-id-prefix"`
4344 // Client version that is sent in BEP 10 handshake message.
4445 // Only applies to private torrents.
45- PrivateExtensionHandshakeClientVersion string
46+ PrivateExtensionHandshakeClientVersion string `yaml:"private-extension-handshake-client-version"`
4647 // URL to the blocklist file in CIDR format.
47- BlocklistURL string
48+ BlocklistURL string `yaml:"blocklist-url"`
4849 // When to refresh blocklist
49- BlocklistUpdateInterval time.Duration
50+ BlocklistUpdateInterval time.Duration `yaml:"blocklist-update-interval"`
5051 // HTTP timeout for downloading blocklist
51- BlocklistUpdateTimeout time.Duration
52+ BlocklistUpdateTimeout time.Duration `yaml:"blocklist-update-timeout"`
5253 // Do not contact tracker if it's IP is blocked
53- BlocklistEnabledForTrackers bool
54+ BlocklistEnabledForTrackers bool `yaml:"blocklist-enabled-for-trackers"`
5455 // Do not connect to peer if it's IP is blocked
55- BlocklistEnabledForOutgoingConnections bool
56+ BlocklistEnabledForOutgoingConnections bool `yaml:"blocklist-enabled-for-outgoing-connections"`
5657 // Do not accept connections from peer if it's IP is blocked
57- BlocklistEnabledForIncomingConnections bool
58+ BlocklistEnabledForIncomingConnections bool `yaml:"blocklist-enabled-for-incoming-connections"`
5859 // Do not accept response larger than this size
59- BlocklistMaxResponseSize int64
60+ BlocklistMaxResponseSize int64 `yaml:"blocklist-max-response-size"`
6061 // Time to wait when adding torrent with AddURI().
61- TorrentAddHTTPTimeout time.Duration
62+ TorrentAddHTTPTimeout time.Duration `yaml:"torrent-add-http-timeout"`
6263 // Maximum allowed size to be received by metadata extension.
63- MaxMetadataSize uint
64+ MaxMetadataSize uint `yaml:"max-metadata-size"`
6465 // Maximum allowed size to be read when adding torrent.
65- MaxTorrentSize uint
66+ MaxTorrentSize uint `yaml:"max-torrent-size"`
6667 // Maximum allowed number of pieces in a torrent.
67- MaxPieces uint32
68+ MaxPieces uint32 `yaml:"max-pieces"`
6869 // Time to wait when resolving host names for trackers and peers.
69- DNSResolveTimeout time.Duration
70+ DNSResolveTimeout time.Duration `yaml:"dns-resolve-timeout"`
7071 // Global download speed limit in KB/s.
71- SpeedLimitDownload int64
72+ SpeedLimitDownload int64 `yaml:"speed-limit-download"`
7273 // Global upload speed limit in KB/s.
73- SpeedLimitUpload int64
74+ SpeedLimitUpload int64 `yaml:"speed-limit-upload"`
7475 // Start torrent automatically if it was running when previous session was closed.
75- ResumeOnStartup bool
76+ ResumeOnStartup bool `yaml:"resume-on-startup"`
7677 // Check each torrent loop for aliveness. Helps to detect bugs earlier.
77- HealthCheckInterval time.Duration
78+ HealthCheckInterval time.Duration `yaml:"health-check-interval"`
7879 // If torrent loop is stuck for more than this duration. Program crashes with stacktrace.
79- HealthCheckTimeout time.Duration
80+ HealthCheckTimeout time.Duration `yaml:"health-check-timeout"`
8081 // The unix permission of created files, execute bit is removed for files
81- FilePermissions fs.FileMode
82+ FilePermissions fs.FileMode `yaml:"file-permissions"`
8283
8384 // Enable RPC server
84- RPCEnabled bool
85+ RPCEnabled bool `yaml:"rpc-enabled"`
8586 // Host to listen for RPC server
86- RPCHost string
87+ RPCHost string `yaml:"rpc-host"`
8788 // Listen port for RPC server
88- RPCPort int
89+ RPCPort int `yaml:"rpc-port"`
8990 // Time to wait for ongoing requests before shutting down RPC HTTP server.
90- RPCShutdownTimeout time.Duration
91+ RPCShutdownTimeout time.Duration `yaml:"rpc-shutdown-timeout"`
9192
9293 // Enable DHT node.
93- DHTEnabled bool
94+ DHTEnabled bool `yaml:"dht-enabled"`
9495 // DHT node will listen on this IP.
95- DHTHost string
96+ DHTHost string `yaml:"dht-host"`
9697 // DHT node will listen on this UDP port.
97- DHTPort uint16
98+ DHTPort uint16 `yaml:"dht-port"`
9899 // DHT announce interval
99- DHTAnnounceInterval time.Duration
100+ DHTAnnounceInterval time.Duration `yaml:"dht-announce-interval"`
100101 // Minimum announce interval when announcing to DHT.
101- DHTMinAnnounceInterval time.Duration
102+ DHTMinAnnounceInterval time.Duration `yaml:"dht-min-announce-interval"`
102103 // Known routers to bootstrap local DHT node.
103- DHTBootstrapNodes []string
104+ DHTBootstrapNodes []string `yaml:"dht-bootstrap-nodes"`
104105
105106 // Number of peer addresses to request in announce request.
106- TrackerNumWant int
107+ TrackerNumWant int `yaml:"tracker-num-want"`
107108 // Time to wait for announcing stopped event.
108109 // Stopped event is sent to the tracker when torrent is stopped.
109- TrackerStopTimeout time.Duration
110+ TrackerStopTimeout time.Duration `yaml:"tracker-stop-timeout"`
110111 // When the client needs new peer addresses to connect, it ask to the tracker.
111112 // To prevent spamming the tracker an interval is set to wait before the next announce.
112- TrackerMinAnnounceInterval time.Duration
113+ TrackerMinAnnounceInterval time.Duration `yaml:"tracker-min-announce-interval"`
113114 // Total time to wait for response to be read.
114115 // This includes ConnectTimeout and TLSHandshakeTimeout.
115- TrackerHTTPTimeout time.Duration
116+ TrackerHTTPTimeout time.Duration `yaml:"tracker-http-timeout"`
116117 // User agent sent when communicating with HTTP trackers.
117118 // Only applies to private torrents.
118- TrackerHTTPPrivateUserAgent string
119+ TrackerHTTPPrivateUserAgent string `yaml:"tracker-http-private-user-agent"`
119120 // Max number of bytes in a tracker response.
120- TrackerHTTPMaxResponseSize uint
121+ TrackerHTTPMaxResponseSize uint `yaml:"tracker-http-max-response-size"`
121122 // Check and validate TLS ceritificates.
122- TrackerHTTPVerifyTLS bool
123+ TrackerHTTPVerifyTLS bool `yaml:"tracker-http-verify-tls"`
123124
124125 // Number of unchoked peers.
125- UnchokedPeers int
126+ UnchokedPeers int `yaml:"unchoked-peers"`
126127 // Number of optimistic unchoked peers.
127- OptimisticUnchokedPeers int
128+ OptimisticUnchokedPeers int `yaml:"optimistic-unchoked-peers"`
128129 // Max number of blocks allowed to be queued without dropping any.
129- MaxRequestsIn int
130+ MaxRequestsIn int `yaml:"max-requests-in"`
130131 // Max number of blocks requested from a peer but not received yet.
131132 // `rreq` value from extended handshake cannot exceed this limit.
132- MaxRequestsOut int
133+ MaxRequestsOut int `yaml:"max-requests-out"`
133134 // Number of bloks requested from peer if it does not send `rreq` value in extended handshake.
134- DefaultRequestsOut int
135+ DefaultRequestsOut int `yaml:"default-requests-out"`
135136 // Time to wait for a requested block to be received before marking peer as snubbed
136- RequestTimeout time.Duration
137+ RequestTimeout time.Duration `yaml:"request-timeout"`
137138 // Max number of running downloads on piece in endgame mode, snubbed and choed peers don't count
138- EndgameMaxDuplicateDownloads int
139+ EndgameMaxDuplicateDownloads int `yaml:"endgame-max-duplicate-downloads"`
139140 // Max number of outgoing connections to dial
140- MaxPeerDial int
141+ MaxPeerDial int `yaml:"max-peer-dial"`
141142 // Max number of incoming connections to accept
142- MaxPeerAccept int
143+ MaxPeerAccept int `yaml:"max-peer-accept"`
143144 // Running metadata downloads, snubbed peers don't count
144- ParallelMetadataDownloads int
145+ ParallelMetadataDownloads int `yaml:"parallel-metadata-downloads"`
145146 // Time to wait for TCP connection to open.
146- PeerConnectTimeout time.Duration
147+ PeerConnectTimeout time.Duration `yaml:"peer-connect-timeout"`
147148 // Time to wait for BitTorrent handshake to complete.
148- PeerHandshakeTimeout time.Duration
149+ PeerHandshakeTimeout time.Duration `yaml:"peer-handshake-timeout"`
149150 // When peer has started to send piece block, if it does not send any bytes in PieceReadTimeout, the connection is closed.
150- PieceReadTimeout time.Duration
151+ PieceReadTimeout time.Duration `yaml:"piece-read-timeout"`
151152 // Max number of peer addresses to keep in connect queue.
152- MaxPeerAddresses int
153+ MaxPeerAddresses int `yaml:"max-peer-addresses"`
153154 // Number of allowed-fast messages to send after handshake.
154- AllowedFastSet int
155+ AllowedFastSet int `yaml:"allowed-fast-set"`
155156
156157 // Number of bytes to read when a piece is requested by a peer.
157- ReadCacheBlockSize int64
158+ ReadCacheBlockSize int64 `yaml:"read-cache-block-size"`
158159 // Number of cached bytes for piece read requests.
159- ReadCacheSize int64
160+ ReadCacheSize int64 `yaml:"read-cache-size"`
160161 // Read bytes for a piece part expires after duration.
161- ReadCacheTTL time.Duration
162+ ReadCacheTTL time.Duration `yaml:"read-cache-ttl"`
162163 // Number of read operations to do in parallel.
163- ParallelReads uint
164+ ParallelReads uint `yaml:"parallel-reads"`
164165 // Number of write operations to do in parallel.
165- ParallelWrites uint
166+ ParallelWrites uint `yaml:"parallel-writes"`
166167 // Number of bytes allocated in memory for downloading piece data.
167- WriteCacheSize int64
168+ WriteCacheSize int64 `yaml:"write-cache-size"`
168169
169170 // When the client want to connect a peer, first it tries to do encrypted handshake.
170171 // If it does not work, it connects to same peer again and does unencrypted handshake.
171172 // This behavior can be changed via this variable.
172- DisableOutgoingEncryption bool
173+ DisableOutgoingEncryption bool `yaml:"disable-outgoing-encryption"`
173174 // Dial only encrypted connections.
174- ForceOutgoingEncryption bool
175+ ForceOutgoingEncryption bool `yaml:"force-outgoing-encryption"`
175176 // Do not accept unencrypted connections.
176- ForceIncomingEncryption bool
177+ ForceIncomingEncryption bool `yaml:"force-incoming-encryption"`
177178
178179 // TCP connect timeout for WebSeed sources
179- WebseedDialTimeout time.Duration
180+ WebseedDialTimeout time.Duration `yaml:"webseed-dial-timeout"`
180181 // TLS handshake timeout for WebSeed sources
181- WebseedTLSHandshakeTimeout time.Duration
182+ WebseedTLSHandshakeTimeout time.Duration `yaml:"webseed-tls-handshake-timeout"`
182183 // HTTP header timeout for WebSeed sources
183- WebseedResponseHeaderTimeout time.Duration
184+ WebseedResponseHeaderTimeout time.Duration `yaml:"webseed-response-header-timeout"`
184185 // HTTP body read timeout for Webseed sources
185- WebseedResponseBodyReadTimeout time.Duration
186+ WebseedResponseBodyReadTimeout time.Duration `yaml:"webseed-response-body-read-timeout"`
186187 // Retry interval for restarting failed downloads
187- WebseedRetryInterval time.Duration
188+ WebseedRetryInterval time.Duration `yaml:"webseed-retry-interval"`
188189 // Verify TLS certificate for WebSeed URLs
189- WebseedVerifyTLS bool
190+ WebseedVerifyTLS bool `yaml:"webseed-verify-tls"`
190191 // Limit the number of WebSeed sources in torrent.
191- WebseedMaxSources int
192+ WebseedMaxSources int `yaml:"webseed-max-sources"`
192193 // Number of maximum simulateous downloads from WebSeed sources.
193- WebseedMaxDownloads int
194+ WebseedMaxDownloads int `yaml:"webseed-max-downloads"`
194195
195196 // Shell command to execute on torrent completion.
196- OnCompleteCmd []string
197+ OnCompleteCmd []string `yaml:"on-complete-cmd"`
197198
198199 // Replace default log handler
199- CustomLogHandler log.Handler
200+ CustomLogHandler log.Handler `yaml:"custom-log-handler"`
200201 // Enable debugging
201- Debug bool
202+ Debug bool `yaml:"debug"`
202203}
203204
204205// DefaultConfig for Session. Do not pass zero value Config to NewSession. Copy this struct and modify instead.
0 commit comments