diff --git a/opentracker.c b/opentracker.c index e2e48f2..c36ceaa 100644 --- a/opentracker.c +++ b/opentracker.c @@ -35,12 +35,12 @@ /* Globals */ time_t g_now_seconds; -char * g_redirecturl = NULL; +char * g_redirecturl; uint32_t g_tracker_id; volatile int g_opentracker_running = 1; int g_self_pipe[2]; -static char * g_serverdir = NULL; +static char * g_serverdir; static void panic( const char *routine ) { fprintf( stderr, "%s: %s\n", routine, strerror(errno) ); @@ -368,6 +368,8 @@ int parse_configfile( char * config_filename ) { if( !scan_ip6( p+13, tmpip )) goto parse_error; accesslist_blessip( tmpip, OT_PERMISSION_MAY_STAT ); #endif + } else if(!byte_diff(p, 17, "access.stats_path" ) && isspace(p[17])) { + set_config_option( &g_stats_path, p+18 ); #ifdef WANT_IP_FROM_PROXY } else if(!byte_diff(p, 12, "access.proxy" ) && isspace(p[12])) { 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 @@ # # access.stats 192.168.0.23 # +# There is another way of hiding your stats. You can obfuscate the path +# to them. Normally it is located at /stats but you can configure it to +# appear anywhere on your tracker. +# +# access.stats_path stats # III) Live sync uses udp multicast packets to keep a cluster of opentrackers # synchronized. This option tells opentracker which port to listen for diff --git a/ot_http.c b/ot_http.c index 7d78fec..7640676 100644 --- a/ot_http.c +++ b/ot_http.c @@ -30,6 +30,9 @@ #define OT_MAXMULTISCRAPE_COUNT 64 extern char *g_redirecturl; +char *g_stats_path; +ssize_t g_stats_path_len; + enum { SUCCESS_HTTP_HEADER_LENGTH = 80, SUCCESS_HTTP_HEADER_LENGTH_CONTENT_ENCODING = 32, @@ -472,7 +475,7 @@ ssize_t http_handle_request( const int64 sock, struct ot_workstruct *ws ) { else if( !memcmp( write_ptr, "sc", 2 ) ) http_handle_scrape( sock, ws, read_ptr ); /* All the rest is matched the standard way */ - else if( !memcmp( write_ptr, "stats", 5) ) + else if( len == g_stats_path_len && !memcmp( write_ptr, g_stats_path, len ) ) http_handle_stats( sock, ws, read_ptr ); else HTTPERROR_404; diff --git a/ot_http.h b/ot_http.h index ced8160..84da0c2 100644 --- a/ot_http.h +++ b/ot_http.h @@ -27,4 +27,7 @@ ssize_t http_handle_request( const int64 s, struct ot_workstruct *ws ); ssize_t http_sendiovecdata( const int64 s, struct ot_workstruct *ws, int iovec_entries, struct iovec *iovector ); ssize_t http_issue_error( const int64 s, struct ot_workstruct *ws, int code ); +extern char *g_stats_path; +extern ssize_t g_stats_path_len; + #endif diff --git a/trackerlogic.c b/trackerlogic.c index d1ef063..f6128fd 100644 --- a/trackerlogic.c +++ b/trackerlogic.c @@ -15,12 +15,15 @@ /* Libowfat */ #include "byte.h" #include "io.h" +#include "iob.h" +#include "array.h" /* Opentracker */ #include "trackerlogic.h" #include "ot_mutex.h" #include "ot_stats.h" #include "ot_clean.h" +#include "ot_http.h" #include "ot_accesslist.h" #include "ot_fullscrape.h" #include "ot_livesync.h" @@ -394,6 +397,10 @@ void trackerlogic_init( ) { srandom( time(NULL) ); g_tracker_id = random(); + if( !g_stats_path ) + g_stats_path = "stats"; + g_stats_path_len = strlen( g_stats_path ); + /* Initialise background worker threads */ mutex_init( ); clean_init( );