瀏覽代碼

kamailio.cfg: added sample usage of xmlrpc module

- enabled with #!define WITH_XMLRPC
- based on ser.cfg version
Daniel-Constantin Mierla 15 年之前
父節點
當前提交
0b5ccf31a6
共有 1 個文件被更改,包括 34 次插入0 次删除
  1. 34 0
      etc/kamailio.cfg

+ 34 - 0
etc/kamailio.cfg

@@ -59,6 +59,10 @@
 #     - adjust CFGDIR/tls.cfg as needed
 #     - define WITH_TLS
 #
+# *** To enable XMLRPC support execute:
+#     - define WITH_XMLRPC
+#     - adjust route[XMLRPC] for access policy
+#
 # *** To enable anti-flood detection execute:
 #     - adjust pike and htable=>ipban settings as needed (default is
 #       block if more than 16 requests in 2 seconds and ban for 300 seconds)
@@ -233,6 +237,10 @@ loadmodule "htable.so"
 loadmodule "pike.so"
 #!endif
 
+#!ifdef WITH_XMLRPC
+loadmodule "xmlrpc.so"
+#!endif
+
 # ----------------- setting module-specific parameters ---------------
 
 
@@ -374,6 +382,12 @@ modparam("pike", "remove_latency", 4)
 modparam("htable", "htable", "ipban=>size=8;autoexpire=300;")
 #!endif
 
+#!ifdef WITH_XMLRPC
+# ----- xmlrpc params -----
+modparam("xmlrpc", "route", "XMLRPC");
+modparam("xmlrpc", "url_match", "^/RPC")
+#!endif
+
 ####### Routing Logic ########
 
 
@@ -749,6 +763,26 @@ route[PSTN] {
 	return;
 }
 
+# XMLRPC routing
+#!ifdef WITH_XMLRPC
+route[XMLRPC]
+{
+	# allow XMLRPC from localhost
+	if ((method=="POST" || method=="GET")
+			&& (src_ip==127.0.0.1)) {
+		# close connection only for xmlrpclib user agents (there is a bug in
+		# xmlrpclib: it waits for EOF before interpreting the response).
+		if ($hdr(User-Agent) =~ "xmlrpclib")
+			set_reply_close();
+		set_reply_no_connect();
+		dispatch_rpc();
+		exit;
+	}
+	send_reply("403", "Forbidden");
+	exit;
+}
+#!endif
+
 # Sample branch router
 branch_route[BRANCH_ONE] {
 	xdbg("new branch at $ru\n");