Documentation
¶
Overview ¶
Package proxycore renders reviewed proxy-core artifacts from server-owned intent models. It is deliberately narrow at first: the MVP supports only sing-box VLESS over TCP with REALITY, and rejects every other combination.
Index ¶
- Constants
- func Base64Subscription(links []string) []byte
- func ClashMetaSubscription(endpoints []VLESSRealityEndpoint) []byte
- func GenerateRealityKeypair() (privateKey, publicKey string, err error)
- func GenerateRealityShortID(n int) (string, error)
- func PlainSubscription(links []string) []byte
- func RealityPublicKeyFromPrivate(privateKey string) (string, error)
- func RenderSingBoxConfig(profile model.ProxyNodeProfile, inbounds []model.ProxyInbound, ...) (singBoxConfig, []string, error)
- func RenderXrayConfig(profile model.ProxyNodeProfile, inbounds []model.ProxyInbound, ...) (xrayConfig, []string, error)
- func SingBoxClientSubscription(endpoints []VLESSRealityEndpoint) ([]byte, error)
- func SubscriptionUserinfo(user model.ProxyUser) string
- func VLESSRealityLinks(user model.ProxyUser, profiles []SubscriptionProfile, ...) ([]string, []string, error)
- type Artifact
- type RenderOptions
- type SingBoxArtifact
- type SubscriptionOptions
- type SubscriptionProfile
- type VLESSRealityEndpoint
Constants ¶
const ( SubscriptionFormatBase64 = "base64" SubscriptionFormatPlain = "plain" SubscriptionFormatSingBox = "sing-box" SubscriptionFormatClash = "clash" SubscriptionFormatClashMeta = "clash-meta" )
const ( DefaultSingBoxConfigPath = "/etc/sing-box/config.json" DefaultXrayConfigPath = "/usr/local/etc/xray/config.json" DefaultListenAddress = "::" )
Variables ¶
This section is empty.
Functions ¶
func Base64Subscription ¶
func ClashMetaSubscription ¶
func ClashMetaSubscription(endpoints []VLESSRealityEndpoint) []byte
ClashMetaSubscription renders a dependency-free Clash.Meta-compatible YAML proxy list for the supported VLESS+REALITY+TCP endpoints.
func GenerateRealityKeypair ¶
GenerateRealityKeypair returns a fresh X25519 keypair as base64.RawURLEncoding strings. The 32-byte keys encode to 43 chars of [A-Za-z0-9_-], satisfying the server's reality key regex.
func GenerateRealityShortID ¶
GenerateRealityShortID returns a random REALITY short_id: a lowercase, even-length hex string. n is the number of random bytes (clamped to 1..8, so the result is 2..16 hex chars), satisfying the short-id regex + even-length rule the core enforces.
func PlainSubscription ¶
func RealityPublicKeyFromPrivate ¶
RealityPublicKeyFromPrivate derives the base64.RawURLEncoding public key for an operator-supplied X25519 private key. It accepts the key in raw/std base64 with or without padding, and always returns the public key in the canonical base64.RawURLEncoding form used in subscription links.
func RenderSingBoxConfig ¶
func RenderSingBoxConfig(profile model.ProxyNodeProfile, inbounds []model.ProxyInbound, users []model.ProxyUser, opts RenderOptions) (singBoxConfig, []string, error)
RenderSingBoxConfig builds the in-memory sing-box config. It returns structs rather than string templates so operator-controlled labels cannot break JSON syntax.
func RenderXrayConfig ¶
func RenderXrayConfig(profile model.ProxyNodeProfile, inbounds []model.ProxyInbound, users []model.ProxyUser, opts RenderOptions) (xrayConfig, []string, error)
RenderXrayConfig builds the in-memory xray config from server-owned intent models. It uses structs rather than templates so operator input cannot break JSON syntax.
func SingBoxClientSubscription ¶
func SingBoxClientSubscription(endpoints []VLESSRealityEndpoint) ([]byte, error)
SingBoxClientSubscription renders a minimal sing-box client outbound config for the supported VLESS+REALITY+TCP endpoints.
func SubscriptionUserinfo ¶
func VLESSRealityLinks ¶
func VLESSRealityLinks(user model.ProxyUser, profiles []SubscriptionProfile, inbounds []model.ProxyInbound, opts SubscriptionOptions) ([]string, []string, error)
VLESSRealityLinks renders MVP VLESS+REALITY links for one subscriber across applied node profiles. It returns an empty slice for inactive users instead of an error so the public subscription endpoint can stay token-stable while enforcing expiry/quota server-side.
Types ¶
type Artifact ¶
type Artifact struct {
Core string
ConfigJSON string
ConfigSHA256 string
ConfigPath string
Warnings []string
}
Artifact is the canonical renderer output for the plan/apply path. ConfigJSON contains user UUIDs and REALITY private keys and must be treated as a node-scoped secret-bearing artifact.
func RenderXrayConfigJSON ¶
func RenderXrayConfigJSON(profile model.ProxyNodeProfile, inbounds []model.ProxyInbound, users []model.ProxyUser, opts RenderOptions) (Artifact, error)
RenderXrayConfigJSON renders a canonical xray config for one node profile. MVP support intentionally matches the sing-box slice: VLESS over TCP with REALITY only. Unsupported protocols/transports fail closed.
type RenderOptions ¶
RenderOptions controls deterministic render behavior. Now is used to filter expired users; zero means time.Now().UTC().
type SingBoxArtifact ¶
type SingBoxArtifact = Artifact
SingBoxArtifact is kept as a compatibility alias for older call sites while xray support shares the same secret-bearing artifact contract.
func RenderSingBoxConfigJSON ¶
func RenderSingBoxConfigJSON(profile model.ProxyNodeProfile, inbounds []model.ProxyInbound, users []model.ProxyUser, opts RenderOptions) (SingBoxArtifact, error)
RenderSingBoxConfigJSON renders a canonical sing-box config for one node profile. The output is valid JSON with a trailing newline and includes the direct outbound that server-side proxy deployments need by default.
type SubscriptionOptions ¶
type SubscriptionProfile ¶
type SubscriptionProfile struct {
Profile model.ProxyNodeProfile
NodeName string
}
SubscriptionProfile is the small server-provided view needed to render links. It intentionally carries display-only node metadata, not Node secrets.
type VLESSRealityEndpoint ¶
type VLESSRealityEndpoint struct {
Label string
Tag string
NodeID string
InboundID string
Server string
ServerPort int
UUID string
Flow string
Network string
SNI string
Fingerprint string
ALPN []string
PublicKey string
ShortID string
}
VLESSRealityEndpoint is a validated, secret-free client subscription endpoint for the currently supported VLESS+REALITY+TCP shape.
func VLESSRealityEndpoints ¶
func VLESSRealityEndpoints(user model.ProxyUser, profiles []SubscriptionProfile, inbounds []model.ProxyInbound, opts SubscriptionOptions) ([]VLESSRealityEndpoint, []string, error)
VLESSRealityEndpoints renders structured subscription endpoints for the currently supported VLESS+REALITY+TCP shape. All public subscription formats are derived from these endpoints so validation and secret stripping stay in one place.
func (VLESSRealityEndpoint) Link ¶
func (e VLESSRealityEndpoint) Link() string