Skip to content

feat(protocol): derive supported protocols from registries#271

Merged
garmr-ulfr merged 2 commits into
mainfrom
build-supported-protos-from-reg
Jun 1, 2026
Merged

feat(protocol): derive supported protocols from registries#271
garmr-ulfr merged 2 commits into
mainfrom
build-supported-protos-from-reg

Conversation

@garmr-ulfr
Copy link
Copy Markdown
Collaborator

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:

  • Replaces the hardcoded supportedProtocols list in protocol/register.go with 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.
  • Adds build tag handling for the Amnezia protocol by splitting its endpoint registration into two files: endpoint.go (enabled with the with_wireguard build tag) and endpoint_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:

  • Updates the replacement for github.com/sagernet/sing-box in go.mod to a new Lantern-specific version, ensuring the correct dependency is used for this build.

Minor codebase improvements:

  • Imports new utility packages (maps, slices) and libbox to support the dynamic protocol registration logic.

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.
Copilot AI review requested due to automatic review settings May 29, 2026 23:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 supportedProtocols in an init() by registering protocols against a fresh libbox.BaseContext, then filtering each registry's Registered() list via CreateOptions(...).
  • Add endpoint_stub.go (no with_wireguard) returning an error from the Amnezia constructor, and add the corresponding build tag to endpoint.go.
  • Bump the sing-box-minimal replacement to v1.12.22-lantern.0.20260529221144-439651539f38 in go.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.

Comment thread protocol/register.go Outdated
Comment thread protocol/amnezia/endpoint_stub.go
Comment thread protocol/register.go
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.
@garmr-ulfr garmr-ulfr merged commit e9fc90d into main Jun 1, 2026
3 checks passed
@garmr-ulfr garmr-ulfr deleted the build-supported-protos-from-reg branch June 1, 2026 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants