Преглед изворни кода

Add an argument for the first separator character after SRS0 and SRS1. The default is now = instead of +

tags/1.3
nichivo пре 9 година
родитељ
комит
1d7e242fa6
2 измењених фајлова са 15 додато и 3 уклоњено
  1. 4
    0
      init/postsrsd.default.in
  2. 11
    3
      postsrsd.c

+ 4
- 0
init/postsrsd.default.in Прегледај датотеку

@@ -13,6 +13,10 @@
13 13
 #
14 14
 #SRS_EXCLUDE_DOMAINS=.example.com,example.org
15 15
 
16
+# First separator character after SRS0 or SRS1.
17
+# Can be one of: -+=
18
+#SRS_SEPARATOR==
19
+
16 20
 # Secret key to sign rewritten addresses.
17 21
 # When postsrsd is installed for the first time, a random secret is generated
18 22
 # and stored in /etc/postsrsd.secret. For most installations, that's just fine.

+ 11
- 3
postsrsd.c Прегледај датотеку

@@ -214,6 +214,7 @@ static void show_help ()
214 214
     "Options:\n"
215 215
     "   -s<file>       read secrets from file (required)\n"
216 216
     "   -d<domain>     set domain name for rewrite (required)\n"
217
+    "   -a<char>       set first separator character which can be one of: -=+ (default: =)\n"
217 218
     "   -f<port>       set port for the forward SRS lookup (default: 10001)\n"
218 219
     "   -r<port>       set port for the reverse SRS lookup (default: 10002)\n"
219 220
     "   -p<pidfile>    write process ID to pidfile (default: none)\n"
@@ -239,7 +240,7 @@ int main (int argc, char **argv)
239 240
   int opt, timeout = 1800, family = AF_INET;
240 241
   int daemonize = FALSE;
241 242
   char *forward_service = NULL, *reverse_service = NULL,
242
-       *user = NULL, *domain = NULL, *chroot_dir = NULL;
243
+       *user = NULL, *domain = NULL, *chroot_dir = NULL, separator = NULL;
243 244
   int forward_sock, reverse_sock;
244 245
   char *secret_file = NULL, *pid_file = NULL;
245 246
   FILE *pf = NULL, *sf = NULL;
@@ -257,7 +258,7 @@ int main (int argc, char **argv)
257 258
   tmp = strrchr(argv[0], '/');
258 259
   if (tmp) self = strdup(tmp + 1); else self = strdup(argv[0]);
259 260
 
260
-  while ((opt = getopt(argc, argv, "46d:f:r:s:u:t:p:c:X::Dhev")) != -1) {
261
+  while ((opt = getopt(argc, argv, "46d:a:f:r:s:u:t:p:c:X::Dhev")) != -1) {
261 262
     switch (opt) {
262 263
       case '?':
263 264
         return EXIT_FAILURE;
@@ -270,6 +271,9 @@ int main (int argc, char **argv)
270 271
       case 'd':
271 272
         domain = strdup(optarg);
272 273
         break;
274
+      case 'a':
275
+        separator = (char)*optarg;
276
+        break;
273 277
       case 'f':
274 278
         forward_service = strdup(optarg);
275 279
         break;
@@ -318,6 +322,8 @@ int main (int argc, char **argv)
318 322
       case 'e':
319 323
         if ( getenv("SRS_DOMAIN") != NULL )
320 324
           domain = strdup(getenv("SRS_DOMAIN"));
325
+        if ( getenv("SRS_SEPARATOR") != NULL )
326
+          separator = (char)*getenv("SRS_SEPARATOR");
321 327
         if ( getenv("SRS_FORWARD_PORT") != NULL )
322 328
           forward_service = strdup(getenv("SRS_FORWARD_PORT"));
323 329
         if ( getenv("SRS_REVERSE_PORT") != NULL )
@@ -455,7 +461,9 @@ int main (int argc, char **argv)
455 461
       srs_add_secret (srs, secret);
456 462
   }
457 463
   fclose (sf);
458
-  srs_set_separator (srs, '+');
464
+  if (separator && srs_set_separator (srs, separator) != SRS_SUCCESS) {
465
+    srs_set_separator (srs, '=');
466
+  }
459 467
 
460 468
   fds[0].fd = forward_sock;
461 469
   fds[0].events = POLLIN;

Loading…
Откажи
Сачувај