Module: kamailio Branch: master Commit: 9b97d01e90963851eaa698b2ab1e04fe43822b98 URL: https://github.com/kamailio/kamailio/commit/9b97d01e90963851eaa698b2ab1e04fe...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2019-12-11T12:28:20+01:00
kamailio.cfg: replaced xmlrpc with jsonrpc in default config
---
Modified: etc/kamailio.cfg
---
Diff: https://github.com/kamailio/kamailio/commit/9b97d01e90963851eaa698b2ab1e04fe... Patch: https://github.com/kamailio/kamailio/commit/9b97d01e90963851eaa698b2ab1e04fe...
---
diff --git a/etc/kamailio.cfg b/etc/kamailio.cfg index ee3ec9e63d..01e56b66ae 100644 --- a/etc/kamailio.cfg +++ b/etc/kamailio.cfg @@ -77,9 +77,9 @@ # - 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 JSONRPC over HTTP(S) support execute: +# - define WITH_JSONRPC +# - adjust route[JSONRPC] for access policy # # *** To enable anti-flood detection execute: # - adjust pike and htable=>ipban settings as needed (default is @@ -199,6 +199,10 @@ enable_tls=yes tls_max_connections=2048 #!endif
+#!ifdef WITH_JSONRPC +tcp_accept_no_cl=yes +#!endif + ####### Custom Parameters #########
/* These parameters can be modified runtime via RPC interface @@ -235,6 +239,9 @@ voicemail.srv_port = "5060" desc "VoiceMail Port" loadmodule "db_mysql.so" #!endif
+#!ifdef WITH_JSONRPC +loadmodule "xhttp.so" +#!endif loadmodule "jsonrpcs.so" loadmodule "kex.so" loadmodule "corex.so" @@ -298,10 +305,6 @@ loadmodule "htable.so" loadmodule "pike.so" #!endif
-#!ifdef WITH_XMLRPC -loadmodule "xmlrpc.so" -#!endif - #!ifdef WITH_DEBUG loadmodule "debugger.so" #!endif @@ -315,6 +318,9 @@ modparam("jsonrpcs", "pretty_format", 1) # modparam("jsonrpcs", "fifo_name", "/run/kamailio/kamailio_rpc.fifo") /* set the path to RPC unix socket control file */ # modparam("jsonrpcs", "dgram_socket", "/run/kamailio/kamailio_rpc.sock") +#!ifdef WITH_JSONRPC +modparam("jsonrpcs", "transport", 7) +#!endif
# ----- ctl params ----- /* set the path to RPC unix socket control file */ @@ -461,12 +467,6 @@ 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 - #!ifdef WITH_DEBUG # ----- debugger params ----- modparam("debugger", "cfgtrace", 1) @@ -922,22 +922,24 @@ 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(); +# JSONRPC over HTTP(S) routing +#!ifdef WITH_JSONRPC +event_route[xhttp:request] { + set_reply_close(); + set_reply_no_connect(); + if(src_ip!=127.0.0.1) { + xhttp_reply("403", "Forbidden", "text/html", + "<html><body>Not allowed from $si</body></html>"); exit; } - send_reply("403", "Forbidden"); - exit; + if ($hu =~ "^/RPC") { + jsonrpc_dispatch(); + exit; + } + + xhttp_reply("200", "OK", "text/html", + "<html><body>Wrong URL $hu</body></html>"); + exit; } #!endif