meridian

package module
v0.1.0-alpha.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2026 License: Apache-2.0 Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Petauron Glivela

Formerly Meridian. See the in-place brand migration for stable installation identities and coordinated release steps.

Glivela is Petauron's access and subscription domain for managed proxy entries. It owns account plans, stable access credentials, route grants, shared usage accounting, and deterministic subscription rendering.

Glivela is not a general-purpose proxy panel and does not fork 3x-ui. Vastora remains the desired-state control plane and its Agent remains responsible for validating and atomically applying Xray configurations on managed nodes. Glivela supplies the authoritative, runtime-independent domain rules that both sides share.

Product boundary

  • Vastora deploys applications, selects nodes, authorizes operations, and records desired/applied revisions.
  • Glivela defines accounts, credentials, route grants, shared quotas, and subscription output.
  • Vastora Agent applies the resulting Xray identities and routes, reports monotonic counters, and confirms runtime health.
  • Senulun observes infrastructure health.

There is one writer for each credential. A migration may import an existing 3x-ui identity once, but released runtime code must not retain dual reads, dual writes, aliases, or a 3x-ui fallback after cutover.

Protocol scope

The first complete vertical slice supports managed VLESS/REALITY and native Hysteria2/TLS entries, VLESS fixed entry-to-egress route credentials, conventional base64 subscriptions, Mihomo YAML, and one shared account quota across both protocols and all route credentials. A native Glivela credential owns a VLESS UUID and, when Hysteria2 is enabled for the entry, a separate Hysteria2 authentication secret. Both runtime clients use the same Xray user label, so their counters contribute to the same account ledger instead of creating a second account or quota. Routed credentials remain VLESS-only: current Xray Hysteria inbounds do not provide a trustworthy per-user routing boundary, so Glivela never publishes a routed Hysteria credential that could silently escape through the native exit.

The APIs are pure and deterministic so callers can persist state in their own forward-only schema and compare desired output before applying a runtime revision.

Security model

Persisted domain records refer to credential fingerprints and caller-owned encrypted secrets. Xray rendering necessarily receives decrypted protocol credentials, the REALITY private key, and the Hysteria2 TLS key for the duration of one in-process projection; these secret-bearing values must stay in encrypted task/state envelopes and are never included in errors, receipts, or event text. Raw subscription links are accepted only as bounded renderer input and are never suitable for logs. Subscription rendering rejects cross-account routes, duplicate identities, ambiguous names, unsupported transports, and mismatched protocol material.

Core API

  • PlanImport validates and fingerprints a complete one-time authority transfer before callers mutate durable state. A legacy VLESS identity may be preserved across different entries, while duplicate VLESS identities within one entry remain invalid. Hysteria2 authentication identities follow the same boundary: they must be unique inside one entry runtime, while a migrated account may preserve the same authentication secret on independent entries. An empty account inventory is valid when an installation has entry runtimes but no subscribers yet.
  • ProjectQuota applies one shared account allowance across native and routed credentials without splitting or duplicating the allowance.
  • RenderLinks and RenderMihomo produce deterministic subscriptions from applied, healthy route receipts.
  • BuildDesiredArtifact creates a complete Xray candidate and binds it to a revision and SHA-256 digest.
  • VerifyAppliedReceipt prevents a stale or different runtime from being reported as the desired state.
  • ParseXrayUserCounters maps exact Xray user counters back to credential IDs without relying on delimiter splitting.

Vastora's migration adapter rejects legacy per-entry traffic ceilings and per-client simultaneous-IP limits before import. Those policies do not have an equivalent in Glivela's account-wide quota model and current Xray runtime, so they must never be silently weakened during replacement.

Status

This public module is the reusable Glivela domain authority. Vastora is its first control-plane integration and owns persistence, operator APIs, UI, and Agent orchestration; no separate mutable panel or node-side service is part of the architecture. The first release remains in pre-release integration until the forward cutover and runtime receipts have been verified on the managed fleet.

Documentation

Overview

Package meridian defines Petauron's runtime-independent account, access, routing, quota, deployment, and subscription rules for managed Xray entries.

Index

Constants

