Browse Source

Allow /stats to be located anywhere in your trackers path

dynamic-accesslists
erdgeist 16 years ago
parent
commit
65d7d9b89c
  1. 6
      opentracker.c
  2. 5
      opentracker.conf.sample
  3. 5
      ot_http.c
  4. 3
      ot_http.h
  5. 7
      trackerlogic.c

6
opentracker.c

@ -35,12 +35,12 @@
/* Globals */ /* Globals */
time_t g_now_seconds; time_t g_now_seconds;
char * g_redirecturl = NULL; char * g_redirecturl;
uint32_t g_tracker_id; uint32_t g_tracker_id;
volatile int g_opentracker_running = 1; volatile int g_opentracker_running = 1;
int g_self_pipe[2]; int g_self_pipe[2];
static char * g_serverdir = NULL; static char * g_serverdir;
static void panic( const char *routine ) { static void panic( const char *routine ) {
fprintf( stderr, "%s: %s\n", routine, strerror(errno) ); 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; if( !scan_ip6( p+13, tmpip )) goto parse_error;
accesslist_blessip( tmpip, OT_PERMISSION_MAY_STAT ); accesslist_blessip( tmpip, OT_PERMISSION_MAY_STAT );
#endif #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 #ifdef WANT_IP_FROM_PROXY
} else if(!byte_diff(p, 12, "access.proxy" ) && isspace(p[12])) { } else if(!byte_diff(p, 12, "access.proxy" ) && isspace(p[12])) {
if( !scan_ip6( p+13, tmpip )) goto parse_error; if( !scan_ip6( p+13, tmpip )) goto parse_error;

5
opentracker.conf.sample

@ -41,6 +41,11 @@
# #
# access.stats 192.168.0.23 # 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 # III) Live sync uses udp multicast packets to keep a cluster of opentrackers
# synchronized. This option tells opentracker which port to listen for # synchronized. This option tells opentracker which port to listen for

5
ot_http.c

@ -30,6 +30,9 @@
#define OT_MAXMULTISCRAPE_COUNT 64 #define OT_MAXMULTISCRAPE_COUNT 64
extern char *g_redirecturl; extern char *g_redirecturl;
char *g_stats_path;
ssize_t g_stats_path_len;
enum { enum {
SUCCESS_HTTP_HEADER_LENGTH = 80, SUCCESS_HTTP_HEADER_LENGTH = 80,
SUCCESS_HTTP_HEADER_LENGTH_CONTENT_ENCODING = 32, 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 ) ) else if( !memcmp( write_ptr, "sc", 2 ) )
http_handle_scrape( sock, ws, read_ptr ); http_handle_scrape( sock, ws, read_ptr );
/* All the rest is matched the standard way */ /* 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 ); http_handle_stats( sock, ws, read_ptr );
else else
HTTPERROR_404; HTTPERROR_404;

3
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_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 ); 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 #endif

7
trackerlogic.c

@ -15,12 +15,15 @@
/* Libowfat */ /* Libowfat */
#include "byte.h" #include "byte.h"
#include "io.h" #include "io.h"
#include "iob.h"
#include "array.h"
/* Opentracker */ /* Opentracker */
#include "trackerlogic.h" #include "trackerlogic.h"
#include "ot_mutex.h" #include "ot_mutex.h"
#include "ot_stats.h" #include "ot_stats.h"
#include "ot_clean.h" #include "ot_clean.h"
#include "ot_http.h"
#include "ot_accesslist.h" #include "ot_accesslist.h"
#include "ot_fullscrape.h" #include "ot_fullscrape.h"
#include "ot_livesync.h" #include "ot_livesync.h"
@ -394,6 +397,10 @@ void trackerlogic_init( ) {
srandom( time(NULL) ); srandom( time(NULL) );
g_tracker_id = random(); g_tracker_id = random();
if( !g_stats_path )
g_stats_path = "stats";
g_stats_path_len = strlen( g_stats_path );
/* Initialise background worker threads */ /* Initialise background worker threads */
mutex_init( ); mutex_init( );
clean_init( ); clean_init( );

Loading…
Cancel
Save