aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2012-09-18 18:44:51 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2012-09-18 18:44:51 +0400
commitd071dc92a2b0f853309b1c450d739dd4bb69f108 (patch)
tree01daaac4e817a7b43abc48d9ec7d607c1b0e042d /src
parent2427ce2a633b2d03851997fce5472e1c3913be72 (diff)
downloadrspamd-d071dc92a2b0f853309b1c450d739dd4bb69f108.tar.gz
rspamd-d071dc92a2b0f853309b1c450d739dd4bb69f108.zip
Remove legacy stuff from librspamdclient.
Add support of unix socket for client library and rspamc.
Diffstat (limited to 'src')
-rw-r--r--src/client/rspamc.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/src/client/rspamc.c b/src/client/rspamc.c
index 7d88ea65c..1c7eaf318 100644
--- a/src/client/rspamc.c
+++ b/src/client/rspamc.c
@@ -149,27 +149,36 @@ add_rspamd_server (gboolean is_control)
fprintf (stderr, "cannot connect to rspamd server - empty string\n");
exit (EXIT_FAILURE);
}
- vec = g_strsplit_set (connect_str, ":", 2);
- if (vec == NULL || *vec == NULL) {
- fprintf (stderr, "cannot connect to rspamd server: %s\n", connect_str);
- exit (EXIT_FAILURE);
- }
+ if (*connect_str != '/') {
+ vec = g_strsplit_set (connect_str, ":", 2);
+ if (vec == NULL || *vec == NULL) {
+ fprintf (stderr, "cannot connect to rspamd server: %s\n", connect_str);
+ exit (EXIT_FAILURE);
+ }
- if (vec[1] == NULL) {
- port = is_control ? DEFAULT_CONTROL_PORT : DEFAULT_PORT;
+ if (vec[1] == NULL) {
+ port = is_control ? DEFAULT_CONTROL_PORT : DEFAULT_PORT;
+ }
+ else {
+ port = strtoul (vec[1], &err_str, 10);
+ if (*err_str != '\0') {
+ fprintf (stderr, "cannot connect to rspamd server: %s, at pos %s\n", connect_str, err_str);
+ exit (EXIT_FAILURE);
+ }
+ }
+ if (! rspamd_add_server (client, vec[0], port, port, &err)) {
+ fprintf (stderr, "cannot connect to rspamd server: %s, error: %s\n", connect_str, err->message);
+ exit (EXIT_FAILURE);
+ }
}
else {
- port = strtoul (vec[1], &err_str, 10);
- if (*err_str != '\0') {
- fprintf (stderr, "cannot connect to rspamd server: %s, at pos %s\n", connect_str, err_str);
+ /* Unix socket version */
+ if (! rspamd_add_server (client, connect_str, 0, 0, &err)) {
+ fprintf (stderr, "cannot connect to rspamd server: %s, error: %s\n", connect_str, err->message);
exit (EXIT_FAILURE);
}
}
- if (! rspamd_add_server (client, vec[0], port, port, &err)) {
- fprintf (stderr, "cannot connect to rspamd server: %s, error: %s\n", connect_str, err->message);
- exit (EXIT_FAILURE);
- }
}
static void