xmlrpc_admin.xml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
  4. <!-- Include general documentation entities -->
  5. <!ENTITY % docentities SYSTEM "../../../docbook/entities.xml">
  6. %docentities;
  7. ]>
  8. <chapter>
  9. <title>&adminguide;</title>
  10. <section>
  11. <title>Parameters</title>
  12. <section id="route">
  13. <title><varname>route</varname> (string)</title>
  14. <para>
  15. Name of the route called for XMLRPC messages.
  16. </para>
  17. <para>
  18. This route will be called only for HTTP messages whose method is
  19. either GET or POST. The message visible inside the route
  20. will be a HTTP request converted to SIP (the uri will be fixed and
  21. a fake via will be added).
  22. </para>
  23. <para>
  24. The route should perform additional security checks to
  25. ensure the client is authorized to execute management/RPC functions
  26. and then it should call the <function>dispatch_rpc()</function>.
  27. </para>
  28. <para>
  29. Default: the main route is used.
  30. </para>
  31. <example>
  32. <title>Set <varname>route</varname> parameter</title>
  33. <programlisting>
  34. modparam("xmlrpc", "route", "route_for_xmlrpcs")
  35. </programlisting>
  36. </example>
  37. </section>
  38. <section id="autoconversion">
  39. <title><varname>autoconversion</varname> (string)</title>
  40. <para>
  41. Enable or disable automatic parameter type conversion globally,
  42. for all the methods parameters.
  43. If on, a type mismatch in a method parameter
  44. will not cause a fault if it is possible to automatically
  45. convert it to the type expected by the method.
  46. </para>
  47. <para>
  48. Default: off.
  49. </para>
  50. <para>
  51. It is recommended to leave this parameter to its default off value
  52. and fix instead the client application (which should use the
  53. proper types) or to modify the target rpc to accept any type
  54. (see the rpc scan '.' modifier).
  55. </para>
  56. <example>
  57. <title>Set the <varname>autoconversion</varname> parameter</title>
  58. <programlisting>
  59. modparam("xmlrpc", "autoconversion", 1)
  60. </programlisting>
  61. </example>
  62. </section>
  63. <section id="escape_cr">
  64. <title><varname>escape_cr</varname> (integer)</title>
  65. <para>
  66. Enable CR ('\r') escaping in replies. If enabled each '\r' in the
  67. xmlrpc reply will be replaced with "&amp;#xD;", according to the
  68. xml spec.
  69. </para>
  70. <para>
  71. It should be turned off only if you suspect interoperability problems
  72. with older clients.
  73. </para>
  74. <para>
  75. Default: on.
  76. </para>
  77. <example>
  78. <title>Set the <varname>escape_cr</varname> parameter</title>
  79. <programlisting>
  80. modparam("xmlrpc", "escape_cr", 1)
  81. </programlisting>
  82. </example>
  83. </section>
  84. <section id="double_lf_to_crlf">
  85. <title><varname>double_lf_to_crlf</varname> (integer)</title>
  86. <para>
  87. When enabled double LFs ('\n\n') in the input xmlrpc strings
  88. will be replaced with CR LF ('\r\n'). This makes LF LF behave like
  89. an escape character for CR LF and is needed for compatibility with
  90. &kamailio; tools and to work around buggy xmlrpc clients that don't
  91. escape the CR in CR LF ('\r' should be escaped to "&amp;#xD;"
  92. otherwise according to the xml spec "\r\n" will be transformed to
  93. '\n'), but need to send CR LF in the strings (e.g. they use
  94. <function>tm.t_uac_wait</function>).
  95. </para>
  96. <para>
  97. Note: when this option is turned on, there is no way to send a double
  98. LF ('\n\n'), it will always be transformed in CR LF ('\r\n').
  99. </para>
  100. <para>
  101. Default: off.
  102. </para>
  103. <example>
  104. <title>Set the <varname>double_lf_to_crlf</varname> parameter</title>
  105. <programlisting>
  106. modparam("xmlrpc", "double_lf_to_crlf", 1)
  107. </programlisting>
  108. </example>
  109. </section>
  110. <section id="param_mode">
  111. <title><varname>mode</varname> (integer)</title>
  112. <para>
  113. When set to 1, the xmlrpc module does not register to core the callback
  114. functions for non-SIP messages. Useful when another module register
  115. a callback for HTTP request, letting the admin decide when to
  116. call the XMLRPC route (or functions).
  117. </para>
  118. <para>
  119. Default: 0.
  120. </para>
  121. <example>
  122. <title>Set the <varname>mode</varname> parameter</title>
  123. <programlisting>
  124. modparam("xmlrpc", "mode", 1)
  125. </programlisting>
  126. </example>
  127. </section>
  128. <section>
  129. <title><varname>url_skip</varname> (str)</title>
  130. <para>
  131. Regular expression to match the HTTP URL. If there is a match,
  132. then the xmlrpc route is not executed.
  133. </para>
  134. <para>
  135. <emphasis>
  136. Default value is null (don't skip).
  137. </emphasis>
  138. </para>
  139. <example>
  140. <title>Set <varname>url_skip</varname> parameter</title>
  141. <programlisting format="linespecific">
  142. ...
  143. modparam("xmlrpc", "url_skip", "^/sip")
  144. ...
  145. </programlisting>
  146. </example>
  147. </section>
  148. <section>
  149. <title><varname>url_match</varname> (str)</title>
  150. <para>
  151. Regular expression to match the HTTP URL. If there is no match,
  152. then xmlrpc route is not executed. This check is done after
  153. url_skip, so if both url_skip and url_match would match then
  154. the xmlrpc route is not executed (url_skip has higher priority).
  155. </para>
  156. <para>
  157. <emphasis>
  158. Default value is null (match everything).
  159. </emphasis>
  160. </para>
  161. <example>
  162. <title>Set <varname>url_match</varname> parameter</title>
  163. <programlisting format="linespecific">
  164. ...
  165. modparam("xmlrpc", "url_match", "^/RPC2")
  166. ...
  167. </programlisting>
  168. </example>
  169. </section>
  170. </section>
  171. <section>
  172. <title>Functions</title>
  173. <section id="xmlrpc.dispatch_rpc">
  174. <title>
  175. <function>dispatch_rpc()</function>
  176. </title>
  177. <para>
  178. This function processes an XMLRPC request, found in the body of
  179. the request.
  180. </para>
  181. <para>
  182. It should be used only in a route specified using the
  183. <varname>"route"</varname> module parameter or if the request method
  184. is GET or POST (using it for other request methods will not have
  185. adverse side-effects, but it will probably not work).
  186. </para>
  187. <para>
  188. dispatch_rpc() extracts the XML-RPC document from the body of the
  189. request to determine the name of the RPC method to be called and then
  190. it searches through the list of all the RPC functions to find a
  191. function with matching name. If such a function is found then
  192. dispatch_rpc() will pass control to the function to handle the
  193. request.
  194. </para>
  195. <example>
  196. <title><function>dispatch_rpc</function> usage</title>
  197. <programlisting>
  198. #...
  199. modparam("xmlrpc", "route", "XMLRPC");
  200. #...
  201. route[XMLRPC]{
  202. if search("^User-Agent:.*xmlrpclib"))
  203. set_reply_close();
  204. set_reply_no_connect(); # optional
  205. dispatch_rpc();
  206. }
  207. </programlisting>
  208. </example>
  209. </section>
  210. <section id="xmlrpc.xmlrpc_reply">
  211. <title>
  212. <function>xmlrpc_reply(code, reason)</function>
  213. </title>
  214. <para>
  215. This function can be called from the config script to directly
  216. generate an XML-RPC reply.
  217. </para>
  218. <example>
  219. <title><function>xmlrpc_reply</function> usage</title>
  220. <programlisting>
  221. #...
  222. modparam("xmlrpc", "route", "XMLRPC");
  223. #...
  224. route[XMLRPC]{
  225. # allow XMLRPC requests only on TLS and only if the client
  226. # certificate is valid
  227. if (proto!=TLS){
  228. xmlrpc_reply("400", "xmlrpc allowed only over TLS");
  229. return;
  230. }
  231. if (@tls.peer.verified!=""){
  232. xmlrpc_reply("400", "Unauthorized");
  233. return;
  234. }
  235. if search("^User-Agent:.*xmlrpclib"))
  236. set_reply_close();
  237. set_reply_no_connect(); # optional
  238. dispatch_rpc();
  239. }
  240. </programlisting>
  241. </example>
  242. </section>
  243. </section>
  244. </chapter>