Skip to content

Commit

Permalink
style lint
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Feb 26, 2024
1 parent 7e31f08 commit afd81ce
Showing 1 changed file with 95 additions and 95 deletions.
190 changes: 95 additions & 95 deletions kong/router/fields.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,144 +56,144 @@ local STREAM_FIELDS = {


local FIELDS_FUNCS = {
-- http.*
-- http.*

["http.method"] =
function(params)
if not params.method then
params.method = get_method()
end
["http.method"] =
function(params)
if not params.method then
params.method = get_method()
end

return params.method
end,
return params.method
end,

["http.path"] =
function(params)
return params.uri
end,
["http.path"] =
function(params)
return params.uri
end,

["http.host"] =
function(params)
return params.host
end,
["http.host"] =
function(params)
return params.host
end,

-- net.*
-- net.*

["net.src.ip"] =
function(params)
if not params.src_ip then
params.src_ip = var.remote_addr
end
["net.src.ip"] =
function(params)
if not params.src_ip then
params.src_ip = var.remote_addr
end

return params.src_ip
end,
return params.src_ip
end,

["net.src.port"] =
function(params)
if not params.src_port then
params.src_port = tonumber(var.remote_port, 10)
end
["net.src.port"] =
function(params)
if not params.src_port then
params.src_port = tonumber(var.remote_port, 10)
end

return params.src_port
end,
return params.src_port
end,

-- below are atc context only
-- below are atc context only

["net.protocol"] =
function(params)
return params.scheme
end,
["net.protocol"] =
function(params)
return params.scheme
end,
}


local is_http = ngx.config.subsystem == "http"


if is_http then
-- tls.*

FIELDS_FUNCS["tls.sni"] =
function(params)
if not params.sni then
params.sni = server_name()
end
-- tls.*

return params.sni
FIELDS_FUNCS["tls.sni"] =
function(params)
if not params.sni then
params.sni = server_name()
end

-- net.*
return params.sni
end

FIELDS_FUNCS["net.dst.ip"] =
function(params)
if not params.dst_ip then
params.dst_ip = var.server_addr
end
-- net.*

return params.dst_ip
FIELDS_FUNCS["net.dst.ip"] =
function(params)
if not params.dst_ip then
params.dst_ip = var.server_addr
end

FIELDS_FUNCS["net.dst.port"] =
function(params, ctx)
if params.port then
return params.port
end
return params.dst_ip
end

if not params.dst_port then
params.dst_port = tonumber((ctx or ngx.ctx).host_port, 10) or
tonumber(var.server_port, 10)
end
FIELDS_FUNCS["net.dst.port"] =
function(params, ctx)
if params.port then
return params.port
end

return params.dst_port
if not params.dst_port then
params.dst_port = tonumber((ctx or ngx.ctx).host_port, 10) or
tonumber(var.server_port, 10)
end

return params.dst_port
end

else -- stream

-- tls.*
-- error value for non-TLS connections ignored intentionally
-- fallback to preread SNI if current connection doesn't terminate TLS
-- tls.*
-- error value for non-TLS connections ignored intentionally
-- fallback to preread SNI if current connection doesn't terminate TLS

FIELDS_FUNCS["tls.sni"] =
function(params)
if not params.sni then
params.sni = server_name() or var.ssl_preread_server_name
end

return params.sni
FIELDS_FUNCS["tls.sni"] =
function(params)
if not params.sni then
params.sni = server_name() or var.ssl_preread_server_name
end

-- net.*
-- when proxying TLS request in second layer or doing TLS passthrough
-- rewrite the dst_ip, port back to what specified in proxy_protocol
return params.sni
end

FIELDS_FUNCS["net.dst.ip"] =
function(params)
if not params.dst_ip then
if var.kong_tls_passthrough_block == "1" or var.ssl_protocol then
params.dst_ip = var.proxy_protocol_server_addr
-- net.*
-- when proxying TLS request in second layer or doing TLS passthrough
-- rewrite the dst_ip, port back to what specified in proxy_protocol

else
params.dst_ip = var.server_addr
end
end
FIELDS_FUNCS["net.dst.ip"] =
function(params)
if not params.dst_ip then
if var.kong_tls_passthrough_block == "1" or var.ssl_protocol then
params.dst_ip = var.proxy_protocol_server_addr

return params.dst_ip
else
params.dst_ip = var.server_addr
end
end

FIELDS_FUNCS["net.dst.port"] =
function(params, ctx)
if not params.dst_port then
if var.kong_tls_passthrough_block == "1" or var.ssl_protocol then
params.dst_port = tonumber(var.proxy_protocol_server_port)
return params.dst_ip
end

else
params.dst_port = tonumber((ctx or ngx.ctx).host_port, 10) or
tonumber(var.server_port, 10)
end
end
FIELDS_FUNCS["net.dst.port"] =
function(params, ctx)
if not params.dst_port then
if var.kong_tls_passthrough_block == "1" or var.ssl_protocol then
params.dst_port = tonumber(var.proxy_protocol_server_port)

return params.dst_port
else
params.dst_port = tonumber((ctx or ngx.ctx).host_port, 10) or
tonumber(var.server_port, 10)
end
end

return params.dst_port
end

end -- is_http


Expand Down

0 comments on commit afd81ce

Please sign in to comment.