Module: kamailio
Branch: master
Commit: e7bf4fc9893107a4b52650b01c925c47c2d1a802
URL:
https://github.com/kamailio/kamailio/commit/e7bf4fc9893107a4b52650b01c925c4…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-01-04T23:10:47+01:00
userblacklist: implemented rpc command userblacklist.reload_blacklist
---
Modified: src/modules/userblacklist/doc/userblacklist_admin.xml
Modified: src/modules/userblacklist/userblacklist.c
---
Diff:
https://github.com/kamailio/kamailio/commit/e7bf4fc9893107a4b52650b01c925c4…
Patch:
https://github.com/kamailio/kamailio/commit/e7bf4fc9893107a4b52650b01c925c4…
---
diff --git a/src/modules/userblacklist/doc/userblacklist_admin.xml
b/src/modules/userblacklist/doc/userblacklist_admin.xml
index 263d9d0..2236248 100644
--- a/src/modules/userblacklist/doc/userblacklist_admin.xml
+++ b/src/modules/userblacklist/doc/userblacklist_admin.xml
@@ -383,7 +383,28 @@ if (!check_whitelist("globalblacklist")) {
</section>
<section>
- <title><acronym>MI</acronym> Commands</title>
+ <title>RPC Commands</title>
+ <section id="userblacklist.r.reload_blacklist">
+ <title>
+ <function
moreinfo="none">userblacklist.reload_blacklist</function>
+ </title>
+ <para>
+ Reload the internal global blacklist cache. This is necessary after
+ the database tables for the global blacklist have been changed.
+ </para>
+ <example>
+ <title><function>userblacklist.reload_blacklist</function>
usage</title>
+ <programlisting format="linespecific">
+...
+&kamcmd; userblacklist.reload_blacklist
+...
+ </programlisting>
+ </example>
+ </section>
+</section>
+
+<section>
+ <title>MI Commands</title>
<section>
<title>
<function moreinfo="none">reload_blacklist</function>
diff --git a/src/modules/userblacklist/userblacklist.c
b/src/modules/userblacklist/userblacklist.c
index 32fe98a..442e754 100644
--- a/src/modules/userblacklist/userblacklist.c
+++ b/src/modules/userblacklist/userblacklist.c
@@ -47,6 +47,7 @@
#include "../../core/error.h"
#include "../../core/ut.h"
#include "../../core/mod_fix.h"
+#include "../../core/rpc_lookup.h"
#include "../../lib/trie/dtrie.h"
#include "db.h"
@@ -1065,8 +1066,38 @@ struct mi_root * mi_check_userwhitelist(struct mi_root* cmd, void*
param)
}
#endif
+static void ubl_rpc_reload_blacklist(rpc_t* rpc, void* ctx)
+{
+ if(reload_sources() != 0) {
+ rpc->fault(ctx, 500, "Reload failed");
+ return;
+ }
+}
+
+static const char* ubl_rpc_reload_blacklist_doc[2] = {
+ "Reload user blacklist records.",
+ 0
+};
+
+rpc_export_t ubl_rpc[] = {
+ {"userblacklist.reload_blacklist", ubl_rpc_reload_blacklist,
+ ubl_rpc_reload_blacklist_doc, 0},
+ {0, 0, 0, 0}
+};
+
+static int ubl_rpc_init(void)
+{
+ if (rpc_register_array(ubl_rpc)!=0)
+ {
+ LM_ERR("failed to register RPC commands\n");
+ return -1;
+ }
+ return 0;
+}
+
static int mod_init(void)
{
+ if (ubl_rpc_init()<0) return -1;
if (userblacklist_db_init() != 0) return -1;
if (init_shmlock() != 0) return -1;
if (init_source_list() != 0) return -1;