#include "server.h"
#define DAEMON_NAME "pfix-srsd"
+#define DAEMON_VERSION "0.1"
#define DEFAULT_ENCODER_PORT 10001
#define DEFAULT_DECODER_PORT 10002
#define RUNAS_USER "nobody"
nl = strchr(srsd->ibuf.data + 4, '\n');
if (!nl) {
if (srsd->ibuf.len > BUFSIZ) {
- syslog(LOG_ERR, "unreasonnable amount of data without a \\n");
+ err("unreasonnable amount of data without a \\n");
return -1;
}
if (srsd->obuf.len) {
}
if (strncmp("get ", srsd->ibuf.data, 4)) {
- syslog(LOG_ERR, "bad request, not starting with \"get \"");
+ err("bad request, not starting with \"get \"");
return -1;
}
if (p == q) {
buffer_addstr(&srsd->obuf, "400 empty request ???\n");
- syslog(LOG_WARNING, "empty request");
+ warn("empty request");
goto skip;
}
++lineno;
if (n == sizeof(buf) - 1 && buf[n - 1] != '\n') {
- syslog(LOG_CRIT, "%s:%d: line too long", sfile, lineno);
+ crit("%s:%d: line too long", sfile, lineno);
goto error;
}
m_strrtrim(buf);
}
if (!lineno) {
- syslog(LOG_CRIT, "%s: empty file, no secrets", sfile);
+ crit("%s: empty file, no secrets", sfile);
goto error;
}
}
}
+ if (!daemonize) {
+ log_syslog = false;
+ }
+
if (argc - optind != 2) {
usage();
return EXIT_FAILURE;
}
+ info("starting %s v%s...", DAEMON_NAME, DAEMON_VERSION);
+
config.domain = argv[optind];
config.srs = srs_read_secrets(argv[optind + 1]);
if (!config.srs
|| start_listener(port_dec, true) < 0) {
return EXIT_FAILURE;
}
- return server_loop(srsd_starter, NULL, process_srs, &config);
+ return server_loop(srsd_starter, NULL, process_srs, NULL, &config);
}