An open and free bittorrent tracker https://erdgeist.org/gitweb/opentracker
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

73 lines
1.8 KiB

  1. /* This software was written by Dirk Engling <erdgeist@erdgeist.org>
  2. It is considered beerware. Prost. Skol. Cheers or whatever.
  3. $id$ */
  4. #ifndef OT_LIVESYNC_H__
  5. #define OT_LIVESYNC_H__
  6. #include "io.h"
  7. #include "trackerlogic.h"
  8. /*
  9. Syncing is done as udp packets in the multicast domain 224.0.42.5 port 9696
  10. Each tracker should join the multicast group and send its live sync packets
  11. to that group, using a ttl of 1
  12. Format of all sync packets is straight forward, packet type determines
  13. which kind of packet this is:
  14. 0x0000 0x04 id of tracker instance
  15. 0x0004 0x04 packet type
  16. ########
  17. ######## PEER SYNC PROTOCOL ########
  18. ########
  19. Each tracker instance accumulates announce requests until its buffer is
  20. full or a timeout is reached. Then it broadcasts its live sync packer:
  21. packet type SYNC_LIVE
  22. [ 0x0008 0x14 info_hash
  23. 0x001c 0x04 peer's ipv4 address
  24. 0x0020 0x02 peer's port
  25. 0x0024 0x02 peer flags v1 ( SEEDING = 0x80, COMPLETE = 0x40, STOPPED = 0x20 )
  26. ]*
  27. */
  28. #ifdef WANT_SYNC_LIVE
  29. #define LIVESYNC_PORT 9696
  30. void livesync_init();
  31. void livesync_deinit();
  32. /* Join multicast group for listening and create sending socket */
  33. void livesync_bind_mcast( char *ip, uint16_t port );
  34. /* Inform live sync about whats going on. */
  35. void livesync_tell( struct ot_workstruct *ws );
  36. /* Tickle the live sync module from time to time, so no events get
  37. stuck when there's not enough traffic to fill udp packets fast
  38. enough */
  39. void livesync_ticker( );
  40. /* Handle an incoming live sync packet */
  41. void handle_livesync( const int64 sock );
  42. #else
  43. /* If no syncing is required, save calling code from #ifdef
  44. constructions */
  45. #define livesync_deinit()
  46. #define livesync_init()
  47. #define livesync_ticker()
  48. #define handle_livesync(a)
  49. #endif
  50. #endif