Skip to content

Commit

Permalink
fix: upstream nodes cant't include ipv6 addr (apache#6908)
Browse files Browse the repository at this point in the history
  • Loading branch information
soulbird authored and Liu-Junlin committed May 20, 2022
1 parent df362a4 commit 081b21f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apisix/schema_def.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ local id_schema = {
}
}

local host_def_pat = "^\\*?[0-9a-zA-Z-._]+$"
local host_def_pat = "^\\*?[0-9a-zA-Z-._\\[\\]:]+$"
local host_def = {
type = "string",
pattern = host_def_pat,
Expand Down
35 changes: 35 additions & 0 deletions t/admin/upstream-array-nodes.t
Original file line number Diff line number Diff line change
Expand Up @@ -450,3 +450,38 @@ GET /t
{"error_msg":"invalid configuration: property \"nodes\" validation failed: object matches none of the required"}
--- no_error_log
[error]



=== TEST 14: nodes host include ipv6 addr
--- config
location /t {
content_by_lua_block {
local t = require("lib.test_admin").test
local code, body = t('/apisix/admin/routes/1',
ngx.HTTP_PUT,
[[{
"upstream": {
"nodes": [
{
"host":"[::1]",
"port":8082,
"weight":1
}
],
"type": "roundrobin"
},
"uri": "/index.html"
}]]
)

ngx.status = code
ngx.say(body)
}
}
--- request
GET /t
--- response_body
passed
--- no_error_log
[error]
1 change: 0 additions & 1 deletion t/plugin/referer-restriction.t
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ hello world
local cases = {
"x.*",
"~y.xn",
"::1",
}
for _, c in ipairs(cases) do
local ok, err = plugin.check_schema({
Expand Down

0 comments on commit 081b21f

Please sign in to comment.