summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile23
-rw-r--r--Makefile.arc4random3
-rw-r--r--Makefile.gzip4
-rw-r--r--Makefile.zstd3
-rw-r--r--man4/opentracker.conf.410
-rw-r--r--ot_http.c2
-rw-r--r--ot_stats.c26
7 files changed, 49 insertions, 22 deletions
diff --git a/Makefile b/Makefile
index e5ca6e4..706b742 100644
--- a/Makefile
+++ b/Makefile
@@ -18,19 +18,23 @@ LIBOWFAT_LIBRARY=$(PREFIX)/libowfat
18BINDIR?=$(PREFIX)/bin 18BINDIR?=$(PREFIX)/bin
19STRIP?=strip 19STRIP?=strip
20 20
21#FEATURES+=-DWAND_V4_ONLY 21#FEATURES+=-DWANT_V4_ONLY
22#FEATURES+=-DWANT_ACCESSLIST_BLACK 22#FEATURES+=-DWANT_ACCESSLIST_BLACK
23#FEATURES+=-DWANT_ACCESSLIST_WHITE 23#FEATURES+=-DWANT_ACCESSLIST_WHITE
24#FEATURES+=-DWANT_DYNAMIC_ACCESSLIST 24#FEATURES+=-DWANT_DYNAMIC_ACCESSLIST
25 25
26#FEATURES+=-DWANT_SYNC_LIVE 26#FEATURES+=-DWANT_SYNC_LIVE
27#FEATURES+=-DWANT_IP_FROM_QUERY_STRING 27#FEATURES+=-DWANT_IP_FROM_QUERY_STRING
28FEATURES+=-DWANT_COMPRESSION_GZIP
29FEATURES+=-DWANT_COMPRESSION_GZIP_ALWAYS
30 28
31#FEATURES+=-DWANT_COMPRESSION_ZSTD 29# If you want gzip support to be compiled in, uncomment the next include.
32#FEATURES+=-DWANT_COMPRESSION_ZSTD_ALWAYS 30# You can further modify the behaviour by setting DWANT_COMPRESSION_GZIP_ALWAYS
33#LDFLAGS+=-lzstd 31# in Makefile.gzip
32include Makefile.gzip
33
34# If you want zstd support to be compiled in, uncomment the next include.
35# You can further modify the behaviour by setting DWANT_COMPRESSION_ZSTD_ALWAYS
36# in Makefile.zstd
37#include Makefile.zstd
34 38
35#FEATURES+=-DWANT_LOG_NETWORKS 39#FEATURES+=-DWANT_LOG_NETWORKS
36#FEATURES+=-DWANT_RESTRICT_STATS 40#FEATURES+=-DWANT_RESTRICT_STATS
@@ -48,8 +52,8 @@ FEATURES+=-DWANT_FULLSCRAPE
48#FEATURES+=-DWANT_NO_AUTO_FREE 52#FEATURES+=-DWANT_NO_AUTO_FREE
49 53
50# Is enabled on BSD systems by default in trackerlogic.h 54# Is enabled on BSD systems by default in trackerlogic.h
51# on Linux systems you will need -lbds 55# on Linux systems the include Makefile adds -lbsd
52#FEATURES+=-DWANT_ARC4RANDOM 56#include Makefile.arc4random
53 57
54#FEATURES+=-D_DEBUG_HTTPERROR 58#FEATURES+=-D_DEBUG_HTTPERROR
55#FEATURES+=-D_DEBUG_RANDOMTORRENTS 59#FEATURES+=-D_DEBUG_RANDOMTORRENTS
@@ -60,8 +64,7 @@ OPTS_debug=-D_DEBUG -g -ggdb # -pg -fprofile-arcs -ftest-coverage
60OPTS_production=-O3 64OPTS_production=-O3
61 65
62CFLAGS+=-I$(LIBOWFAT_HEADERS) -DGIT_VERSION=$(GIT_VERSION) -Wall -pipe -pthread -Wextra #-ansi -pedantic 66CFLAGS+=-I$(LIBOWFAT_HEADERS) -DGIT_VERSION=$(GIT_VERSION) -Wall -pipe -pthread -Wextra #-ansi -pedantic
63LDFLAGS+=-L$(LIBOWFAT_LIBRARY) -lowfat -pthread -lz 67LDFLAGS+=-L$(LIBOWFAT_LIBRARY) -lowfat -pthread
64#LDFLAGS+=-lbsd
65 68
66BINARY =opentracker 69BINARY =opentracker
67HEADERS=trackerlogic.h scan_urlencoded_query.h ot_mutex.h ot_stats.h ot_vector.h ot_clean.h ot_udp.h ot_iovec.h ot_fullscrape.h ot_accesslist.h ot_http.h ot_livesync.h ot_rijndael.h 70HEADERS=trackerlogic.h scan_urlencoded_query.h ot_mutex.h ot_stats.h ot_vector.h ot_clean.h ot_udp.h ot_iovec.h ot_fullscrape.h ot_accesslist.h ot_http.h ot_livesync.h ot_rijndael.h
diff --git a/Makefile.arc4random b/Makefile.arc4random
new file mode 100644
index 0000000..1488408
--- /dev/null
+++ b/Makefile.arc4random
@@ -0,0 +1,3 @@
1FEATURES+=-DWANT_ARC4RANDOM
2LDFLAGS+=-lbsd
3
diff --git a/Makefile.gzip b/Makefile.gzip
new file mode 100644
index 0000000..70d6d62
--- /dev/null
+++ b/Makefile.gzip
@@ -0,0 +1,4 @@
1FEATURES+=-DWANT_COMPRESSION_GZIP
2#FEATURES+=-DWANT_COMPRESSION_GZIP_ALWAYS
3
4LDFLAGS+=-lz
diff --git a/Makefile.zstd b/Makefile.zstd
new file mode 100644
index 0000000..2bb56be
--- /dev/null
+++ b/Makefile.zstd
@@ -0,0 +1,3 @@
1FEATURES+=-DWANT_COMPRESSION_ZSTD
2#FEATURES+=-DWANT_COMPRESSION_ZSTD_ALWAYS
3LDFLAGS+=-lzstd
diff --git a/man4/opentracker.conf.4 b/man4/opentracker.conf.4
index 4b68121..b4f5f51 100644
--- a/man4/opentracker.conf.4
+++ b/man4/opentracker.conf.4
@@ -17,13 +17,13 @@ The following options are available:
17 17
18.Bl -tag -width ".It access.proxy" -compact 18.Bl -tag -width ".It access.proxy" -compact
19.It listen.tcp_udp Ar address 19.It listen.tcp_udp Ar address
20Specifies the address opentracker will listen on for both TCP and UDP connections. If not specified, opentracker listens on 0.0.0.0:6969 by default. 20Specifies an address opentracker will listen on for both TCP and UDP connections. If none are specified, opentracker listens on 0.0.0.0:6969 by default. Can be added more than once.
21 21
22.It listen.tcp Ar address 22.It listen.tcp Ar address
23Specifies the address opentracker will listen on for TCP connections. 23Specifies the address opentracker will listen on for TCP connections. Can be added more than once.
24 24
25.It listen.udp Ar address 25.It listen.udp Ar address
26Specifies the address opentracker will listen on for UDP connections. 26Specifies the address opentracker will listen on for UDP connections. Can be added more than once.
27 27
28.It listen.udp.workers Ar threads 28.It listen.udp.workers Ar threads
29Specifies how many threads will be spawned to handle UDP connections. Defaults to 4. 29Specifies how many threads will be spawned to handle UDP connections. Defaults to 4.
@@ -47,13 +47,13 @@ Specifies the IP address or network in CIDR notation allowed to fetch stats from
47Specifies the path to the stats location. You can configure opentracker to appear anywhere on your tracker. Defaults to /stats. 47Specifies the path to the stats location. You can configure opentracker to appear anywhere on your tracker. Defaults to /stats.
48 48
49.It access.proxy Ar ip_address_or_network 49.It access.proxy Ar ip_address_or_network
50Specifies the IP address or network of the reverse proxies. Opentracker will take the X-Forwarded-For address instead of the source IP address. 50Specifies the IP address or network of the reverse proxies. Opentracker will take the X-Forwarded-For address instead of the source IP address. Can be added more than once.
51 51
52.It livesync.cluster.listen Ar ip_address:port 52.It livesync.cluster.listen Ar ip_address:port
53Specifies the IP address and port opentracker will listen on for incoming live sync packets to keep a cluster of opentrackers synchronized. 53Specifies the IP address and port opentracker will listen on for incoming live sync packets to keep a cluster of opentrackers synchronized.
54 54
55.It livesync.cluster.node_ip Ar ip_address 55.It livesync.cluster.node_ip Ar ip_address
56Specifies the trusted IP address for sync between trackers running in a cluster. 56Specifies one trusted IP address for sync between trackers running in a cluster. Can be added more than once.
57 57
58.It batchsync.cluster.admin_ip Ar ip_address 58.It batchsync.cluster.admin_ip Ar ip_address
59Specifies the admin IP address for old-style (HTTP-based) asynchronous tracker syncing. 59Specifies the admin IP address for old-style (HTTP-based) asynchronous tracker syncing.
diff --git a/ot_http.c b/ot_http.c
index af3f210..5c622e2 100644
--- a/ot_http.c
+++ b/ot_http.c
@@ -4,9 +4,9 @@
4 $id$ */ 4 $id$ */
5 5
6/* System */ 6/* System */
7#define _GNU_SOURCE
7#include <arpa/inet.h> 8#include <arpa/inet.h>
8#include <pthread.h> 9#include <pthread.h>
9#define _GNU_SOURCE
10#include <stdio.h> 10#include <stdio.h>
11#include <stdlib.h> 11#include <stdlib.h>
12#include <string.h> 12#include <string.h>
diff --git a/ot_stats.c b/ot_stats.c
index 158884f..b2eaec9 100644
--- a/ot_stats.c
+++ b/ot_stats.c
@@ -320,7 +320,7 @@ typedef struct {
320/* Fetches stats from tracker */ 320/* Fetches stats from tracker */
321size_t stats_top_txt(char *reply, int amount) { 321size_t stats_top_txt(char *reply, int amount) {
322 size_t j; 322 size_t j;
323 ot_record top100s[100], top100c[100]; 323 ot_record top100s[100], top100c[100], top100l[100];
324 char *r = reply, hex_out[42]; 324 char *r = reply, hex_out[42];
325 int idx, bucket; 325 int idx, bucket;
326 326
@@ -329,14 +329,16 @@ size_t stats_top_txt(char *reply, int amount) {
329 329
330 byte_zero(top100s, sizeof(top100s)); 330 byte_zero(top100s, sizeof(top100s));
331 byte_zero(top100c, sizeof(top100c)); 331 byte_zero(top100c, sizeof(top100c));
332 byte_zero(top100l, sizeof(top100l));
332 333
333 for (bucket = 0; bucket < OT_BUCKET_COUNT; ++bucket) { 334 for (bucket = 0; bucket < OT_BUCKET_COUNT; ++bucket) {
334 ot_vector *torrents_list = mutex_bucket_lock(bucket); 335 ot_vector *torrents_list = mutex_bucket_lock(bucket);
335 for (j = 0; j < torrents_list->size; ++j) { 336 for (j = 0; j < torrents_list->size; ++j) {
336 ot_torrent *torrent = (ot_torrent *)(torrents_list->data) + j; 337 ot_torrent *torrent = (ot_torrent *)(torrents_list->data) + j;
337 size_t peer_count = torrent->peer_list6->peer_count + torrent->peer_list4->peer_count; 338 size_t peer_count = torrent->peer_list6->peer_count + torrent->peer_list4->peer_count;
338 size_t seed_count = torrent->peer_list6->seed_count + torrent->peer_list4->seed_count; 339 size_t seed_count = torrent->peer_list6->seed_count + torrent->peer_list4->seed_count;
339 idx = amount - 1; 340 size_t leech_count = peer_count - seed_count;
341 idx = amount - 1;
340 while ((idx >= 0) && (peer_count > top100c[idx].val)) 342 while ((idx >= 0) && (peer_count > top100c[idx].val))
341 --idx; 343 --idx;
342 if (idx++ != amount - 1) { 344 if (idx++ != amount - 1) {
@@ -352,6 +354,14 @@ size_t stats_top_txt(char *reply, int amount) {
352 memcpy(&top100s[idx].hash, &torrent->hash, sizeof(ot_hash)); 354 memcpy(&top100s[idx].hash, &torrent->hash, sizeof(ot_hash));
353 top100s[idx].val = seed_count; 355 top100s[idx].val = seed_count;
354 } 356 }
357 idx = amount - 1;
358 while ((idx >= 0) && (leech_count > top100l[idx].val))
359 --idx;
360 if (idx++ != amount - 1) {
361 memmove(top100l + idx + 1, top100l + idx, (amount - 1 - idx) * sizeof(ot_record));
362 memcpy(&top100l[idx].hash, &torrent->hash, sizeof(ot_hash));
363 top100l[idx].val = leech_count;
364 }
355 } 365 }
356 mutex_bucket_unlock(bucket, 0); 366 mutex_bucket_unlock(bucket, 0);
357 if (!g_opentracker_running) 367 if (!g_opentracker_running)
@@ -366,6 +376,10 @@ size_t stats_top_txt(char *reply, int amount) {
366 for (idx = 0; idx < amount; ++idx) 376 for (idx = 0; idx < amount; ++idx)
367 if (top100s[idx].val) 377 if (top100s[idx].val)
368 r += sprintf(r, "\t%zd\t%s\n", top100s[idx].val, to_hex(hex_out, top100s[idx].hash)); 378 r += sprintf(r, "\t%zd\t%s\n", top100s[idx].val, to_hex(hex_out, top100s[idx].hash));
379 r += sprintf(r, "Top %d torrents by leechers:\n", amount);
380 for (idx = 0; idx < amount; ++idx)
381 if (top100l[idx].val)
382 r += sprintf(r, "\t%zd\t%s\n", top100l[idx].val, to_hex(hex_out, top100l[idx].hash));
369 383
370 return r - reply; 384 return r - reply;
371} 385}