Skip to content

Commit

Permalink
fixed the bug: upstream subname subpath
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaokai-wang committed Apr 30, 2017
1 parent 57ad7a4 commit a2d2b5d
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/ngx_stream_upsync_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -1545,20 +1545,25 @@ ngx_stream_upsync_etcd_parse_json(void *data)
static ngx_int_t
ngx_stream_upsync_check_key(u_char *key, ngx_str_t host)
{
u_char *last, *ip_p, *port_p, *s_p;
u_char *last, *ip_p, *port_p, *u_p, *s_p;
ngx_int_t port;

s_p = (u_char *)ngx_strrchr(key, '/');
if (s_p == NULL) {
u_p = (u_char *)ngx_strstr(key, host.data);
if (u_p == NULL) {
ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, 0,
"upsync_parse_json: %s key format is illegal, "
"contains no slash ('/')", key);
"upsync_parse_json: %s is illegal, "
"dont contains upstream name %V", key, &host);
return NGX_ERROR;
}
if (*(s_p - host.len - 1) != '/') {
if (*(u_p + host.len) != '/' || *(u_p - 1) != '/') {
return NGX_ERROR;
}
if (ngx_strncmp((s_p - host.len), host.data, host.len) != 0) {

s_p = (u_char *)ngx_strrchr(key, '/');
if (s_p == NULL) {
ngx_log_error(NGX_LOG_ERR, ngx_cycle->log, 0,
"upsync_parse_json: %s key format is illegal, "
"contains no slash ('/')", key);
return NGX_ERROR;
}

Expand Down

0 comments on commit a2d2b5d

Please sign in to comment.