-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Labels
Description
http://neat.readthedocs.io/en/latest/properties.html#transport specifies that transport
is of type Array
.
The Tutorial at http://neat.readthedocs.io/en/latest/tutorial.html#a-minimal-client uses an array of transports. But that array doesn't work for at least two reasons:
- An assert ensuring that
transport
node has an object namedvalue
fires off. This allows it to go on, while still handling the WebRTC case:
@@ -819,8 +819,7 @@ neat_set_property(neat_ctx *ctx, neat_flow *flow, const char *properties)
json_object_foreach(props, key, prop) {
if (strcmp(key, "transport") == 0) {
val = json_object_get(prop, "value");
- assert(val);
- if (json_typeof(val) == JSON_STRING) {
+ if (val && json_typeof(val) == JSON_STRING) {
if (strcmp(json_string_value(val), "WEBRTC") == 0) {
flow->webrtcEnabled = true;
- Later on, the validation of the transport object rejects it too, because it is of type
JSON_ARRAY
and that doesn't match the check on:
nt_find_enabled_stacks()
{
...
if (json_is_object(transports)) { <--- false
...
} else {
fprintf(stderr, "ERROR: Invalid property format\n");
}
Output of a debug session:
Breakpoint 1, nt_find_enabled_stacks (json=0x60a9b0, stacks=stacks@entry=0x7fffffffccc0,
stack_count=stack_count@entry=0x7fffffffccb8, precedences=precedences@entry=0x0)
at /usr/src/debug/libneat-0.0.1~td161-1.x86_64/neat_json_helpers.c:72
72 {
Missing separate debuginfos, use: dnf debuginfo-install jansson-2.11-1.fc27.x86_64 ldns-1.7.0-11.fc27.x86_64 libmnl-1.0.4-4.fc27.x86_64 libuv-1.19.2-1.fc27.x86_64 lksctp-tools-1.0.16-8.fc27.x86_64 openssl-libs-1.1.0h-3.fc27.x86_64 zlib-1.2.11-4.fc27.x86_64
(gdb) list
67 * TODO: Contemplate whether this can be written better somehow.
68 */
69 void
70 nt_find_enabled_stacks(json_t *json, neat_protocol_stack_type *stacks,
71 size_t *stack_count, int *precedences)
72 {
73 json_t *transports, *transport;
74 json_error_t error;
75 size_t i;
76 neat_protocol_stack_type *stack_ptr = stacks;
(gdb) step
84 assert(json);
(gdb)
85 assert(stacks && stack_count);
(gdb)
88 transports = json_object_get(json, "transport");
(gdb)
89 if (transports == NULL) {
(gdb) p *transports
$1 = {type = JSON_ARRAY, refcount = 1}
(gdb) step
99 if (json_is_object(transports)) {
(gdb)
141 fprintf(stderr, "ERROR: Invalid property format\n");
Which made me wonder if the format used in the Tutorial is actually valid.
There is https://github.com/NEAT-project/neat/blob/master/examples/prop_all.json which also uses an array but it is not used by any example. The contents looks reasonable.