feat(protocol): derive supported protocols from registries#271
Merged
Conversation
Collect the supported protocol list from the inbound/outbound/endpoint registries at init instead of hardcoding it, so the list reflects the active build tags. Add an amnezia endpoint stub for builds without with_wireguard that registers a constructor returning an error, and bump sing-box-minimal.
Contributor
There was a problem hiding this comment.
Pull request overview
Replaces the hardcoded supportedProtocols list with a runtime computation that queries inbound/outbound/endpoint registries, so the reported set reflects what is actually compiled in (based on build tags). Also splits Amnezia's endpoint registration behind a with_wireguard build tag, and updates the sing-box-minimal replace directive to a pseudo-version that presumably exposes CreateOptions on the registries.
Changes:
- Dynamic computation of
supportedProtocolsin aninit()by registering protocols against a freshlibbox.BaseContext, then filtering each registry'sRegistered()list viaCreateOptions(...). - Add
endpoint_stub.go(nowith_wireguard) returning an error from the Amnezia constructor, and add the corresponding build tag toendpoint.go. - Bump the
sing-box-minimalreplacement tov1.12.22-lantern.0.20260529221144-439651539f38ingo.mod/go.sum.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| protocol/register.go | Build supportedProtocols dynamically from registries instead of hardcoding it. |
| protocol/amnezia/endpoint.go | Gate real Amnezia endpoint registration on with_wireguard. |
| protocol/amnezia/endpoint_stub.go | Stub endpoint registration when with_wireguard is off; returns a clear error at construction. |
| go.mod | Update sing-box-minimal replace to a newer pseudo-version. |
| go.sum | Corresponding checksum update for the new module version. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Derive protocol availability from build tags rather than probing the registry's CreateOptions. sing-box registers all protocols regardless of build tag, so collect the full registered set and remove wireguard, amnezia, and tailscale when their build tags are absent.
WendelHime
approved these changes
Jun 1, 2026
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.
This pull request introduces dynamic detection of supported protocols based on build tags, replacing the previous hardcoded list. It also adds build tag handling for the Amnezia protocol and updates a dependency version in
go.mod. The main impact is improved flexibility and accuracy in protocol support reporting, especially in builds with optional features like WireGuard.Dynamic protocol registration and build tag handling:
supportedProtocolslist inprotocol/register.gowith a dynamic mechanism that queries protocol registries at runtime, ensuring only protocols actually supported by the current build (based on build tags) are reported. This uses new helper logic to collect and deduplicate protocols from inbound, outbound, and endpoint registries.endpoint.go(enabled with thewith_wireguardbuild tag) andendpoint_stub.go(used when the tag is not set). The stub returns an error if Amnezia is not included in the build, providing clear feedback to developers and users. [1] [2]Dependency update:
github.com/sagernet/sing-boxingo.modto a new Lantern-specific version, ensuring the correct dependency is used for this build.Minor codebase improvements:
maps,slices) andlibboxto support the dynamic protocol registration logic.