feat(sub): allow admins to edit JSON subscription base template#5380
Open
aleskxyz wants to merge 1 commit into
Open
feat(sub): allow admins to edit JSON subscription base template#5380aleskxyz wants to merge 1 commit into
aleskxyz wants to merge 1 commit into
Conversation
|
I would also like to see the ability to configure the balancer, for example, add an "Auto" outbound that will connect to one of the servers from the config |
96430da to
0346cf8
Compare
JSON subscriptions were built from a hard-coded skeleton, so customizing dns/inbounds/policy/routing/tail outbounds required nginx sub_filter or manual DB edits. Store the skeleton in a new subJsonTemplate setting, seeded from embedded default.json on first start; proxy outbounds and remarks are still generated per client. Add a Base JSON template tab under subscription format settings, GET /panel/api/setting/getDefaultSubJsonTemplate for reset, and save-time validation that the template must be a JSON object. Reject non-object roots at save; fall back to the embedded default at runtime when parsing fails. Panel restart is required for subscription output to pick up changes. Signed-off-by: aleskxyz <39186039+aleskxyz@users.noreply.github.com>
0346cf8 to
1ca211a
Compare
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.
Summary
Adds an admin-editable JSON subscription base template (
subJsonTemplate) so the skeleton of each JSON subscription (dns, inbounds, policy, routing, tail outbounds) can be changed from the panel. Proxy outbounds and remarks are still generated per client.Why
JSON subscriptions were built from a fixed embedded skeleton with no panel setting to customize dns, inbounds, policy, routing, or tail outbounds. This adds
subJsonTemplate, seeded fromdefault.jsonon first start, with a settings UI and API to edit and reset the template.Type of change
Areas affected
How was this tested?
Backend
go test ./internal/sub/...— custom base template, rules overlay without routing, null-template fallbackgo test ./internal/web/service/... -run 'SubJson|SeedSubJson'— seeding,CheckValid(including non-object rejection)Frontend
npm run typecheck,npm run lint,npm run test— all pass (541 tests)Manual
default.json→ save + restart appliesScreenshots / recordings
N/A (new settings tab with JSON editor and reset button; no screenshots attached).
Breaking changes
None. Existing installs get the embedded default seeded when the setting is empty. Default subscription output is unchanged until an admin edits the template.
Checklist
go build ./...and the test suite pass locally.npm run lint,npm run typecheck, andnpm run buildpass.Note:
go test ./...currently fails on one pre-existing unrelated check:TestAPIRoutesDocumented— missing docs forPOST /panel/api/clients/clientIpsByGuid. All tests for this feature pass.