Skip to content

feat(cli): support IPv4/IPv6 dual-stack for admin_listen#13746

Open
gjing1st wants to merge 1 commit into
apache:masterfrom
gjing1st:admin-listen-dual-stack
Open

feat(cli): support IPv4/IPv6 dual-stack for admin_listen#13746
gjing1st wants to merge 1 commit into
apache:masterfrom
gjing1st:admin-listen-dual-stack

Conversation

@gjing1st

Copy link
Copy Markdown

Motivation

admin_listen currently only accepts a single {ip, port} object.
Passing an array is silently ignored — the CLI reads only the
.ip/.port scalars and falls back to the default 0.0.0.0:9180,
so the Admin API can never listen on both IPv4 and IPv6 at once.
(Background: #7972 asked about IPv6 on the control plane but was closed
as not planned without a fix.)

Solution

  • apisix/cli/schema.lua: admin_listen now accepts either the
    existing object or an array of {ip, port} (oneOf). Also fixed the
    schema property name from the wrong listen to ip.
  • apisix/cli/ops.lua: collect every address into a list; allow the
    same port to be reused across addresses of the same service (required
    for dual-stack); keep backward-compatible behavior for the object form.
  • apisix/cli/ngx_tpl.lua: emit one listen directive per address
    (both https and http branches).
  • conf/config.yaml.example: document the array / dual-stack syntax.

Test

Added a case in t/cli/test_admin.sh: with the array form,
make init generates both listen 0.0.0.0:9180; and
listen [::]:9180;.

Resolves #13744

admin_listen currently only accepts a single {ip, port} object.
Passing an array is silently ignored because the CLI reads only
the .ip/.port scalars and falls back to the default
0.0.0.0:9180, so the Admin API can never listen on both
IPv4 and IPv6 at once.

Allow admin_listen to be either the existing object or an array
of {ip, port}. The CLI collects every address and the nginx
template emits one "listen" directive per address. The port
conflict check now permits the same port to be reused across
addresses of the same service, which is required for dual-stack.
The single-object form keeps working unchanged (backward
compatible), and config.yaml.example documents the new syntax.

Test: extend t/cli/test_admin.sh to assert that the array form
generates both "listen 0.0.0.0:9180;" and "listen [::]:9180;".

Resolves apache#13744
Related: apache#7972 (earlier IPv6-on-control-plane request, closed as
not planned without a fix)

Signed-off-by: gj <gjing1st@gmail.com>
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request labels Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

support IPv4/IPv6 dual-stack for admin_listen

1 participant