Allow /stats to be located anywhere in your trackers path
parent
6abed54fd7
commit
b6fdc5433a
|
@ -2,7 +2,7 @@
|
|||
It is considered beerware. Prost. Skol. Cheers or whatever.
|
||||
Some of the stuff below is stolen from Fefes example libowfat httpd.
|
||||
|
||||
$Id: opentracker.c,v 1.221 2009/06/16 12:17:53 erdgeist Exp $ */
|
||||
$Id: opentracker.c,v 1.222 2009/06/17 15:06:31 erdgeist Exp $ */
|
||||
|
||||
/* System */
|
||||
#include <stdlib.h>
|
||||
|
@ -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;
|
||||
|
@ -564,4 +566,4 @@ while( scanon ) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
const char *g_version_opentracker_c = "$Source: /home/cvsroot/opentracker/opentracker.c,v $: $Revision: 1.221 $\n";
|
||||
const char *g_version_opentracker_c = "$Source: /home/cvsroot/opentracker/opentracker.c,v $: $Revision: 1.222 $\n";
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
@ -503,4 +506,4 @@ ssize_t http_handle_request( const int64 sock, struct ot_workstruct *ws ) {
|
|||
return ws->reply_size;
|
||||
}
|
||||
|
||||
const char *g_version_http_c = "$Source: /home/cvsroot/opentracker/ot_http.c,v $: $Revision: 1.37 $\n";
|
||||
const char *g_version_http_c = "$Source: /home/cvsroot/opentracker/ot_http.c,v $: $Revision: 1.38 $\n";
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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( );
|
||||
|
@ -431,4 +438,4 @@ void trackerlogic_deinit( void ) {
|
|||
mutex_deinit( );
|
||||
}
|
||||
|
||||
const char *g_version_trackerlogic_c = "$Source: /home/cvsroot/opentracker/trackerlogic.c,v $: $Revision: 1.129 $\n";
|
||||
const char *g_version_trackerlogic_c = "$Source: /home/cvsroot/opentracker/trackerlogic.c,v $: $Revision: 1.130 $\n";
|
||||
|
|
Loading…
Reference in New Issue