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.
 
 
 
 

80 lines
2.6 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_ACCESSLIST_H__
  5. #define OT_ACCESSLIST_H__
  6. #if defined ( WANT_ACCESSLIST_BLACK ) && defined (WANT_ACCESSLIST_WHITE )
  7. # error WANT_ACCESSLIST_BLACK and WANT_ACCESSLIST_WHITE are exclusive.
  8. #endif
  9. #if defined ( WANT_ACCESSLIST_BLACK ) || defined (WANT_ACCESSLIST_WHITE )
  10. #define WANT_ACCESSLIST
  11. void accesslist_init( );
  12. void accesslist_deinit( );
  13. int accesslist_hashisvalid( ot_hash hash );
  14. extern char *g_accesslist_filename;
  15. #else
  16. #define accesslist_init( accesslist_filename )
  17. #define accesslist_deinit( )
  18. #define accesslist_hashisvalid( hash ) 1
  19. #endif
  20. /* Test if an address is subset of an ot_net, return value is considered a bool */
  21. int address_in_net( const ot_ip6 address, const ot_net *net );
  22. /* Store a value into a vector of struct { ot_net net, uint8_t[x] value } member;
  23. returns NULL
  24. if member_size is too small, or
  25. if one of the nets inside the vector are a subnet of _net_, or
  26. if _net_ is a subnet of one of the nets inside the vector, or
  27. if the vector could not be resized
  28. returns pointer to new member in vector for success
  29. member_size can be sizeof(ot_net) to reduce the lookup to a boolean mapping
  30. */
  31. void *set_value_for_net( const ot_net *net, ot_vector *vector, const void *value, const size_t member_size );
  32. /* Takes a vector filled with struct { ot_net net, uint8_t[x] value } member;
  33. Returns pointer to _member_ associated with the net, or NULL if not found
  34. member_size can be sizeof(ot_net) to reduce the lookup to a boolean mapping
  35. */
  36. void *get_value_for_net( const ot_ip6 address, const ot_vector *vector, const size_t member_size );
  37. #ifdef WANT_IP_FROM_PROXY
  38. int proxylist_add_network( const ot_net *proxy, const ot_net *net );
  39. int proxylist_check_network( const ot_ip6 *proxy, const ot_ip6 address /* can be NULL to only check proxy */ );
  40. #endif
  41. #ifdef WANT_FULLLOG_NETWORKS
  42. typedef struct ot_log ot_log;
  43. struct ot_log {
  44. ot_ip6 ip;
  45. uint8_t *data;
  46. size_t size;
  47. ot_time time;
  48. ot_log *next;
  49. };
  50. extern ot_log *g_logchain_first, *g_logchain_last;
  51. void loglist_add_network( const ot_net *net );
  52. void loglist_reset( );
  53. int loglist_check_address( const ot_ip6 address );
  54. #endif
  55. typedef enum {
  56. OT_PERMISSION_MAY_FULLSCRAPE = 0x1,
  57. OT_PERMISSION_MAY_STAT = 0x2,
  58. OT_PERMISSION_MAY_LIVESYNC = 0x4,
  59. OT_PERMISSION_MAY_PROXY = 0x8
  60. } ot_permissions;
  61. int accesslist_blessip( ot_ip6 ip, ot_permissions permissions );
  62. int accesslist_isblessed( ot_ip6 ip, ot_permissions permissions );
  63. #endif