View Source
const (
	MaxIdentifierLength  = 128
	MaxDisplayNameLength = 512
	MaxResetDays         = 3650
)
View Source
const (
	DefaultRealityPort      = 443
	RealityBackendPort      = 10443
	DefaultLandingSOCKSPort = 1080
	XrayAPIListenPort       = 10085
	XrayMinimumClient       = "0.0.0"
)

Variables

This section is empty.

Functions

func CompositePublicIP

func CompositePublicIP(address netip.Addr) bool

CompositePublicIP validates reported public exit addresses before publication.

func Hysteria2LinkForCredential

func Hysteria2LinkForCredential(endpoint HysteriaEndpoint, material CredentialMaterial, name string) (string, error)

func HysteriaCertificateNotAfter

func HysteriaCertificateNotAfter(endpoint HysteriaEndpoint) (time.Time, error)

func Identity

func Identity(secret string) string

func LinkForCredential

func LinkForCredential(endpoint RealityEndpoint, material CredentialMaterial, name string) (string, error)
func RenderLinks(entries []NativeEntry, accountID string, mode PublishingMode, routes []PublishedRoute, encoded bool) ([]byte, error)

func RenderMihomo

func RenderMihomo(entries []NativeEntry, accountID string, mode PublishingMode, routes []PublishedRoute) ([]byte, error)

func RenderXrayConfiguration

func RenderXrayConfiguration(plan XrayPlan) ([]byte, error)

func RouteUser

func RouteUser(grantID string) string

func SubscriptionTokenFingerprint

func SubscriptionTokenFingerprint(token string) string

func ValidIdentifier

func ValidIdentifier(value string) bool

func ValidIdentity

func ValidIdentity(value string) bool

func ValidateCompositeExitPair

func ValidateCompositeExitPair(ipv6, ipv4 RoutePeer) error

func ValidateCompositePeers

func ValidateCompositePeers(grant RouteGrant, ipv6, ipv4 RoutePeer) error

Composite routes keep one client credential and one quota membership. The private transport family is independent of each exit's final public family.

func VerifyAppliedReceipt

func VerifyAppliedReceipt(desired DesiredArtifact, receipt AppliedReceipt) error

Types

type AccessGate

type AccessGate struct {
	CredentialID string `json:"credentialId"`
	Enabled      bool   `json:"enabled"`
}

type Account

type Account struct {
	ID              string      `json:"id"`
	DisplayName     string      `json:"displayName"`
	Plan            AccountPlan `json:"plan"`
	DesiredRevision uint64      `json:"desiredRevision"`
	AppliedRevision uint64      `json:"appliedRevision"`
}

func (Account) Validate

func (a Account) Validate() error

type AccountPlan

type AccountPlan struct {
	TotalBytes int64 `json:"totalBytes"`
	ExpiryTime int64 `json:"expiryTime"`
	ResetDays  int   `json:"resetDays"`
	Enabled    bool  `json:"enabled"`
}

func (AccountPlan) Validate

func (p AccountPlan) Validate() error

type AppliedReceipt

type AppliedReceipt struct {
	Revision     uint64 `json:"revision"`
	ConfigSHA256 string `json:"configSha256"`
	RuntimeReady bool   `json:"runtimeReady"`
}

type CounterSnapshot

type CounterSnapshot struct {
	CredentialID string `json:"credentialId"`
	UpBytes      int64  `json:"upBytes"`
	DownBytes    int64  `json:"downBytes"`
}

func ParseXrayUserCounters

func ParseXrayUserCounters(materials []CredentialMaterial, payload []byte) ([]CounterSnapshot, error)

ParseXrayUserCounters accepts the bounded result of Xray's StatsService query. Names are matched against the complete expected name, so an imported user label containing Xray's delimiter remains unambiguous.

func (CounterSnapshot) TotalBytes

func (s CounterSnapshot) TotalBytes() int64

type Credential

type Credential struct {
	ID        string         `json:"id"`
	AccountID string         `json:"accountId"`
	Kind      CredentialKind `json:"kind"`
	User      string         `json:"user"`
	Identity  string         `json:"identity"`
	EntryID   string         `json:"entryId"`
	EgressID  string         `json:"egressId,omitempty"`
	Enabled   bool           `json:"enabled"`
}

