feat(cli): support IPv4/IPv6 dual-stack for admin_listen#13746
Open
gjing1st wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
admin_listencurrently only accepts a single{ip, port}object.Passing an array is silently ignored — the CLI reads only the
.ip/.portscalars and falls back to the default0.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_listennow accepts either theexisting object or an array of
{ip, port}(oneOf). Also fixed theschema property name from the wrong
listentoip.apisix/cli/ops.lua: collect every address into a list; allow thesame 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 onelistendirective 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 initgenerates bothlisten 0.0.0.0:9180;andlisten [::]:9180;.Resolves #13744