|
@@ -219,6 +219,8 @@ static void show_help ()
|
219
|
219
|
" -s<file> read secrets from file (required)\n"
|
220
|
220
|
" -d<domain> set domain name for rewrite (required)\n"
|
221
|
221
|
" -a<char> set first separator character which can be one of: -=+ (default: =)\n"
|
|
222
|
+ " -n<num> length of hash to be used in rewritten addresses (default: 4)\n"
|
|
223
|
+ " -N<num> minimum length of hash to accept for validation (default: 4)\n"
|
222
|
224
|
" -l<addr> set socket listen address (default: 127.0.0.1)\n"
|
223
|
225
|
" -f<port> set port for the forward SRS lookup (default: 10001)\n"
|
224
|
226
|
" -r<port> set port for the reverse SRS lookup (default: 10002)\n"
|
|
@@ -242,7 +244,7 @@ typedef void(*handle_t)(srs_t*, FILE*, const char*, const char*, const char**);
|
242
|
244
|
|
243
|
245
|
int main (int argc, char **argv)
|
244
|
246
|
{
|
245
|
|
- int opt, timeout = 1800, family = AF_UNSPEC;
|
|
247
|
+ int opt, timeout = 1800, family = AF_UNSPEC, hashlength = 0, hashmin = 0;
|
246
|
248
|
int daemonize = FALSE;
|
247
|
249
|
char *listen_addr = NULL, *forward_service = NULL, *reverse_service = NULL,
|
248
|
250
|
*user = NULL, *domain = NULL, *chroot_dir = NULL;
|
|
@@ -265,7 +267,7 @@ int main (int argc, char **argv)
|
265
|
267
|
tmp = strrchr(argv[0], '/');
|
266
|
268
|
if (tmp) self = strdup(tmp + 1); else self = strdup(argv[0]);
|
267
|
269
|
|
268
|
|
- while ((opt = getopt(argc, argv, "46d:a:l:f:r:s:u:t:p:c:X::Dhev")) != -1) {
|
|
270
|
+ while ((opt = getopt(argc, argv, "46d:a:l:f:r:s:n:N:u:t:p:c:X::Dhev")) != -1) {
|
269
|
271
|
switch (opt) {
|
270
|
272
|
case '?':
|
271
|
273
|
return EXIT_FAILURE;
|
|
@@ -296,6 +298,12 @@ int main (int argc, char **argv)
|
296
|
298
|
case 's':
|
297
|
299
|
secret_file = strdup(optarg);
|
298
|
300
|
break;
|
|
301
|
+ case 'n':
|
|
302
|
+ hashlength = atoi(optarg);
|
|
303
|
+ break;
|
|
304
|
+ case 'N':
|
|
305
|
+ hashmin = atoi(optarg);
|
|
306
|
+ break;
|
299
|
307
|
case 'p':
|
300
|
308
|
pid_file = strdup(optarg);
|
301
|
309
|
break;
|
|
@@ -334,6 +342,10 @@ int main (int argc, char **argv)
|
334
|
342
|
domain = strdup(getenv("SRS_DOMAIN"));
|
335
|
343
|
if ( getenv("SRS_SEPARATOR") != NULL )
|
336
|
344
|
separator = *getenv("SRS_SEPARATOR");
|
|
345
|
+ if ( getenv("SRS_HASHLENGTH") != NULL )
|
|
346
|
+ hashlength = atoi(getenv("SRS_HASHLENGTH"));
|
|
347
|
+ if ( getenv("SRS_HASHMIN") != NULL )
|
|
348
|
+ hashmin = atoi(getenv("SRS_HASHMIN"));
|
337
|
349
|
if ( getenv("SRS_FORWARD_PORT") != NULL )
|
338
|
350
|
forward_service = strdup(getenv("SRS_FORWARD_PORT"));
|
339
|
351
|
if ( getenv("SRS_REVERSE_PORT") != NULL )
|
|
@@ -473,6 +485,10 @@ int main (int argc, char **argv)
|
473
|
485
|
fclose (sf);
|
474
|
486
|
|
475
|
487
|
srs_set_separator (srs, separator);
|
|
488
|
+ if (hashlength)
|
|
489
|
+ srs_set_hashlength (srs, hashlength);
|
|
490
|
+ if (hashmin)
|
|
491
|
+ srs_set_hashmin (srs, hashmin);
|
476
|
492
|
|
477
|
493
|
for (sc = 0; sc < socket_count; ++sc) {
|
478
|
494
|
fds[sc].fd = sockets[sc];
|