Skip to content

Commit 0910e73

Browse files
committed
parsing json key-value check key-format if meeting : format and update readme
1 parent b681c1c commit 0910e73

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ http_interface example:
169169
```
170170
curl -X PUT -d "{\"weight\":1, \"max_fails\":2, \"fail_timeout\":10}" http://$consul_ip:$port/v1/kv/$dir1/$upstream_name/$backend_ip:$backend_port
171171
or
172-
curl -X PUT -d '{"weight":1, "max_fails":2, "fail_timeout":10}" http://$consul_ip:$port/v1/kv/$dir1/$upstream_name/$backend_ip:$backend_port
172+
curl -X PUT -d '{"weight":1, "max_fails":2, "fail_timeout":10}' http://$consul_ip:$port/v1/kv/$dir1/$upstream_name/$backend_ip:$backend_port
173173
```
174174
value support json format.
175175

src/ngx_http_dynamic_update_upstream_module.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,7 +1449,7 @@ static ngx_int_t
14491449
ngx_http_dynamic_update_upstream_parse_json(u_char *buf,
14501450
ngx_http_dynamic_update_upstream_server_t *conf_server)
14511451
{
1452-
u_char *p;
1452+
u_char *p, *port_p;
14531453
ngx_int_t max_fails=2, backup=0, down=0;
14541454
ngx_str_t src, dst;
14551455
ngx_http_update_conf_t *upstream_conf=NULL;
@@ -1486,6 +1486,10 @@ ngx_http_dynamic_update_upstream_parse_json(u_char *buf,
14861486
cJSON *temp1 = cJSON_GetObjectItem(server_next, "Key");
14871487
if (temp1 != NULL && temp1->valuestring != NULL) {
14881488
p = (u_char *)ngx_strrchr(temp1->valuestring, '/');
1489+
port_p = (u_char *)ngx_strchr(p, ':');
1490+
if (port_p == NULL) {
1491+
continue;
1492+
}
14891493

14901494
upstream_conf = ngx_array_push(&ctx->upstream_conf);
14911495
ngx_memzero(upstream_conf, sizeof(*upstream_conf));
@@ -1953,7 +1957,7 @@ ngx_http_dynamic_update_upstream_init_process(ngx_cycle_t *cycle)
19531957
ngx_destroy_pool(pool);
19541958
ctx->pool = NULL;
19551959

1956-
break;
1960+
continue;
19571961
}
19581962

19591963
return NGX_ERROR;

0 commit comments

Comments
 (0)