summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-11-23 09:29:59 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-11-23 09:29:59 +0000
commit62fee4b415f9c4e738f7fd5dea441dabe1244d2d (patch)
tree8f651ca15d66928912c0bd03d6ab9ba342f25e40
parent6a915b7a5c0424514d32d671a272236b10c75604 (diff)
downloadrspamd-62fee4b415f9c4e738f7fd5dea441dabe1244d2d.tar.gz
rspamd-62fee4b415f9c4e738f7fd5dea441dabe1244d2d.zip
Add 'reresolve' command to the control interface
-rw-r--r--src/libserver/rspamd_control.c33
-rw-r--r--src/libserver/rspamd_control.h7
-rw-r--r--src/rspamadm/control.c10
3 files changed, 45 insertions, 5 deletions
diff --git a/src/libserver/rspamd_control.c b/src/libserver/rspamd_control.c
index 5443b81a3..9e17f2120 100644
--- a/src/libserver/rspamd_control.c
+++ b/src/libserver/rspamd_control.c
@@ -69,17 +69,24 @@ static const struct rspamd_control_cmd_match {
{
.name = {
.begin = "/stat",
- .len = 5
+ .len = sizeof ("/stat") - 1
},
.type = RSPAMD_CONTROL_STAT
},
{
.name = {
.begin = "/reload",
- .len = 7
+ .len = sizeof ("/reload") - 1
},
.type = RSPAMD_CONTROL_RELOAD
},
+ {
+ .name = {
+ .begin = "/reresolve",
+ .len = sizeof ("/reresolve") - 1
+ },
+ .type = RSPAMD_CONTROL_RERESOLVE
+ },
};
void
@@ -190,6 +197,10 @@ rspamd_control_write_reply (struct rspamd_control_session *session)
ucl_object_insert_key (cur, ucl_object_fromint (
elt->reply.reply.reload.status), "status", 0, false);
break;
+ case RSPAMD_CONTROL_RERESOLVE:
+ ucl_object_insert_key (cur, ucl_object_fromint (
+ elt->reply.reply.reresolve.status), "status", 0, false);
+ break;
default:
break;
}
@@ -358,6 +369,7 @@ rspamd_control_default_cmd_handler (gint fd,
struct rspamd_control_reply rep;
gssize r;
struct rusage rusg;
+ struct rspamd_config *cfg;
memset (&rep, 0, sizeof (rep));
rep.type = cmd->type;
@@ -379,6 +391,23 @@ rspamd_control_default_cmd_handler (gint fd,
break;
case RSPAMD_CONTROL_RELOAD:
break;
+ case RSPAMD_CONTROL_RERESOLVE:
+ if (cd->worker->srv->cfg) {
+ REF_RETAIN (cd->worker->srv->cfg);
+ cfg = cd->worker->srv->cfg;
+
+ if (cfg->ups_ctx) {
+ msg_info_config ("reresolving upstreams");
+ rspamd_upstream_reresolve (cfg->ups_ctx);
+ }
+
+ rep.reply.reresolve.status = 0;
+ REF_RELEASE (cfg);
+ }
+ else {
+ rep.reply.reresolve.status = EINVAL;
+ }
+ break;
default:
break;
}
diff --git a/src/libserver/rspamd_control.h b/src/libserver/rspamd_control.h
index a41421afa..ddca143cc 100644
--- a/src/libserver/rspamd_control.h
+++ b/src/libserver/rspamd_control.h
@@ -34,6 +34,7 @@ struct rspamd_worker;
enum rspamd_control_type {
RSPAMD_CONTROL_STAT = 0,
RSPAMD_CONTROL_RELOAD,
+ RSPAMD_CONTROL_RERESOLVE,
RSPAMD_CONTROL_MAX
};
@@ -46,6 +47,9 @@ struct rspamd_control_command {
struct {
guint unused;
} reload;
+ struct {
+ guint unused;
+ } reresolve;
} cmd;
};
@@ -62,6 +66,9 @@ struct rspamd_control_reply {
struct {
guint status;
} reload;
+ struct {
+ guint status;
+ } reresolve;
} reply;
};
diff --git a/src/rspamadm/control.c b/src/rspamadm/control.c
index fc19277eb..42c17650a 100644
--- a/src/rspamadm/control.c
+++ b/src/rspamadm/control.c
@@ -76,7 +76,8 @@ rspamadm_control_help (gboolean full_help)
"--help: shows available options and commands\n\n"
"Supported commands:\n"
"stat - show statistics\n"
- "reload - reload workers dynamic data\n";
+ "reload - reload workers dynamic data\n"
+ "reresolve - resolve upstreams addresses\n";
}
else {
help_str = "Manage rspamd main control interface";
@@ -144,7 +145,7 @@ rspamadm_control (gint argc, gchar **argv)
gint sock;
context = g_option_context_new (
- "keypair - create encryption keys");
+ "control - manage rspamd main control interface");
g_option_context_set_summary (context,
"Summary:\n Rspamd administration utility version "
RVERSION
@@ -158,7 +159,7 @@ rspamadm_control (gint argc, gchar **argv)
exit (1);
}
- if (argc == 0) {
+ if (argc <= 1) {
rspamd_fprintf (stderr, "command required\n");
exit (1);
}
@@ -171,6 +172,9 @@ rspamadm_control (gint argc, gchar **argv)
else if (g_ascii_strcasecmp (cmd, "reload") == 0) {
path = "/reload";
}
+ else if (g_ascii_strcasecmp (cmd, "reresolve") == 0) {
+ path = "/reresolve";
+ }
else {
rspamd_fprintf (stderr, "unknown command: %s\n", cmd);
exit (1);