[sr-dev] [kamailio/kamailio] Adapt some core rpc command to json (#1185)

Federico Cabiddu notifications at github.com
Wed Jul 12 10:40:40 CEST 2017


Recently playing with jsonrpcs I found an issue with core.sockets_list and core.aliases_list commands called via jsonrpc_dispatch. 
The problem for the first is that the socket's list is that the JSON produced is like
{
        "jsonrpc":      "2.0",
        "result":       {
                "socket":       {
                        "proto":        "udp",
                        "address":      "XX.XX.XX.XX",
                        "ipaddress":    "XX.XX.XX.XX",
                        "port": "5060",
                        "mcast":        "no",
                        "mhomed":       "no"
                },
                "socket":       {
                        "proto":        "udp",
                        "address":      "XX.XX.XX.XX",
                        "ipaddress":    "XX.XX.XX.XX",
                        "port": "5060",
                        "mcast":        "no",
                        "mhomed":       "no"
                },
                ....
        },
        "id":   1
 }

While this is a valid JSON document, the fact that the "socket" key is defined several time in the same object makes many parsers not to properly parse it and only keep the last value.
Solution for this is to set the RET_ARRAY flag for the rpc command core.sockets_list reply so that the jsonrpcs module will create an array for the sockets instead on an object.
Similar issue for the aliases list returned by the core.aliases_list command: in this case the proposed solution is to add an "aliases" array to the rpc reply.
You can view, comment on, or merge this pull request online at:

  https://github.com/kamailio/kamailio/pull/1185

-- Commit Summary --

  * core: set RET_ARRAY flag for core.sockets_list command
  * core: return aliases list as an array in core.aliases_list

-- File Changes --

    M src/core/core_cmd.c (6)

-- Patch Links --

https://github.com/kamailio/kamailio/pull/1185.patch
https://github.com/kamailio/kamailio/pull/1185.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/1185
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20170712/84220ca5/attachment-0001.html>


More information about the sr-dev mailing list