|
@@ -48,7 +48,7 @@
|
48
|
48
|
|
49
|
49
|
static char *self = NULL;
|
50
|
50
|
|
51
|
|
-static size_t bind_service (const char *service, int family, int* socks, size_t max_socks)
|
|
51
|
+static size_t bind_service (const char *listen_addr, const char *service, int family, int* socks, size_t max_socks)
|
52
|
52
|
{
|
53
|
53
|
struct addrinfo *addr, *it;
|
54
|
54
|
struct addrinfo hints;
|
|
@@ -60,7 +60,7 @@ static size_t bind_service (const char *service, int family, int* socks, size_t
|
60
|
60
|
hints.ai_family = family;
|
61
|
61
|
hints.ai_socktype = SOCK_STREAM;
|
62
|
62
|
|
63
|
|
- err = getaddrinfo(NULL, service, &hints, &addr);
|
|
63
|
+ err = getaddrinfo(listen_addr, service, &hints, &addr);
|
64
|
64
|
if (err != 0) {
|
65
|
65
|
fprintf(stderr, "%s: bind_service(%s): %s\n", self, service, gai_strerror(err));
|
66
|
66
|
return count;
|
|
@@ -219,6 +219,7 @@ 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
|
+ " -l<addr> set socket listen address (default: 127.0.0.1)\n"
|
222
|
223
|
" -f<port> set port for the forward SRS lookup (default: 10001)\n"
|
223
|
224
|
" -r<port> set port for the reverse SRS lookup (default: 10002)\n"
|
224
|
225
|
" -p<pidfile> write process ID to pidfile (default: none)\n"
|
|
@@ -243,7 +244,7 @@ int main (int argc, char **argv)
|
243
|
244
|
{
|
244
|
245
|
int opt, timeout = 1800, family = AF_UNSPEC;
|
245
|
246
|
int daemonize = FALSE;
|
246
|
|
- char *forward_service = NULL, *reverse_service = NULL,
|
|
247
|
+ char *listen_addr = NULL, *forward_service = NULL, *reverse_service = NULL,
|
247
|
248
|
*user = NULL, *domain = NULL, *chroot_dir = NULL;
|
248
|
249
|
char separator = '=';
|
249
|
250
|
char *secret_file = NULL, *pid_file = NULL;
|
|
@@ -264,7 +265,7 @@ int main (int argc, char **argv)
|
264
|
265
|
tmp = strrchr(argv[0], '/');
|
265
|
266
|
if (tmp) self = strdup(tmp + 1); else self = strdup(argv[0]);
|
266
|
267
|
|
267
|
|
- while ((opt = getopt(argc, argv, "46d:a:f:r:s:u:t:p:c:X::Dhev")) != -1) {
|
|
268
|
+ while ((opt = getopt(argc, argv, "46d:a:l:f:r:s:u:t:p:c:X::Dhev")) != -1) {
|
268
|
269
|
switch (opt) {
|
269
|
270
|
case '?':
|
270
|
271
|
return EXIT_FAILURE;
|
|
@@ -280,6 +281,9 @@ int main (int argc, char **argv)
|
280
|
281
|
case 'a':
|
281
|
282
|
separator = *optarg;
|
282
|
283
|
break;
|
|
284
|
+ case 'l':
|
|
285
|
+ listen_addr = strdup(optarg);
|
|
286
|
+ break;
|
283
|
287
|
case 'f':
|
284
|
288
|
forward_service = strdup(optarg);
|
285
|
289
|
break;
|
|
@@ -404,11 +408,11 @@ int main (int argc, char **argv)
|
404
|
408
|
return EXIT_FAILURE;
|
405
|
409
|
}
|
406
|
410
|
/* Bind ports. May require privileges if the config specifies ports below 1024 */
|
407
|
|
- sc = bind_service(forward_service, family, &sockets[socket_count], 4 - socket_count);
|
|
411
|
+ sc = bind_service(listen_addr, forward_service, family, &sockets[socket_count], 4 - socket_count);
|
408
|
412
|
if (sc == 0) return EXIT_FAILURE;
|
409
|
413
|
while (sc-- > 0) handler[socket_count++] = handle_forward;
|
410
|
414
|
free (forward_service);
|
411
|
|
- sc = bind_service(reverse_service, family, &sockets[socket_count], 4 - socket_count);
|
|
415
|
+ sc = bind_service(listen_addr, reverse_service, family, &sockets[socket_count], 4 - socket_count);
|
412
|
416
|
if (sc == 0) return EXIT_FAILURE;
|
413
|
417
|
while (sc-- > 0) handler[socket_count++] = handle_reverse;
|
414
|
418
|
free (reverse_service);
|