Skip to content

Commit

Permalink
export parse_proxy_url and add tests for cluster_use_proxy option
Browse files Browse the repository at this point in the history
  • Loading branch information
chobits committed Dec 3, 2024
1 parent 9f2eed6 commit 45c68b5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions kong/clustering/rpc/manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ local cjson_encode = cjson.encode
local cjson_decode = cjson.decode
local validate_client_cert = clustering_tls.validate_client_cert
local CLUSTERING_PING_INTERVAL = constants.CLUSTERING_PING_INTERVAL
local parse_proxy_url = require("kong.clustering.utils").parse_proxy_url


local RPC_MATA_V1 = "kong.meta.v1"
Expand Down
4 changes: 2 additions & 2 deletions kong/clustering/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ local CLUSTER_PROXY_SSL_TERMINATOR_SOCK = fmt("unix:%s/%s",
local _M = {}


local function parse_proxy_url(proxy_server)
function _M.parse_proxy_url(proxy_server)
local ret = {}

if proxy_server then
Expand Down Expand Up @@ -84,7 +84,7 @@ function _M.connect_cp(dp, endpoint, protocols)
}

if conf.cluster_use_proxy then
local proxy_opts = parse_proxy_url(conf.proxy_server)
local proxy_opts = _M.parse_proxy_url(conf.proxy_server)
opts.proxy_opts = {
wss_proxy = proxy_opts.proxy_url,
wss_proxy_authorization = proxy_opts.proxy_authorization,
Expand Down
9 changes: 9 additions & 0 deletions spec/02-integration/09-hybrid_mode/10-forward-proxy_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,15 @@ for _, strategy in helpers.each_strategy() do
if auth_on then
assert.matches("accepted basic proxy%-authorization", contents)
end

-- check the debug log of the `cluster_use_proxy` option
path = pl_path.join("servroot2", "logs", "error.log")
contents = pl_file.read(path)
if rpc == "on" and inc_sync == "on" then
assert.matches("%[rpc%] using proxy", contents)
else
assert.matches("%[clustering%] using proxy", contents)
end
end)
end)
end)
Expand Down

0 comments on commit 45c68b5

Please sign in to comment.