Skip to content

Commit

Permalink
refactor(http3): use http3 instead of quic
Browse files Browse the repository at this point in the history
  • Loading branch information
zll600 committed Mar 6, 2024
1 parent b83a20b commit 1842423
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 21 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/quic.yml → .github/workflows/http3.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: QUIC
name: HTTP/3

on:
push:
Expand Down Expand Up @@ -32,7 +32,7 @@ jobs:
- lua-resty-worker-events
- lua-resty-events
test_dir:
- t/quic/admin
- t/http3/admin

runs-on: ${{ matrix.platform }}
timeout-minutes: 90
Expand Down Expand Up @@ -72,13 +72,13 @@ jobs:
id: test_env
run: |
test_dir="${{ matrix.test_dir }}"
if [[ $test_dir =~ 't/quic/plugin' ]]; then
if [[ $test_dir =~ 't/http3/plugin' ]]; then
echo "type=plugin" >>$GITHUB_OUTPUT
fi
if [[ $test_dir =~ 't/quic/admin' ]]; then
if [[ $test_dir =~ 't/http3/admin' ]]; then
echo "type=first" >>$GITHUB_OUTPUT
fi
if [[ $test_dir =~ ' t/quic/xrpc' ]]; then
if [[ $test_dir =~ ' t/http3/xrpc' ]]; then
echo "type=last" >>$GITHUB_OUTPUT
fi
Expand Down
5 changes: 4 additions & 1 deletion apisix/cli/ngx_tpl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -631,12 +631,15 @@ http {
{% if enable_http2 then %}
http2 on;
{% end %}
{% if enable_http3_global then %}
http3 on;
{% end %}
{% for _, item in ipairs(node_listen) do %}
listen {* item.ip *}:{* item.port *} default_server {% if enable_reuseport then %} reuseport {% end %};
{% end %}
{% if ssl.enable then %}
{% for _, item in ipairs(ssl.listen) do %}
{% if item.enable_quic then %}
{% if item.enable_http3 then %}
listen {* item.ip *}:{* item.port *} quic default_server {% if enable_reuseport then %} reuseport {% end %};
listen {* item.ip *}:{* item.port *} ssl default_server;
{% else %}
Expand Down
20 changes: 13 additions & 7 deletions apisix/cli/ops.lua
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ Please modify "admin_key" in conf/config.yaml .
local ip_port_to_check = {}

local function listen_table_insert(listen_table, scheme, ip, port,
enable_http2, enable_quic, enable_ipv6)
enable_http2, enable_http3, enable_ipv6)
if type(ip) ~= "string" then
util.die(scheme, " listen ip format error, must be string", "\n")
end
Expand All @@ -402,7 +402,7 @@ Please modify "admin_key" in conf/config.yaml .
ip = ip,
port = port,
enable_http2 = enable_http2,
enable_quic = enable_quic
enable_http3 = enable_http3
})
ip_port_to_check[addr] = scheme
end
Expand All @@ -417,7 +417,7 @@ Please modify "admin_key" in conf/config.yaml .
ip = ip,
port = port,
enable_http2 = enable_http2,
enable_quic = enable_quic
enable_http3 = enable_http3
})
ip_port_to_check[addr] = scheme
end
Expand Down Expand Up @@ -466,14 +466,15 @@ Please modify "admin_key" in conf/config.yaml .
end
yaml_conf.apisix.node_listen = node_listen

local enable_http3_global = false
local ssl_listen = {}
-- listen in https, support multiple ports, support specific IP
for _, value in ipairs(yaml_conf.apisix.ssl.listen) do
local ip = value.ip
local port = value.port
local enable_ipv6 = false
local enable_http2 = value.enable_http2
local enable_quic = value.enable_quic
local enable_http3 = value.enable_http3

if ip == nil then
ip = "0.0.0.0"
Expand All @@ -493,16 +494,21 @@ Please modify "admin_key" in conf/config.yaml .
enable_http2_global = true
end

if enable_quic == nil then
enable_quic = false
if enable_http3 == nil then
enable_http3 = false
end
if enable_http3 == true then
enable_http3_global = true
end

listen_table_insert(ssl_listen, "https", ip, port,
enable_http2, enable_quic, enable_ipv6)
enable_http2, enable_http3, enable_ipv6)
end

yaml_conf.apisix.ssl.listen = ssl_listen
yaml_conf.apisix.enable_http2 = enable_http2_global
yaml_conf.apisix.enable_http3_global = enable_http3_global


if yaml_conf.apisix.ssl.ssl_trusted_certificate ~= nil then
local cert_path = yaml_conf.apisix.ssl.ssl_trusted_certificate
Expand Down
2 changes: 1 addition & 1 deletion apisix/cli/schema.lua
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ local config_schema = {
enable_http2 = {
type = "boolean",
},
enable_quic = {
enable_http3 = {
type = "boolean",
},
}
Expand Down
4 changes: 2 additions & 2 deletions conf/config-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ apisix:
listen: # APISIX listening port for HTTPS traffic.
- port: 9443
enable_http2: true
enable_quic: false # Enable QUIC or HTTP/3. If not set default to `false`.
enable_http3: false # Enable HTTP/3 (with QUIC). If not set default to `false`.
# - ip: 127.0.0.3 # If not set, default to `0.0.0.0`.
# port: 9445
# enable_http2: true
# enable_quic: true
# enable_http3: true
# ssl_trusted_certificate: /path/to/ca-cert # Set the path to CA certificates used to verify client
# certificates in the PEM format.
ssl_protocols: TLSv1.2 TLSv1.3 # TLS versions supported.
Expand Down
2 changes: 1 addition & 1 deletion t/APISIX.pm
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,6 @@ _EOC_
$a6_ngx_directives
server {
listen 1983 quic reuseport;
listen 1983 ssl;
ssl_certificate cert/apisix.crt;
ssl_certificate_key cert/apisix.key;
Expand Down Expand Up @@ -730,6 +729,7 @@ _EOC_
listen 1994 quic reuseport;
listen 1994 ssl;
http2 on;
http3 on;
ssl_certificate cert/apisix.crt;
ssl_certificate_key cert/apisix.key;
lua_ssl_trusted_certificate cert/apisix.crt;
Expand Down
8 changes: 4 additions & 4 deletions t/cli/test_main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ apisix:
- ip: 127.0.0.4
port: 9445
enable_http2: true
enable_quic: true
enable_http3: true
" > conf/config.yaml

make init
Expand Down Expand Up @@ -171,9 +171,9 @@ if [ $count_https_specific_ip_and_enable_http2 -ne 1 ]; then
exit 1
fi

count_https_specific_ip_and_enable_quic=`grep -c "listen 127.0.0..:944. quic" conf/nginx.conf || true`
if [ $count_https_specific_ip_and_enable_quic -ne 1 ]; then
echo "failed: failed to support specific IP and enable quic listen in https"
count_https_specific_ip_and_enable_http3=`grep -c "listen 127.0.0..:944. quic" conf/nginx.conf || true`
if [ $count_https_specific_ip_and_enable_http3 -ne 1 ]; then
echo "failed: failed to support specific IP and enable http3 listen in https"
exit 1
fi

Expand Down
File renamed without changes.

0 comments on commit 1842423

Please sign in to comment.