func (Credential) Validate

func (c Credential) Validate() error

type CredentialKind

type CredentialKind string
const (
	NativeCredential CredentialKind = "native"
	RouteCredential  CredentialKind = "route"
)

type CredentialMaterial

type CredentialMaterial struct {
	Credential       Credential `json:"credential"`
	ProtocolID       string     `json:"protocolId"`
	HysteriaAuth     string     `json:"hysteriaAuth,omitempty"`
	HysteriaIdentity string     `json:"hysteriaIdentity,omitempty"`
}

func (CredentialMaterial) Validate

func (m CredentialMaterial) Validate() error

type DesiredArtifact

type DesiredArtifact struct {
	Revision     uint64 `json:"revision"`
	Config       []byte `json:"config"`
	ConfigSHA256 string `json:"configSha256"`
}

func BuildDesiredArtifact

func BuildDesiredArtifact(plan XrayPlan) (DesiredArtifact, error)

func (DesiredArtifact) Validate

func (a DesiredArtifact) Validate() error

type EgressPolicy

type EgressPolicy string

EgressPolicy controls the final destination family of native traffic. Fixed routes keep their SOCKS transport and the landing's own egress policy.

const (
	EgressAuto     EgressPolicy = "auto"
	EgressIPv4Only EgressPolicy = "ipv4_only"
	EgressIPv6Only EgressPolicy = "ipv6_only"
)

func (EgressPolicy) Validate

func (p EgressPolicy) Validate() error

The zero value means the policy was not specified and leaves Xray's system address selection unchanged. Unknown policies must never become auto.

type HysteriaEndpoint

type HysteriaEndpoint struct {
	ID             string `json:"id"`
	EntryID        string `json:"entryId"`
	InboundTag     string `json:"inboundTag"`
	ListenPort     int    `json:"listenPort"`
	AdvertiseHost  string `json:"advertiseHost"`
	AdvertisePort  int    `json:"advertisePort"`
	ServerName     string `json:"serverName"`
	CertificatePEM string `json:"certificatePem"`
	PrivateKeyPEM  string `json:"privateKeyPem"`
}

func (HysteriaEndpoint) Validate

func (e HysteriaEndpoint) Validate() error

type ImportAccount

type ImportAccount struct {
	Account                      Account           `json:"account"`
	SubscriptionTokenFingerprint string            `json:"subscriptionTokenFingerprint"`
	Credentials                  []Credential      `json:"credentials"`
	HysteriaIdentities           map[string]string `json:"hysteriaIdentities,omitempty"`
	Grants                       []RouteGrant      `json:"grants"`
	Usage                        []UsageMember     `json:"usage"`
}

type ImportPlan

type ImportPlan struct {
	Accounts []ImportAccount `json:"accounts"`
	SHA256   string          `json:"sha256"`
}

func PlanImport

func PlanImport(accounts []ImportAccount) (ImportPlan, error)

PlanImport validates a complete one-time authority transfer before a caller writes any state. It carries only the subscription-token fingerprint; the caller must move the raw token directly between encrypted stores.

type NativeEntry

type NativeEntry struct {
	Material CredentialMaterial `json:"material"`
	Protocol ProtocolKind       `json:"protocol"`
	Link     string             `json:"link"`
}

type ProtocolKind

type ProtocolKind string
const (
	VLESSReality ProtocolKind = "vless-reality"
	Hysteria2    ProtocolKind = "hysteria2"
)

func (ProtocolKind) Valid

func (p ProtocolKind) Valid() bool

type PublishedRoute

type PublishedRoute struct {
	Grant                  RouteGrant   `json:"grant"`
	Protocol               ProtocolKind `json:"protocol"`
	EntryName              string       `json:"entryName"`
	EgressNameSuffix       string       `json:"egressNameSuffix,omitempty"`
	EgressRegionPrefix     string       `json:"egressRegionPrefix,omitempty"`
	IPv4EgressRegionPrefix string       `json:"ipv4EgressRegionPrefix,omitempty"`
	BaseLink               string       `json:"baseLink"`
	RouteLink              string       `json:"routeLink"`
	BaseProtocolIdentity   string       `json:"baseProtocolIdentity"`
	RouteProtocolIdentity  string       `json:"routeProtocolIdentity"`
}

