diff options
Diffstat (limited to 'src/json.c')
-rw-r--r-- | src/json.c | 23 |
1 files changed, 10 insertions, 13 deletions
@@ -1437,26 +1437,23 @@ json_t *connlimit_stmt_json(const struct stmt *stmt, struct output_ctx *octx) json_t *tproxy_stmt_json(const struct stmt *stmt, struct output_ctx *octx) { - json_t *root = json_object(); - - if (stmt->tproxy.addr) { - int family; - json_t *tmp; - - family = stmt->tproxy.table_family; - if (family == NFPROTO_INET) - family = stmt->tproxy.family; + json_t *tmp, *root = json_object(); - tmp = json_string(family2str(family)); + if (stmt->tproxy.table_family == NFPROTO_INET && + stmt->tproxy.family != NFPROTO_UNSPEC) { + tmp = json_string(family2str(stmt->tproxy.family)); json_object_set_new(root, "family", tmp); + } + if (stmt->tproxy.addr) { tmp = expr_print_json(stmt->tproxy.addr, octx); json_object_set_new(root, "addr", tmp); } - if (stmt->tproxy.port) - json_object_set_new(root, "port", - expr_print_json(stmt->tproxy.port, octx)); + if (stmt->tproxy.port) { + tmp = expr_print_json(stmt->tproxy.port, octx); + json_object_set_new(root, "port", tmp); + } return json_pack("{s:o}", "tproxy", root); } |