Adapt some core rpc command to json #1185
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.