All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog
- Fix panic when attempting to shutdown chihaya before main server loop has started
- Do not allocate new bytes buffer for each bencode operation
- Fix
TestSerializer
not failing when serialization errors out - Fix potential race condition for global variable in
record.Record
- Refactor cc utility to use
io.Writer
andio.Reader
- Improve Recorder section of README
- Use
sync.Pool
as backend instead of channels forutil/BufferPool
- Replace runtime CPU profiler with
net/http/pprof
debug server - Make
HitAndRuns
,TorrentGroupFreeleech
,Clients
andGlobalFreeleech
useatomic
primitives - Use
[]byte
instead of string to prevent lookups in heap or via golang internalaeshash
- Move closing of flush channels to separate function
- Replace gob serialization with custom binary marshalling
- Change
Peer.Addr
to fixed array - Re-allocate empty maps for Leechers to reduce memory usage
- Optimize Peer in-memory size
- Cleanup bencode utility
- Rename
database/Record*
->database/Queue*
- Simplify request handling by processing them directly, and pass contextTimeout to handler response
- Make Queue methods optional async, with fast pathway without goroutine spawn
- Update schema.sql for
STRICT_TRANS_TABLES
- Replace
Users
/Torrents
locks withatomic.Pointer
- Replace
net/http
with https://github.com/valyala/fasthttp - Refactor query parsing into a struct via
fasthttp
- Do not spawn new goroutine for
QueueSnatch
- Keep single sql.DB instead of multiple custom Connection
- Remove usage of
TEMPORARY
tables for flushes - Alter config to take database DSN directly
- Make recorder output
csv
instead ofjson
- Introduce and use non-crypto Rand for tests and announce interval drift
- Enable mutex and blocks profiling when running with -P flag
- Introduce anonymize command to anonymize binary cache dumps
- Enable PGO builds for chihaya
- Separate metrics for
context.DeadlineExceeded
andcontext.Cancelled
- Add test case for
server/util.failure
- Adjust histogram buckets to better capture wider range of data
- Load group freeleech during initialization
- Separate torrents and group freeleech reload
- Reload approved client list on every refresh
- Prometheus metric
throughput
- Increase announce interval for non-existing torrents
- Use new
util.Semaphore
(introduced inv10.0.0
) indatabase/flush
- Use
context.WithTimeout
to cancel long-running request
- Exit on uninitialized
Record
error - Improve and standardize logging across various files
- Update warning messages in
readConfig
- Make serialization atomic by using
os.Rename
- Refactor old
/check
into new/alive
endpoint - Bump minimum Go version to 1.19
- Record of ID 0 in
approved_clients
table being treated as non-approved - Requests should be counted for Prometheus collector before handling them in
ServerHTTP
- Handle
TorrentsMutex
'sRUnlock
in defer inserver/scrape.go
- Incorrect usage of
log.Panic
inrecord/record.go
- Allow configuring
ReadHeaderTimeout
,IdleTimeout
andSetKeepAlivesEnabled
- Refactor config file structure:
- Move
read_timeout
,write_timeout
to newhttp.timeout
section and remove_timeout
suffix
- Move
- Avoid 'superfluous response.WriteHeader call' error when handling panic in
ServeHTTP
- Do not set GOMAXPROCS in chihaya/main as it defaults to system CPUs on new Go versions already
- Ability to control HTTP timeouts via
read_timeout
andwrite_timeout
(in newhttp
config section)
- Refactor config file structure:
- Move
strict_port
,numwant
andmaxnumwant
to newannounce
section - Move
addr
,admin_token
to newhttp
section - Rename
proxy
toproxy_header
and move it tohttp
section
- Move
flush_groups
configuration option and related code
- Modify HTTP read/write timeouts
- Support for semicolons in query parameters (https://golang.org/doc/go1.17#semicolons)
- Due to above change, bump minimum Go version to 1.17
- Load freeleech data for torrent groups separately from torrents themselves
- Switch build system to
Makefile
- Null pointer dereference on SQL rows in
purgeInactivePeers
andload*
functions - Wrong max deadlock count being printed in warning message
- Improve database tests
- Database tests using
go-testfixtures/testfixtures
were added
- Download and upload multiplier being switched around when loading new user
flush_groups
config option was added to control whether groups should be updated whenever related torrent is flushed
- Renamed table
client_whitelist
toapproved_clients
- Renamed prometheus stat
chihaya_whitelist
tochihaya_clients
- Removed all references to whitelist/blacklist
- Use
crypto/rand
inutil
forRandStringBytes
andRand
chihaya_sql_errors_count
metric now tracks SQL errors
- Temporary tables for user and torrent flushes are now used more efficiently
- Do not use enum for
transfer_history
- Update the timestamp on torrents group when flushing torrents
- Do not return scrape information for torrents that user can not download
- New format for
record
including more useful data
- Prometheus metric for tracking aborted deadlocks
- Tests for
GetInt
andGetBool
inconfig
- Tests for
server/params
- Clarify
Your client is not approved
message by usingpeer_id
instead ofid
- Remove unnecessary quoting of integer columns for database queries
- Ability to configure default/maximum
numwant
from config
ServeHTTP
panicking when query string included empty parameter followed by delimiter (?bug=&yes=
)
- Ensure
peer_id
is always 20 bytes - Rewrite query string parser
- Ignore
info_hash
if it isn't exactly 20 bytes
- Log failing URL on panic in
ServeHTTP
/check
endpoint for healt-checking- Ability to configure intervals from
config.json
- Ability to configure deadlock behavior from
config.json
- Ability to configure channels buffer length from
config.json
- Ability to
restore
cache dump from JSON
successful
typo- Handle errors early for prepared statements
- Moved
InitPrivateIPBlocks
toinit
insideserver.go
- Panic in metrics instead of returning empty body on error
- Golint reformat code
- Narrow
bytes.Buffer
in server toio.Writer
- Eliminate long lines
- golangci: disable default linters and specify hard list of enabled ones
- Return HTTP 500 when panicking in
ServeHTTP
- Use
time.Duration.String
for time formatting across code - Remove
prepareStatement
fromdatabase.go
- database:
OpenDatabaseConnection
->Open
- database:
exec
->execute
,execBuffer
->exec
(follows PDO) - Reformat README with better explanation of config file
- Count only unique deadlocks for
chihaya_deadlock_count
- Move query parsing logic to separate module
- Do not parse query string globally in server, have each action handle it separately if needed
- Completely rework passkey and action logic allowing for non-passkey protected endpoints
- Return 404 with empty body when request is malformed or action is not recognized instead of bencoded message
- Handle errors of
w.Write()
inServeHTTP
- Various code cleanups
- Ability to enable or disable strict port checking in
config.json
- Add bencode utility for converting between bencode and JSON
- Help screen for
chihaya
- Ability to configure inactive peer time and announce drift
- Call to
panic()
with wrong argument infailure()
(server.go
) cc
utility was overwriting torrent cache file with JSON version- Header configured in
proxy
was not being respected @config/GetInt()
was improperly implemented usingint
instead ofjson.Number
InactiveAnnounceInterval
did not account for configured announce drift properlyconfig
Getters were failing on unexpected values (such asnil
) instead of falling back to default- New flush logic for users and torrents was not properly utilizing temporary table leading to data loss in cases where single user or torrent was present multiple times in a flushed channel
- Have
Get
functions inconfig
returnbool
indicating whether default was used - Rename
cache-dump
tocc
- Do not use
chihaya/log
insidecc
utility - Split types from
database
intotypes
sub-package - Move logging of Info from stderr to stdout
- Rename
profile
flag toP
- Make announce drift random
- Make @config/GetInt() return
int
instead ofint64
config
now reads numeric values from JSON as numbers instead of floats
- Ability to configure logging of flushes in
config.json
- Utility for exporting cache into readable JSON format
- Ability to specify custom arguments
CGO_ENABLED
,GOOS
andGOARCH
in Dockerfile during build process - Dump stacktrace when error is encountered
- README was improperly showing
null
as valid value foradmin_token
andproxy
.
- Changed
users
andtorrents
flush SQL queries to use temporary table withUPDATE
instead ofINSERT INTO ... ON DUPLICATE KEY ...
, this avoids rare cases where previously removed entry from these tables is inserted back with default values by chihaya - Code cleanup
- Make torrentId
uint32
- Moved
main.go
tocmd/chihaya
to allow for building multiple binaries
- Support for interval time in
/scrape
endpoint - Support for
failure reason
in/scrape
endpoint - Add port to
transfer_ips
- Add port to JSON recorder
- Use Alpine docker image as builder
- Better formatting of warning messages in config.go
- Split mandatory parameters check into separate sections with their own failure messages
- Do not lock TorrentsMutex if no info_hash is provided to
/scrape
- Print name of unsupported action in failure message
- Refactor logging across codebase
- Record hidden ip as 2130706433 (127.0.0.1) instead of 0 (0.0.0.0)
- Refactor config allowing for default values to be given in code
- Move
record
andscrape
from build tags into config variables
- Additional metrics in prometheus for whitelist, hit and runs
- Additional metrics in prometheus for channels, reload time, flush time, deadlock
- Validate port provided by client (must be between 1024 and 65535)
- Code cleanup
- Move IP check from server to announce
- Ability to control which (if any) header is used for proxy support
- Fail request if IP provided by client is in private range
- Support for prometheus metrics
- Run docker container as UID 1000
- Use Go 1.14
- Plaintext
/stats
endpoint
- Print number of CPUs when started with
profile
flag
- Dockerfile
- Code style fixes
- Optimize structs memory alignment
- Code cleanup
- Rewrote database using database/sql and MySQL driver
- Tests for config.go
- Only one peer per user is sent when seeders requested
- Tests for record.go
- Tests for util.go
- Print peerId on 'client not approved' failure message
- RandStringBytes in util
- Tests for util/bufferpool
- Broken error handling for parseQuery in server.go
- Explicitly Close() server itself on shutdown (golang/go#10527)
- Migrate to bencode library (https://github.com/zeebo/bencode)
- Explicitly ignore error handling on shutdown
- Code cleanup
- Remove obsolete TODOs
- Simplify ipAddr handling in announce
- Export ConfigMap from config
- Extract record into separate package
- Synchronously populate initial data from database into memory
- Support for archived whitelist entries
- Failsafe to ensure all IPs are always IPv4 only
- Allow to build without
scrape
andrecorder
via build tags
- Ensure down/up multipliers are always positive
- Make
transferHistory
wait inpurgeInactivePeers
atomic with add influshTransferHistory
- Ensure
transferHistoryWaitGroup
is released properly on loop break whentransferHistoryChannel
is empty - Do not break main loop in
flushTransferHistory
when channel is empty
- Rename whitelist table from
xbt_whitelist
toclient_whitelist
- Update torrent's
last_action
only if announced action is seeding - Increase AnnounceInterval, MinAnnounceInterval and PurgeInactiveInterval
- Update to MariaDB 10.3.3 syntax (https://mariadb.com/kb/en/library/values-value)
- Move external modules to
go.mod
- Check error value from
.Encode
during serialization - Remove
connectable
fromtransfer_history
flush - Code cleanup and formatting
- Support for disabling logging of IP for user
- Support for
no_peer_id
- Support for
ipv4
query string - Support for interval in
failure
- Ignore
paused
event (https://www.bittorrent.org/beps/bep_0021.html) - Cleanup unused code
- Have
interval
for announce include small drift in form ofmin(600, seeders)
- Default to compact responses unless explicitly asked for by
compact=0
- Bump default
numWant
from 20 to 25
- Add LICENSE
- Simple JSON announce recorder
- Handle SIGTERM in addition to INT for graceful restarts
- Support for group based freeleech
- Allow downloading Hit and Runs even if
DisableDownload
is set for user
- Returning 50 peers when the client asks for 0
- Fix peer inactivity query
- Broken bencode on
/scrape
- Swapped up/down multiplier for initial torrent load
- Ensure time delta is never higher than inactivity period
- Whitelist reloading was limited to 100 entries
- Run
go fmt
- Use linear falloff when handling deadlocks
- Make some config values more sane
- Stop disabling http/1.1 keep-alive
- Reduce peer ID collision potential
- Structure of
transfer_ips
was reworked to include more data
- Support for slots
- Add deserialization time logging
- Handle global freeleech
- Reactivate pruned torrents when a seeder announces
- Lock
mainConn
before closing it - Only start HTTP server after initializing the database
- Fix database reload timeouts occurring during a slot cache verification
- Fix race condition causing users to appear inactive but leaving them in the peer hash
- Force
Connection: close
- Suppress superfluous HTTP panic logging
- Sleep before verifying slots for the first time
- Switch to a better used slots verification strategy
- Only load enabled users
- Flush the peer on every announce to update the last announce time
- Support for reverse proxy via
X-Real-Ip
header - Deadlock handling
- Use multiple database connections
- Run
go fmt
- Flush torrent when a leecher becomes a seeder
- Log when done serializing
- Switch to
mymysql
(https://github.com/ziutek/mymysql)
- Initial release