Skip to content

A private tracker middleware for the chihaya BitTorrent tracker

License

Notifications You must be signed in to change notification settings

mrd0ll4r/chihaya-privtrak-middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

chihaya-privtrak-middleware

Build Status Go Report Card GoDoc IRC Channel

A private tracker middleware for the chihaya BitTorrent tracker.

go get -t -u github.com/mrd0ll4r/chihaya-privtrak-middleware

Features

  • In-memory storage of peer stats
  • Versatile user ID handling (anything unique that fits into 16 bytes works)
  • Generates deltas for user/infohash pairs
  • Batches deltas, hands them off to a DeltaHandler, for further processing
  • Purges stale peer stats
  • Built for concurrency

Non-Features

  • Doesn't check whether a user is allowed to announce. Write your own middleware for that, don't try to build one monolithic private tracker middleware.
  • Doesn't check whether an infohash/client/... is whitelisted. Same as above.

How to use this

the whole thing is in early stages, beware

Roughly, you need to do something like this:

  1. Implement a UserIdentifier to derive unique user IDs from requests. You could use HTTP/UDP optional parameters for this, or customized routes, or ... Just make sure the process is fast and reliable. Do not throw database queries in here, you WILL kill your tracker and/or DB. A sane way of doing this would be to issue 16-byte passkeys and just use them as user IDs.
  2. Implement a DeltaHandler to handle the deltas. You'd probably write these to a DB, or reprocess them first. They come in batches for a reason - don't insert them into a DB one by one. Before throwing them into a DB, you might want to
    • look up a user's numeric ID
    • look up the torrents numeric ID
    • (aggregate, possibly)
    • push them into an event processing system, for cool continuous queries
    • produce prometheus stats?
  3. Compile this middleware into your chihaya instance by adding a few lines in the cmd/chihay/config.go file.
  4. Adjust your config accordingly.

Expected issues

  • Should roughly double the memory usage of a tracker running optmem. It'd be elegant to merge the two somehow, but I don't see that happening soon.
  • Must run as a PreHook to throttle tracker throughput in case of a slow DeltaHandler. Otherwise we just get a goroutine explosion.

Future plans

  • Add an interface to deal with backup/restore functionality Basically, it needs to:

    1. Restore everything on startup
    2. Be notified whenever we remove a peer due to GC (maybe also stopped peers? What about partial seeds? What about paused downloads?)
    3. Figure out if we know a user/infohash combination before we create it from scratch
  • Possibly include IP/PeerID in the deltas? The DeltaHandler can figure out whether to remove these due to special user's protection.

License

MIT, see LICENSE

About

A private tracker middleware for the chihaya BitTorrent tracker

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages