|
|
@ -394,6 +394,42 @@ int parse_configfile( char * config_filename ) { |
|
|
|
return bound; |
|
|
|
return bound; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void load_state(const char * const state_filename ) { |
|
|
|
|
|
|
|
FILE * state_filehandle; |
|
|
|
|
|
|
|
char inbuf[512]; |
|
|
|
|
|
|
|
ot_hash infohash; |
|
|
|
|
|
|
|
unsigned long long base, downcount; |
|
|
|
|
|
|
|
int consumed; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
state_filehandle = fopen( state_filename, "r" ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( state_filehandle == NULL ) { |
|
|
|
|
|
|
|
fprintf( stderr, "Warning: Can't open config file: %s.", state_filename ); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* We do ignore anything that is not of the form "^[:xdigit:]:\d+:\d+" */ |
|
|
|
|
|
|
|
while( fgets( inbuf, sizeof(inbuf), state_filehandle ) ) { |
|
|
|
|
|
|
|
int i; |
|
|
|
|
|
|
|
for( i=0; i<(int)sizeof(ot_hash); ++i ) { |
|
|
|
|
|
|
|
int eger = 16 * scan_fromhex( inbuf[ 2*i ] ) + scan_fromhex( inbuf[ 1 + 2*i ] ); |
|
|
|
|
|
|
|
if( eger < 0 ) |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
infohash[i] = eger; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( i != (int)sizeof(ot_hash) ) continue; |
|
|
|
|
|
|
|
i *= 2; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( inbuf[ i++ ] != ':' || !( consumed = scan_ulonglong( inbuf+i, &base ) ) ) continue; |
|
|
|
|
|
|
|
i += consumed; |
|
|
|
|
|
|
|
if( inbuf[ i++ ] != ':' || !( consumed = scan_ulonglong( inbuf+i, &downcount ) ) ) continue; |
|
|
|
|
|
|
|
add_torrent_from_saved_state( infohash, base, downcount ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fclose( state_filehandle ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int drop_privileges (const char * const serverdir) { |
|
|
|
int drop_privileges (const char * const serverdir) { |
|
|
|
struct passwd *pws = NULL; |
|
|
|
struct passwd *pws = NULL; |
|
|
|
|
|
|
|
|
|
|
@ -448,7 +484,7 @@ int main( int argc, char **argv ) { |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
while( scanon ) { |
|
|
|
while( scanon ) { |
|
|
|
switch( getopt( argc, argv, ":i:p:A:P:d:r:s:f:v" |
|
|
|
switch( getopt( argc, argv, ":i:p:A:P:d:r:s:f:l:v" |
|
|
|
#ifdef WANT_ACCESSLIST_BLACK |
|
|
|
#ifdef WANT_ACCESSLIST_BLACK |
|
|
|
"b:" |
|
|
|
"b:" |
|
|
|
#elif defined( WANT_ACCESSLIST_WHITE ) |
|
|
|
#elif defined( WANT_ACCESSLIST_WHITE ) |
|
|
@ -477,6 +513,7 @@ while( scanon ) { |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
case 'd': set_config_option( &g_serverdir, optarg ); break; |
|
|
|
case 'd': set_config_option( &g_serverdir, optarg ); break; |
|
|
|
case 'r': set_config_option( &g_redirecturl, optarg ); break; |
|
|
|
case 'r': set_config_option( &g_redirecturl, optarg ); break; |
|
|
|
|
|
|
|
case 'l': load_state( optarg ); break; |
|
|
|
case 'A': |
|
|
|
case 'A': |
|
|
|
if( !scan_ip6( optarg, tmpip )) { usage( argv[0] ); exit( 1 ); } |
|
|
|
if( !scan_ip6( optarg, tmpip )) { usage( argv[0] ); exit( 1 ); } |
|
|
|
accesslist_blessip( tmpip, 0xffff ); /* Allow everything for now */ |
|
|
|
accesslist_blessip( tmpip, 0xffff ); /* Allow everything for now */ |
|
|
|