Browse Source

Added syslog output

tags/1.0
Timo Röhling 12 years ago
parent
commit
df7a3836c4
1 changed files with 8 additions and 0 deletions
  1. 8
    0
      postsrsd.c

+ 8
- 0
postsrsd.c View File

29
 #include <string.h>
29
 #include <string.h>
30
 #include <poll.h>
30
 #include <poll.h>
31
 #include <wait.h>
31
 #include <wait.h>
32
+#include <syslog.h>
32
 
33
 
33
 #ifndef VERSION
34
 #ifndef VERSION
34
 #define VERSION "1.0"
35
 #define VERSION "1.0"
148
   if (result == SRS_SUCCESS) {
149
   if (result == SRS_SUCCESS) {
149
     output = url_encode(outputbuf, sizeof(outputbuf), value);
150
     output = url_encode(outputbuf, sizeof(outputbuf), value);
150
     fprintf (fp, "200 %s\n", output);
151
     fprintf (fp, "200 %s\n", output);
152
+    if (strcmp(address, value) != 0) syslog (LOG_MAIL | LOG_INFO, "srs_forward: <%s> rewritten as <%s>", address, value);
151
   } else {
153
   } else {
152
     fprintf (fp, "500 %s\n", srs_strerror(result));
154
     fprintf (fp, "500 %s\n", srs_strerror(result));
155
+    if (result != SRS_ENOTREWRITTEN)
156
+      syslog (LOG_MAIL | LOG_INFO, "srs_forward: <%s> not rewritten: %s", address, srs_strerror(result));
153
   }
157
   }
154
   fflush (fp);
158
   fflush (fp);
155
 }
159
 }
163
   if (result == SRS_SUCCESS) {
167
   if (result == SRS_SUCCESS) {
164
     output = url_encode(outputbuf, sizeof(outputbuf), value);
168
     output = url_encode(outputbuf, sizeof(outputbuf), value);
165
     fprintf (fp, "200 %s\n", output);
169
     fprintf (fp, "200 %s\n", output);
170
+    syslog (LOG_MAIL | LOG_INFO, "srs_reverse: <%s> rewritten as <%s>", address, value); 
166
   } else {
171
   } else {
167
     fprintf (fp, "500 %s\n", srs_strerror(result));
172
     fprintf (fp, "500 %s\n", srs_strerror(result));
173
+    if (result != SRS_ENOTREWRITTEN && result != SRS_ENOTSRSADDRESS)
174
+      syslog (LOG_MAIL | LOG_INFO, "srs_reverse: <%s> not rewritten: %s", address, srs_strerror(result));
168
   }
175
   }
169
   fflush (fp);
176
   fflush (fp);
170
 }
177
 }
332
     fclose (pf);
339
     fclose (pf);
333
   }
340
   }
334
 
341
 
342
+  openlog ("postsrsd", LOG_PID, LOG_MAIL);
335
   srs = srs_new();
343
   srs = srs_new();
336
   srs_add_secret (srs, secret);
344
   srs_add_secret (srs, secret);
337
   srs_set_separator (srs, '+');
345
   srs_set_separator (srs, '+');

Loading…
Cancel
Save