Merge pull request #1185 from grumvalski/core_rpc_fmt
authorFederico Cabiddu <federico.cabiddu@gmail.com>
Wed, 12 Jul 2017 08:52:25 +0000 (10:52 +0200)
committerGitHub <noreply@github.com>
Wed, 12 Jul 2017 08:52:25 +0000 (10:52 +0200)
Adapt some core rpc command to json

src/core/core_cmd.c

index 9d62617..b7e4b02 100644 (file)
@@ -876,14 +876,16 @@ static const char* core_aliases_list_doc[] = {
 static void core_aliases_list(rpc_t* rpc, void* c)
 {
        void *hr;
+       void *hs;
        void *ha;
        struct host_alias* a;
 
        rpc->add(c, "{", &hr);
        rpc->struct_add(hr, "s",
                        "myself_callbacks", is_check_self_func_list_set()?"yes":"no");
+       rpc->struct_add(hr, "[", "aliases", &hs);
        for(a=aliases; a; a=a->next) {
-               rpc->struct_add(hr, "{", "alias", &ha);
+               rpc->struct_add(hs, "{", "alias", &ha);
                rpc->struct_add(ha, "sS",
                                "proto",  proto2a(a->proto),
                                "address", &a->alias
@@ -989,7 +991,7 @@ static rpc_export_t core_rpc_methods[] = {
        {"core.udp4_raw_info",     core_udp4rawinfo,       core_udp4rawinfo_doc,
                0},
        {"core.aliases_list",      core_aliases_list,      core_aliases_list_doc,   0},
-       {"core.sockets_list",      core_sockets_list,      core_sockets_list_doc,   0},
+       {"core.sockets_list",      core_sockets_list,      core_sockets_list_doc,   RET_ARRAY},
 #ifdef USE_DNS_CACHE
        {"dns.mem_info",          dns_cache_mem_info,     dns_cache_mem_info_doc,
                0       },