diff options
| author | erdgeist <> | 2009-06-17 15:06:31 +0000 |
|---|---|---|
| committer | erdgeist <> | 2009-06-17 15:06:31 +0000 |
| commit | 65d7d9b89cc44b85d5ef8522276f04c53846acf2 (patch) | |
| tree | d45907fdefb44d0525ffe7512fe63ea93eb41d51 | |
| parent | 2a17f847aeb948d1f788b3454fa66b905ba2f28a (diff) | |
Allow /stats to be located anywhere in your trackers path
| -rw-r--r-- | opentracker.c | 6 | ||||
| -rw-r--r-- | opentracker.conf.sample | 5 | ||||
| -rw-r--r-- | ot_http.c | 5 | ||||
| -rw-r--r-- | ot_http.h | 3 | ||||
| -rw-r--r-- | trackerlogic.c | 7 |
5 files changed, 23 insertions, 3 deletions
diff --git a/opentracker.c b/opentracker.c index e2e48f2..c36ceaa 100644 --- a/opentracker.c +++ b/opentracker.c | |||
| @@ -35,12 +35,12 @@ | |||
| 35 | 35 | ||
| 36 | /* Globals */ | 36 | /* Globals */ |
| 37 | time_t g_now_seconds; | 37 | time_t g_now_seconds; |
| 38 | char * g_redirecturl = NULL; | 38 | char * g_redirecturl; |
| 39 | uint32_t g_tracker_id; | 39 | uint32_t g_tracker_id; |
| 40 | volatile int g_opentracker_running = 1; | 40 | volatile int g_opentracker_running = 1; |
| 41 | int g_self_pipe[2]; | 41 | int g_self_pipe[2]; |
| 42 | 42 | ||
| 43 | static char * g_serverdir = NULL; | 43 | static char * g_serverdir; |
| 44 | 44 | ||
| 45 | static void panic( const char *routine ) { | 45 | static void panic( const char *routine ) { |
| 46 | fprintf( stderr, "%s: %s\n", routine, strerror(errno) ); | 46 | fprintf( stderr, "%s: %s\n", routine, strerror(errno) ); |
| @@ -368,6 +368,8 @@ int parse_configfile( char * config_filename ) { | |||
| 368 | if( !scan_ip6( p+13, tmpip )) goto parse_error; | 368 | if( !scan_ip6( p+13, tmpip )) goto parse_error; |
| 369 | accesslist_blessip( tmpip, OT_PERMISSION_MAY_STAT ); | 369 | accesslist_blessip( tmpip, OT_PERMISSION_MAY_STAT ); |
| 370 | #endif | 370 | #endif |
| 371 | } else if(!byte_diff(p, 17, "access.stats_path" ) && isspace(p[17])) { | ||
| 372 | set_config_option( &g_stats_path, p+18 ); | ||
| 371 | #ifdef WANT_IP_FROM_PROXY | 373 | #ifdef WANT_IP_FROM_PROXY |
| 372 | } else if(!byte_diff(p, 12, "access.proxy" ) && isspace(p[12])) { | 374 | } else if(!byte_diff(p, 12, "access.proxy" ) && isspace(p[12])) { |
| 373 | if( !scan_ip6( p+13, tmpip )) goto parse_error; | 375 | if( !scan_ip6( p+13, tmpip )) goto parse_error; |
diff --git a/opentracker.conf.sample b/opentracker.conf.sample index 50cbd3c..9cad622 100644 --- a/opentracker.conf.sample +++ b/opentracker.conf.sample | |||
| @@ -41,6 +41,11 @@ | |||
| 41 | # | 41 | # |
| 42 | # access.stats 192.168.0.23 | 42 | # access.stats 192.168.0.23 |
| 43 | # | 43 | # |
| 44 | # There is another way of hiding your stats. You can obfuscate the path | ||
| 45 | # to them. Normally it is located at /stats but you can configure it to | ||
| 46 | # appear anywhere on your tracker. | ||
| 47 | # | ||
| 48 | # access.stats_path stats | ||
| 44 | 49 | ||
| 45 | # III) Live sync uses udp multicast packets to keep a cluster of opentrackers | 50 | # III) Live sync uses udp multicast packets to keep a cluster of opentrackers |
| 46 | # synchronized. This option tells opentracker which port to listen for | 51 | # synchronized. This option tells opentracker which port to listen for |
| @@ -30,6 +30,9 @@ | |||
| 30 | #define OT_MAXMULTISCRAPE_COUNT 64 | 30 | #define OT_MAXMULTISCRAPE_COUNT 64 |
| 31 | extern char *g_redirecturl; | 31 | extern char *g_redirecturl; |
| 32 | 32 | ||
| 33 | char *g_stats_path; | ||
| 34 | ssize_t g_stats_path_len; | ||
| 35 | |||
| 33 | enum { | 36 | enum { |
| 34 | SUCCESS_HTTP_HEADER_LENGTH = 80, | 37 | SUCCESS_HTTP_HEADER_LENGTH = 80, |
| 35 | SUCCESS_HTTP_HEADER_LENGTH_CONTENT_ENCODING = 32, | 38 | SUCCESS_HTTP_HEADER_LENGTH_CONTENT_ENCODING = 32, |
| @@ -472,7 +475,7 @@ ssize_t http_handle_request( const int64 sock, struct ot_workstruct *ws ) { | |||
| 472 | else if( !memcmp( write_ptr, "sc", 2 ) ) | 475 | else if( !memcmp( write_ptr, "sc", 2 ) ) |
| 473 | http_handle_scrape( sock, ws, read_ptr ); | 476 | http_handle_scrape( sock, ws, read_ptr ); |
| 474 | /* All the rest is matched the standard way */ | 477 | /* All the rest is matched the standard way */ |
| 475 | else if( !memcmp( write_ptr, "stats", 5) ) | 478 | else if( len == g_stats_path_len && !memcmp( write_ptr, g_stats_path, len ) ) |
| 476 | http_handle_stats( sock, ws, read_ptr ); | 479 | http_handle_stats( sock, ws, read_ptr ); |
| 477 | else | 480 | else |
| 478 | HTTPERROR_404; | 481 | HTTPERROR_404; |
| @@ -27,4 +27,7 @@ ssize_t http_handle_request( const int64 s, struct ot_workstruct *ws ); | |||
| 27 | ssize_t http_sendiovecdata( const int64 s, struct ot_workstruct *ws, int iovec_entries, struct iovec *iovector ); | 27 | ssize_t http_sendiovecdata( const int64 s, struct ot_workstruct *ws, int iovec_entries, struct iovec *iovector ); |
| 28 | ssize_t http_issue_error( const int64 s, struct ot_workstruct *ws, int code ); | 28 | ssize_t http_issue_error( const int64 s, struct ot_workstruct *ws, int code ); |
| 29 | 29 | ||
| 30 | extern char *g_stats_path; | ||
| 31 | extern ssize_t g_stats_path_len; | ||
| 32 | |||
| 30 | #endif | 33 | #endif |
diff --git a/trackerlogic.c b/trackerlogic.c index d1ef063..f6128fd 100644 --- a/trackerlogic.c +++ b/trackerlogic.c | |||
| @@ -15,12 +15,15 @@ | |||
| 15 | /* Libowfat */ | 15 | /* Libowfat */ |
| 16 | #include "byte.h" | 16 | #include "byte.h" |
| 17 | #include "io.h" | 17 | #include "io.h" |
| 18 | #include "iob.h" | ||
| 19 | #include "array.h" | ||
| 18 | 20 | ||
| 19 | /* Opentracker */ | 21 | /* Opentracker */ |
| 20 | #include "trackerlogic.h" | 22 | #include "trackerlogic.h" |
| 21 | #include "ot_mutex.h" | 23 | #include "ot_mutex.h" |
| 22 | #include "ot_stats.h" | 24 | #include "ot_stats.h" |
| 23 | #include "ot_clean.h" | 25 | #include "ot_clean.h" |
| 26 | #include "ot_http.h" | ||
| 24 | #include "ot_accesslist.h" | 27 | #include "ot_accesslist.h" |
| 25 | #include "ot_fullscrape.h" | 28 | #include "ot_fullscrape.h" |
| 26 | #include "ot_livesync.h" | 29 | #include "ot_livesync.h" |
| @@ -394,6 +397,10 @@ void trackerlogic_init( ) { | |||
| 394 | srandom( time(NULL) ); | 397 | srandom( time(NULL) ); |
| 395 | g_tracker_id = random(); | 398 | g_tracker_id = random(); |
| 396 | 399 | ||
| 400 | if( !g_stats_path ) | ||
| 401 | g_stats_path = "stats"; | ||
| 402 | g_stats_path_len = strlen( g_stats_path ); | ||
| 403 | |||
| 397 | /* Initialise background worker threads */ | 404 | /* Initialise background worker threads */ |
| 398 | mutex_init( ); | 405 | mutex_init( ); |
| 399 | clean_init( ); | 406 | clean_init( ); |