type PublishingMode

type PublishingMode string
const FixedMode PublishingMode = "fixed"

func (PublishingMode) Valid

func (m PublishingMode) Valid() bool

type QuotaProjection

type QuotaProjection struct {
	UsedBytes int64        `json:"usedBytes"`
	Enabled   bool         `json:"enabled"`
	Gates     []AccessGate `json:"gates"`
}

func ProjectQuota

func ProjectQuota(plan AccountPlan, members []UsageMember) (QuotaProjection, error)

ProjectQuota computes one account-wide usage value and projects only an on/off gate to each credential. It never splits the remaining quota between credentials, which would duplicate the plan or rewrite Xray on every sample.

type RealityEndpoint

type RealityEndpoint struct {
	ID            string   `json:"id"`
	EntryID       string   `json:"entryId"`
	InboundTag    string   `json:"inboundTag"`
	ListenAddress string   `json:"listenAddress"`
	ListenPort    int      `json:"listenPort"`
	AdvertiseHost string   `json:"advertiseHost"`
	AdvertisePort int      `json:"advertisePort"`
	Target        string   `json:"target"`
	ServerNames   []string `json:"serverNames"`
	PrivateKey    string   `json:"privateKey"`
	PublicKey     string   `json:"publicKey"`
	ShortIDs      []string `json:"shortIds"`
	Fingerprint   string   `json:"fingerprint"`
}

func (RealityEndpoint) Validate

func (e RealityEndpoint) Validate() error

type RouteGrant

type RouteGrant struct {
	ID           string         `json:"id"`
	AccountID    string         `json:"accountId"`
	EntryID      string         `json:"entryId"`
	EgressID     string         `json:"egressId"`
	IPv4EgressID string         `json:"ipv4EgressId,omitempty"`
	InboundTag   string         `json:"inboundTag"`
	Base         Credential     `json:"base"`
	Route        Credential     `json:"route"`
	Mode         PublishingMode `json:"mode"`
	Enabled      bool           `json:"enabled"`
	HideNative   bool           `json:"hideNative"`
	DesiredRev   uint64         `json:"desiredRevision"`
	AppliedRev   uint64         `json:"appliedRevision"`
	RuntimeGood  bool           `json:"runtimeHealthy"`
}

func (RouteGrant) Deployable

func (g RouteGrant) Deployable() bool

Deployable reports whether the desired grant belongs in the next Xray projection. AppliedRev and RuntimeGood describe the previous receipt, so they deliberately do not gate creation of a newer desired configuration.

func (RouteGrant) Publishable

func (g RouteGrant) Publishable() bool

func (RouteGrant) Validate

func (g RouteGrant) Validate() error

type RoutePeer

type RoutePeer struct {
	EgressID   string       `json:"egressId"`
	Address    string       `json:"address"`
	Port       int          `json:"port"`
	ExitFamily EgressPolicy `json:"exitFamily,omitempty"`
	Ready      bool         `json:"ready,omitempty"`
}

func (RoutePeer) Validate

func (p RoutePeer) Validate() error

type UsageMember

type UsageMember struct {
	CredentialID string `json:"credentialId"`
	Baseline     int64  `json:"baseline"`
	Observed     int64  `json:"observed"`
	Active       bool   `json:"active"`
}

func ObserveUsage

func ObserveUsage(members []UsageMember, counters map[string]int64) ([]UsageMember, error)

func ResetUsage

func ResetUsage(members []UsageMember) []UsageMember

type XrayPlan

type XrayPlan struct {
	Revision          uint64               `json:"revision"`
	NativeEgress      EgressPolicy         `json:"nativeEgress,omitempty"`
	RealityEndpoints  []RealityEndpoint    `json:"realityEndpoints,omitempty"`
	HysteriaEndpoints []HysteriaEndpoint   `json:"hysteriaEndpoints,omitempty"`
	Credentials       []CredentialMaterial `json:"credentials"`
	Grants            []RouteGrant         `json:"grants"`
	Peers             []RoutePeer          `json:"peers"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL