Browse Source

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

tags/1.3
nichivo 9 years ago
parent
commit
1d7e242fa6
2 changed files with 15 additions and 3 deletions
  1. 4
    0
      init/postsrsd.default.in
  2. 11
    3
      postsrsd.c

+ 4
- 0
init/postsrsd.default.in View File

13
 #
13
 #
14
 #SRS_EXCLUDE_DOMAINS=.example.com,example.org
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
 # Secret key to sign rewritten addresses.
20
 # Secret key to sign rewritten addresses.
17
 # When postsrsd is installed for the first time, a random secret is generated
21
 # When postsrsd is installed for the first time, a random secret is generated
18
 # and stored in /etc/postsrsd.secret. For most installations, that's just fine.
22
 # and stored in /etc/postsrsd.secret. For most installations, that's just fine.

+ 11
- 3
postsrsd.c View File

214
     "Options:\n"
214
     "Options:\n"
215
     "   -s<file>       read secrets from file (required)\n"
215
     "   -s<file>       read secrets from file (required)\n"
216
     "   -d<domain>     set domain name for rewrite (required)\n"
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
     "   -f<port>       set port for the forward SRS lookup (default: 10001)\n"
218
     "   -f<port>       set port for the forward SRS lookup (default: 10001)\n"
218
     "   -r<port>       set port for the reverse SRS lookup (default: 10002)\n"
219
     "   -r<port>       set port for the reverse SRS lookup (default: 10002)\n"
219
     "   -p<pidfile>    write process ID to pidfile (default: none)\n"
220
     "   -p<pidfile>    write process ID to pidfile (default: none)\n"
239
   int opt, timeout = 1800, family = AF_INET;
240
   int opt, timeout = 1800, family = AF_INET;
240
   int daemonize = FALSE;
241
   int daemonize = FALSE;
241
   char *forward_service = NULL, *reverse_service = NULL,
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
   int forward_sock, reverse_sock;
244
   int forward_sock, reverse_sock;
244
   char *secret_file = NULL, *pid_file = NULL;
245
   char *secret_file = NULL, *pid_file = NULL;
245
   FILE *pf = NULL, *sf = NULL;
246
   FILE *pf = NULL, *sf = NULL;
257
   tmp = strrchr(argv[0], '/');
258
   tmp = strrchr(argv[0], '/');
258
   if (tmp) self = strdup(tmp + 1); else self = strdup(argv[0]);
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
     switch (opt) {
262
     switch (opt) {
262
       case '?':
263
       case '?':
263
         return EXIT_FAILURE;
264
         return EXIT_FAILURE;
270
       case 'd':
271
       case 'd':
271
         domain = strdup(optarg);
272
         domain = strdup(optarg);
272
         break;
273
         break;
274
+      case 'a':
275
+        separator = (char)*optarg;
276
+        break;
273
       case 'f':
277
       case 'f':
274
         forward_service = strdup(optarg);
278
         forward_service = strdup(optarg);
275
         break;
279
         break;
318
       case 'e':
322
       case 'e':
319
         if ( getenv("SRS_DOMAIN") != NULL )
323
         if ( getenv("SRS_DOMAIN") != NULL )
320
           domain = strdup(getenv("SRS_DOMAIN"));
324
           domain = strdup(getenv("SRS_DOMAIN"));
325
+        if ( getenv("SRS_SEPARATOR") != NULL )
326
+          separator = (char)*getenv("SRS_SEPARATOR");
321
         if ( getenv("SRS_FORWARD_PORT") != NULL )
327
         if ( getenv("SRS_FORWARD_PORT") != NULL )
322
           forward_service = strdup(getenv("SRS_FORWARD_PORT"));
328
           forward_service = strdup(getenv("SRS_FORWARD_PORT"));
323
         if ( getenv("SRS_REVERSE_PORT") != NULL )
329
         if ( getenv("SRS_REVERSE_PORT") != NULL )
455
       srs_add_secret (srs, secret);
461
       srs_add_secret (srs, secret);
456
   }
462
   }
457
   fclose (sf);
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
   fds[0].fd = forward_sock;
468
   fds[0].fd = forward_sock;
461
   fds[0].events = POLLIN;
469
   fds[0].events = POLLIN;

Loading…
Cancel
Save