wayne-cheng commented on a change in pull request #4856:
URL: https://github.com/apache/apisix/pull/4856#discussion_r698132660
##########
File path: apisix/cli/ops.lua
##########
@@ -461,45 +461,132 @@ Please modify "admin_key" in conf/config.yaml .
end
end
- -- support multiple ports listen, compatible with the original style
- if type(yaml_conf.apisix.node_listen) == "number" then
+ local ip_port_to_check = {}
+
+ local function listen_table_insert(listen_table, scheme, ip, port,
enable_http2, enable_ipv6)
+ if type(ip) ~= "string" then
+ util.die(scheme, " listen ip format error, must be string", "\n")
+ end
+
+ if type(port) ~= "number" then
+ util.die(scheme, " listen port format error, must be number", "\n")
+ end
+
+ if ports_to_check[port] ~= nil then
+ util.die(scheme, " listen port ", port, " conflicts with ",
+ ports_to_check[port], "\n")
+ end
+
+ local addr = ip .. ":" .. port
- if ports_to_check[yaml_conf.apisix.node_listen] ~= nil then
- util.die("node_listen port ", yaml_conf.apisix.node_listen,
- " conflicts with ",
ports_to_check[yaml_conf.apisix.node_listen], "\n")
+ if ip_port_to_check[addr] == nil then
+ table_insert(listen_table,
+ {ip = ip, port = port, enable_http2 = enable_http2})
+ ip_port_to_check[addr] = scheme
end
- local node_listen = {{port = yaml_conf.apisix.node_listen}}
- yaml_conf.apisix.node_listen = node_listen
+ if enable_ipv6 then
+ ip = "[::]"
+ addr = ip .. ":" .. port
+
+ if ip_port_to_check[addr] == nil then
+ table_insert(listen_table,
+ {ip = ip, port = port, enable_http2 = enable_http2})
+ ip_port_to_check[addr] = scheme
+ end
+ end
+ end
+
+ local node_listen = {}
+ -- listen in http, support multiple ports and specific IP, compatible with
the original style
+ if type(yaml_conf.apisix.node_listen) == "number" then
+ listen_table_insert(node_listen, "http", "0.0.0.0",
yaml_conf.apisix.node_listen,
+ false, yaml_conf.apisix.enable_ipv6)
elseif type(yaml_conf.apisix.node_listen) == "table" then
- local node_listen = {}
- for index, value in ipairs(yaml_conf.apisix.node_listen) do
+ for _, value in ipairs(yaml_conf.apisix.node_listen) do
if type(value) == "number" then
+ listen_table_insert(node_listen, "http", "0.0.0.0", value,
+ false, yaml_conf.apisix.enable_ipv6)
+ elseif type(value) == "table" then
+ local ip = value.ip
+ local port = value.port
+ local enable_ipv6 = false
+ local enable_http2 = value.enable_http2
+
+ if ip == nil then
+ ip = "0.0.0.0"
+ if yaml_conf.apisix.enable_ipv6 then
+ enable_ipv6 = true
+ end
+ end
+
+ if port == nil then
+ port = 9080
+ end
- if ports_to_check[value] ~= nil then
- util.die("node_listen port ", value, " conflicts with ",
- ports_to_check[value], "\n")
+ if enable_http2 == nil then
+ enable_http2 = false
end
- table_insert(node_listen, index, {port = value})
+ listen_table_insert(node_listen, "http", ip, port,
+ enable_http2, enable_ipv6)
+ end
+ end
+ end
+ yaml_conf.apisix.node_listen = node_listen
+
+ local ssl_listen = {}
+ -- listen in https, support multiple ports, support specific IP
+ if type(yaml_conf.apisix.ssl.listen) == "number" then
Review comment:
Got it, the related code has also been removed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]