glivela

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

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

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 Imports: 29 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

Glivela

Glivela manages proxy entries, landings, routes and subscriptions through an independent control panel. It integrates with Vastora for application installation, updates and access to the panel.

What it provides

  • Account credentials, quotas and subscription generation.
  • VLESS/REALITY entries, SS2022 forwarding and OpenClash/Mihomo client chains.
  • Entry and landing inventory, route configuration and availability controls.
  • IP quality and unlock results, route latency and node-to-node speed tests.
  • Network-optimization status and explicitly requested configuration changes.

The controller and panel run as a nonroot Docker application. Entry and landing roles run as native services with the reviewed official Xray core. Nodes use the private authenticated control channel; proxy traffic stays on its configured path.

Getting started

Install the controller and required node roles through Vastora, open the Glivela application, initialize its business state, then configure an entry, landing and subscription. Keep bootstrap files, certificates, protocol credentials and state outside the source checkout.

Diagnostics

Development

The Go module requires Go 1.26; the UI uses the locked dependencies in ui/. See UI development and release publication. Existing CI checks the backend, native distribution, UI and dependencies.

control/ owns orchestration and the management API, landing/ owns the landing runtime, and ui/ owns the panel. The offline tool in tools/legacy-export/ is separate from installed runtimes; see its README before importing existing data.

Public examples use synthetic node labels and documentation addresses. Operational records, deployments, credentials, subscription URLs and real fleet inventory do not belong in this repository. Node labels are operator-provided; Glivela does not maintain a vendor-specific alias list.

License

Apache-2.0. Bundled third-party programs retain their own licenses and notices.

Retaining issued subscription labels and an existing host guard during upgrades: operator-owned configuration.

For two enrolled native nodes with a verified provider LAN, choose 专属内网 IPv4 · SS2022 when creating a client chain, or use 修改落地传输 on its existing route details. Supply the entry source address/interface and landing listener address/interface. Both addresses must be single RFC1918 IPv4 addresses already assigned to the specified interfaces. Only the existing chain's TCP listener is authorized; no subnet access or automatic public fallback is created. Ordinary native traffic and all other public/shared listeners retain their existing policy.

The management client-chains request accepts privateLink: {source, address, sourceInterface, interface} with the existing chain/account/entry/egress identity and current expectedRevision. Omit privateLink to preserve an existing link; use clearPrivateLink: true explicitly to restore the original public transport. Existing chain credentials and subscription identity remain unchanged. Server-forwarding and three-hop private transport are outside this MVP. Upgrade the selected controller, native entry and landing before applying this policy. Refresh the original Mihomo/OpenClash subscription, verify HTTPS and the final exit, and confirm both-end traffic uses the private interfaces. Private-link web speed/latency measurements are not currently provided.

Managed ingress DNS resources

An administrator may supply a non-secret DNS resource in the authenticated advertise-host request's resource field, alongside entryId, action: apply and the exact expectedRevision string. The resource contains id, hostname, address, type (A or AAAA), revision, appliedRevision, and status. It must be ready, fully applied, and resolve to the same public address as the current entry. Exact successful retries are idempotent. SNI remains separate.

The host manager owns domain allocation and provider access. Glivela receives no DNS-provider key or host-manager administrator session, does not read its database, and retains its own identities, permissions and task state. This optional portable provisioning input does not add a runtime dependency on Vastora. DNS propagation and real subscription access must be verified before accepting a migration.

Subscription profiles

The account panel offers 仅节点 (the existing format negotiation and node order) and Aethersailor 重度分流 (OpenClash/Mihomo). Both links use the same subscription identity and published inventory. The optional profile uses ?format=mihomo&profile=aethersailor; profile=nodes or no profile retains existing behavior. URI output with the Full profile is rejected.

The Full profile includes policy groups and rules, without DNS, TUN, listeners or local network settings. It does not edit installed client profiles. Keep local company/private-network overrides ahead of imported rules; clients need compatible geosite/geoip data and access to rule-provider downloads. See template provenance and adaptation.

Shadowrocket 重度分流:在订阅类型选择 Aethersailor 后选择“小火箭”,先在首页导入配套节点订阅,再在配置页下载原生 .conf。保留原配置并合并已有 DNS、公司与内网优先规则后使用;下载配置不会自动完成本地合并。

小火箭原生兼容范围:保留分类、策略组及规则顺序;不支持上游 DOMAIN-REGEX 和 SRC-PORT。未匹配流量继续匹配后续规则或兜底策略,不保证与 OpenClash 完全等价。

Documentation

Overview

Package glivela 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"
)
View Source
const IPv4ClientSS2022 = "ipv4-ss2022"
View Source
const IPv4ClientSS2022Method = "2022-blake3-aes-256-gcm"
View Source
const IPv4RelaySS2022 = "ipv4-relay-ss2022"

IPv4RelaySS2022 is an exact-source client-only relay, independent of the server-forwarding source grants.

View Source
const ManagedLocalTLSTarget = "127.0.0.1:24483"

ManagedLocalTLSTarget is the fixed TLS origin published on loopback by Vastora's managed gateway. It is not a general private-target allowance.

View Source
const SS2022Method = "2022-blake3-aes-128-gcm"
View Source
const XrayRenderVersion uint8 = 31

XrayRenderVersion identifies the deterministic entry configuration format. Bit zero retains the REALITY UDP 443 policy. Bit one removes the retired management-port blacklist. Bit two enables automatic TCP family fallback. Bit three selects IPv6 resolver transport for explicit IPv6-only entries. Bit four permits explicitly scoped provider-LAN client sockets. Versions 0..3, 7 and 15 remain immutable snapshot readers.

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 PrivateClientIPv4

func PrivateClientIPv4(value string) bool

func PublicTransportIPv4

func PublicTransportIPv4(value string) bool

PublicTransportIPv4 permits a single canonical unicast endpoint, never a subnet, wildcard, private management address or DNS-dependent destination.

func PublicTransportIPv6

func PublicTransportIPv6(value string) bool

PublicTransportIPv6 accepts only a canonical, non-transition global unicast address. Transport endpoints and authorized sources are exact addresses, never prefixes or names resolved by a different network namespace.

func RenderAethersailorProfile

func RenderAethersailorProfile(body []byte, items []SubscriptionItem) ([]byte, error)

RenderAethersailorProfile wraps the already-authorized Mihomo inventory. It never edits proxy transport settings, credentials, ordering or helpers.

func RenderLinks(entries []NativeEntry, accountID string, mode PublishingMode, routes []PublishedRoute, order []string, encoded bool) ([]byte, error)

func RenderShadowrocketNodes

func RenderShadowrocketNodes(body []byte) ([]byte, error)

RenderShadowrocketNodes retains the published inventory but uses native URI fields. Shadowrocket's Clash importer can select Chrome120 even when the source requests chrome plus ML-KEM; its native fingerprint field is explicit.

func RenderShadowrocketProfile

func RenderShadowrocketProfile(body []byte) ([]byte, error)

RenderShadowrocketProfile renders native policy configuration for the same node subscription. Shadowrocket keeps subscribed nodes separate from .conf files: exact names bind these groups to the unchanged native node inventory. No General, Host, DNS, scripts, rewrites or local override sections are emitted.

func RenderXrayConfiguration

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

func RouteUser

func RouteUser(grantID string) string

func SealImportMaterial

func SealImportMaterial(m ImportMaterial, key []byte, snapshotID string) ([]byte, error)

SealImportMaterial uses standard authenticated encryption with an externally supplied 256-bit transfer key. Nonces come from Go's GCM implementation. The authenticated snapshot identifier prevents swapping material between exports. Successful decryption is not evidence that the legacy writer is fenced.

func SubscriptionTokenFingerprint

func SubscriptionTokenFingerprint(token string) string

func ValidIdentifier

func ValidIdentifier(value string) bool

func ValidIdentity

func ValidIdentity(value string) bool

func ValidRealityTargetPin

func ValidRealityTargetPin(target, pin string) bool

ValidRealityTargetPin checks the durable hostname/port and reviewed address. The only non-public destination is the managed same-host TLS origin.

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 ValidateEndpointImport

func ValidateEndpointImport(material ImportMaterial, endpoints []ImportEndpoint) error

ValidateEndpointImport covers every credential's existing entry, not just entries selected for the first landing migration. Empty account inventories may legitimately coexist with configured endpoints and vice versa.

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 BusinessOwnership

type BusinessOwnership struct {
	Origin           string `json:"origin,omitempty"`
	SourceSHA256     string `json:"sourceSha256"`
	CaptureSHA256    string `json:"captureSha256"`
	PreviousWriterID string `json:"previousWriterId"`
	StoppedAt        string `json:"stoppedAt"`
	CapturedAt       string `json:"capturedAt"`
}

BusinessOwnership is sealed with the business data by the one-time offline handover tool after it verifies the final backup and stopped old writer. It records data authority, never current process/route health. The previous writer identity is opaque to the controller, not a host capability contract.

func (BusinessOwnership) Validate

func (o BusinessOwnership) Validate(sourceSHA256 string) error

type ClientChain

type ClientChain struct {
	PrivateLink *PrivateClientLink `json:"privateLink,omitempty"`
	EgressIP    string             `json:"egressIp,omitempty"`
	Shared      bool               `json:"shared,omitempty"`
	Relay       *ClientChainRelay  `json:"relay,omitempty"`
	// IPv6SS2022 chains carry separately authorized, exact transport addresses.
	// Empty transport fields identify existing IPv4 client chains.
	Transport            string `json:"transport,omitempty"`
	SourceIPv6           string `json:"sourceIpv6,omitempty"`
	ServerIPv6           string `json:"serverIpv6,omitempty"`
	EntryCertificateID   string `json:"entryCertificateId,omitempty"`
	LandingCertificateID string `json:"landingCertificateId,omitempty"`
	ID                   string `json:"id"`
	AccountID            string `json:"accountId"`
	EntryID              string `json:"entryId"`
	EgressID             string `json:"egressId"`
	Name                 string `json:"name"`
	Port                 int    `json:"port"`
	Key                  string `json:"key"`
	Enabled              bool   `json:"enabled"`
}

ClientChain contains a dedicated user credential, never the server transport key. It is stored only inside the encrypted business material.

func (ClientChain) Validate

func (c ClientChain) Validate() error

type ClientChainRelay

type ClientChainRelay struct {
	NodeID        string `json:"nodeId"`
	CertificateID string `json:"certificateId"`
	Transport     string `json:"transport,omitempty"`
	SourceIPv4    string `json:"sourceIpv4,omitempty"`
	ServerIPv4    string `json:"serverIpv4,omitempty"`
	SourceIPv6    string `json:"sourceIpv6"`
	ServerIPv6    string `json:"serverIpv6"`
	Port          int    `json:"port"`
	Key           string `json:"key"`
}

ClientChainRelay holds a separate credential for the intermediate hop. As with the final landing credential, it remains encrypted at rest.

func (ClientChainRelay) ValidateServerRelay

func (r ClientChainRelay) ValidateServerRelay(final PrivateTransport) error

type ClientLanding

type ClientLanding struct {
	AccountID string `json:"accountId"`
	Key       string `json:"key"`
}

ClientLanding is a shared transport credential owned by one account. It survives that account's client-to-server forwarding migration; original per-chain configuration stays retained for explicit forward recovery.

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 BuildDesiredArtifactVersion

func BuildDesiredArtifactVersion(plan XrayPlan, version uint8) (DesiredArtifact, error)

BuildDesiredArtifactVersion verifies persisted entry snapshots using their exact rendering format. Callers creating new desired state use the current version; loading a snapshot never rewrites its bytes, digest or revision.

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 keeps automatic family selection, not the host/control-plane resolver. Every native policy uses Glivela's explicit business DNS.

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 {
	// RetiredUsageBytes preserves this period's account-wide consumption after
	// dedicated route credentials and per-node watermarks have been erased.
	RetiredUsageBytes            int64             `json:"retiredUsageBytes,omitempty"`
	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"`
}

func (ImportAccount) Quota

func (a ImportAccount) Quota() (QuotaProjection, error)

Quota retains consumed bytes from permanently retired routes without retaining their credentials or attributing them to another live counter.

type ImportApplication

type ImportApplication struct {
	Name           string `json:"name"`
	NodeID         string `json:"nodeId"`
	Runtime        string `json:"runtime"`
	PreviousStatus string `json:"previousStatus"`
}

type ImportEndpoint

type ImportEndpoint struct {
	// PreviousAdvertiseHost authorizes recovery of the latest metadata-only
	// subscription address change, without accepting unrelated runtime drift.
	PreviousAdvertiseHost string `json:"previousAdvertiseHost,omitempty"`

	RealityChanges       []RealityTargetChange `json:"realityChanges,omitempty"`
	Reality              RealityEndpoint       `json:"reality"`
	Hysteria             *HysteriaEndpoint     `json:"hysteria,omitempty"`
	ServiceID            string                `json:"serviceId"`
	RuntimeCertificateID string                `json:"runtimeCertificateId,omitempty"`
	RuntimeConfigSHA256  string                `json:"runtimeConfigSha256,omitempty"`
	TargetIP             string                `json:"targetIp"`
	VLESSEnabled         bool                  `json:"vlessEnabled"`
	HysteriaEnabled      bool                  `json:"hysteriaEnabled"`
	TotalBytes           int64                 `json:"totalBytes"`
	UsedBytes            int64                 `json:"usedBytes"`
	QuotaAppliedEnabled  bool                  `json:"quotaAppliedEnabled"`
	ResetDay             int                   `json:"resetDay"`
	ResetSchedule        ImportResetSchedule   `json:"resetSchedule"`
	DesiredRevision      uint64                `json:"desiredRevision"`
	AppliedRevision      uint64                `json:"appliedRevision"`
	HistoricalHealthy    bool                  `json:"historicalHealthy"`
	PreviousStatus       string                `json:"previousStatus"`
	PreviousError        string                `json:"previousError"`
	LegacyRetired        bool                  `json:"legacyRetired"`
	// Retired is the current endpoint policy. LegacyRetired above only
	// records retirement of the old implementation, not this endpoint.
	Retired             bool            `json:"retired"`
	SourcePeerJSON      json.RawMessage `json:"sourcePeer"`
	CertificateNotAfter string          `json:"certificateNotAfter"`
	CreatedAt           string          `json:"createdAt"`
	UpdatedAt           string          `json:"updatedAt"`
}

ImportEndpoint retains the existing proxy configuration and historical observations. None of PreviousStatus, AppliedRevision or HistoricalHealthy is fresh runtime evidence for the newly enrolled controller.

func (ImportEndpoint) Validate

func (e ImportEndpoint) Validate() error

type ImportLandingSelection

type ImportLandingSelection struct {
	NodeIDs             []string          `json:"nodeIds"`
	LandingRegionCodes  map[string]string `json:"landingRegionCodes,omitempty"`
	LandingNameSuffixes map[string]string `json:"landingNameSuffixes,omitempty"`
	RetiringNodeIDs     []string          `json:"retiringNodeIds,omitempty"`
	Revision            uint64            `json:"revision"`
}

type ImportMaterial

type ImportMaterial struct {
	// Grant ID to enrolled landing certificate. Bound by the immutable grant
	// account/entry/exit; captured only after current mutual enrollment proof.
	ManagedRouteLandings map[string]string `json:"managedRouteLandings,omitempty"`

	RetiredLandings    map[string]RetiredLanding    `json:"retiredLandings,omitempty"`
	SubscriptionOrders map[string]SubscriptionOrder `json:"subscriptionOrders,omitempty"`
	// Deleted entries remain disabled and retained for identity and accounting history.
	DeletedRoutes       map[string]bool `json:"deletedRoutes,omitempty"`
	DeletedClientChains map[string]bool `json:"deletedClientChains,omitempty"`

	ClientLandings     map[string]ClientLanding         `json:"clientLandings,omitempty"`
	ClientChains       []ClientChain                    `json:"clientChains,omitempty"`
	SourceSHA256       string                           `json:"sourceSha256"`
	RetainedSource     json.RawMessage                  `json:"retainedSource"`
	Endpoints          []ImportEndpoint                 `json:"endpoints"`
	References         ImportReferences                 `json:"references"`
	Plan               ImportPlan                       `json:"plan"`
	SubscriptionTokens map[string]string                `json:"subscriptionTokens"`
	ProtocolSecrets    map[string]string                `json:"protocolSecrets"`
	HysteriaSecrets    map[string]string                `json:"hysteriaSecrets"`
	ResetSchedules     map[string]ImportResetSchedule   `json:"resetSchedules"`
	TrafficCounters    map[string]ImportTrafficCounters `json:"trafficCounters"`
	Ownership          *BusinessOwnership               `json:"ownership,omitempty"`
}

ImportMaterial is one atomic, sensitive handover checkpoint. RetainedSource is migration history, never a second live configuration source. An explicit offline retirement operation may redact expired-host history while retaining its source identity header. Never send this material in a receipt or logs.

func OpenImportMaterial

func OpenImportMaterial(sealed, key []byte, snapshotID string) (ImportMaterial, error)

func (ImportMaterial) EffectiveClientChain

func (m ImportMaterial) EffectiveClientChain(c ClientChain) (ClientChain, error)

func (ImportMaterial) Validate

func (m ImportMaterial) Validate() error

type ImportNode

type ImportNode struct {
	Name                string          `json:"name"`
	PreviousStatus      string          `json:"previousStatus"`
	ServiceAddress      string          `json:"serviceAddress"`
	PrivateAddress      string          `json:"privateAddress"`
	PeerJSON            json.RawMessage `json:"peer,omitempty"`
	EgressAddressesJSON json.RawMessage `json:"egressAddresses,omitempty"`
}

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 ImportPublication

type ImportPublication struct {
	ServiceID           string `json:"serviceId"`
	EntryNodeID         string `json:"entryNodeId"`
	Kind                string `json:"kind"`
	IngressOwner        string `json:"ingressOwner"`
	Hostname            string `json:"hostname"`
	SNIHostname         string `json:"sniHostname"`
	DNSProvider         string `json:"dnsProvider"`
	DNSRecordID         string `json:"dnsRecordId"`
	AccessApplicationID string `json:"accessApplicationId"`
	TLSEnabled          bool   `json:"tlsEnabled"`
	DesiredRevision     uint64 `json:"desiredRevision"`
	AppliedRevision     uint64 `json:"appliedRevision"`
	PreviousStatus      string `json:"previousStatus"`
	PreviousError       string `json:"previousError"`
	ActionRequired      bool   `json:"actionRequired"`
	CleanupPending      bool   `json:"cleanupPending"`
	CleanupAttempt      int64  `json:"cleanupAttempt"`
	CleanupRetryAt      string `json:"cleanupRetryAt"`
	CreatedAt           string `json:"createdAt"`
	UpdatedAt           string `json:"updatedAt"`
}

type ImportReferences

type ImportReferences struct {
	Nodes            map[string]ImportNode        `json:"nodes"`
	Applications     map[string]ImportApplication `json:"applications"`
	Services         map[string]ImportService     `json:"services"`
	Publications     map[string]ImportPublication `json:"publications"`
	LandingSelection *ImportLandingSelection      `json:"landingSelection,omitempty"`
}

ImportReferences preserves object identities and display/publication data. PreviousStatus and saved network observations are not current reachability or write authority. No platform credentials/capability matrix are imported.

type ImportResetSchedule

type ImportResetSchedule struct {
	NextResetAt string `json:"nextResetAt"`
	LastResetAt string `json:"lastResetAt"`
}

Preserve the recorded schedule, not a newly calculated cycle from import time. Strings retain the source timestamp's precision and offset verbatim.

type ImportService

type ImportService struct {
	Timezone            string `json:"timezone"`
	ApplicationID       string `json:"applicationId"`
	Name                string `json:"name"`
	DisplayName         string `json:"displayName"`
	RegionCode          string `json:"regionCode"`
	Protocol            string `json:"protocol"`
	ApplicationProtocol string `json:"applicationProtocol"`
	ContainerPort       int    `json:"containerPort"`
	HostPort            int    `json:"hostPort"`
	Endpoint            string `json:"endpoint"`
	PreviousStatus      string `json:"previousStatus"`
}

type ImportTrafficCounters

type ImportTrafficCounters struct {
	UploadBytes         int64  `json:"uploadBytes"`
	DownloadBytes       int64  `json:"downloadBytes"`
	RawUploadBytes      int64  `json:"rawUploadBytes"`
	RawDownloadBytes    int64  `json:"rawDownloadBytes"`
	StartedAt           string `json:"startedAt"`
	ObservedAt          string `json:"observedAt"`
	WatermarkObservedAt string `json:"watermarkObservedAt"`
}

Directional totals and raw counter watermarks have different meanings from the account quota baseline. Neither may be reconstructed from their sum.

type NativeEntry

type NativeEntry struct {
	Material CredentialMaterial `json:"material"`
	Protocol ProtocolKind       `json:"protocol"`
	Link     string             `json:"link"`
}
type PrivateClientLink struct {
	Source          string `json:"source"`
	Address         string `json:"address"`
	SourceInterface string `json:"sourceInterface"`
	Interface       string `json:"interface"`
}

PrivateClientLink authorizes one provider-LAN socket, never a private subnet. Interface ownership is checked again on each owning native runtime.

func (PrivateClientLink) Validate

func (p PrivateClientLink) Validate() error

type PrivateClientPolicy

type PrivateClientPolicy struct {
	PrivateClientLink
	ID        string `json:"id"`
	AccountID string `json:"accountId"`
	Port      int    `json:"port"`
}

type PrivateTransport

type PrivateTransport struct {
	// PrivateLink binds an existing client listener to one enrolled provider-LAN
	// socket. PublicAddress retains its wire field name but must equal Address.
	PrivateLink *PrivateClientLink `json:"privateLink,omitempty"`
	// Port is explicit only for the shared public SS2022 listener. Zero reads
	// retained server policies at their original port; it is not dial fallback.
	ClientListenerID string `json:"clientListenerId,omitempty"`
	Port             int    `json:"port,omitempty"`
	Protocol         string `json:"protocol,omitempty"`
	Key              string `json:"key,omitempty"`
	PublicAddress    string `json:"publicAddress,omitempty"`
}

PrivateTransport belongs to the server entry-to-landing connection; never serialize this policy into a public subscription or diagnostic output. An explicitly shared listener can use an already-issued client key, without exposing any retained server-only key. Empty values read retained SOCKS policy.

func (PrivateTransport) Endpoint

func (t PrivateTransport) Endpoint(privateAddress string) string

func (PrivateTransport) ListenerPort

func (t PrivateTransport) ListenerPort() int

func (PrivateTransport) Method

func (t PrivateTransport) Method() string

Method reuses the cipher implied by the issued listener's canonical key.

func (PrivateTransport) Validate

func (t PrivateTransport) Validate() error

type ProtocolKind

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

func (ProtocolKind) Valid

func (p ProtocolKind) Valid() bool

type PublicSSHPolicy

type PublicSSHPolicy struct {
	HostPublicAddresses []string `json:"hostPublicAddresses"`
	AddressesComplete   bool     `json:"addressesComplete"`
}

PublicSSHPolicy decodes the retired optional SSH policy in immutable historical artifacts and exact firewall cleanup only. New desired builders remove it; there is no management API or maintenance command that enables this policy.

func (*PublicSSHPolicy) Clone

func (p *PublicSSHPolicy) Clone() *PublicSSHPolicy

func (*PublicSSHPolicy) RequireHost

func (p *PublicSSHPolicy) RequireHost(value string) error

RequireHost catches omissions of already-known public literals. Hostnames and private NAT interfaces do not prove a complete external mapping.

func (*PublicSSHPolicy) Validate

func (p *PublicSSHPolicy) Validate() error

type PublishedClientChain

type PublishedClientChain struct {
	Chain              ClientChain
	Base               NativeEntry
	Server             string
	EgressRegionPrefix string
	EgressNameSuffix   string
}

type PublishedRoute

type PublishedRoute struct {
	Name                   string       `json:"name,omitempty"`
	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 RealityInitialRepair

type RealityInitialRepair struct {
	CertificateID  string `json:"certificateId"`
	ConfigSHA256   string `json:"configSha256"`
	EvidenceSHA256 string `json:"evidenceSha256"`
	VerifiedAt     string `json:"verifiedAt"`
}

RealityInitialRepair records an administrator attestation, not a node receipt or public-client acceptance. The full evidence stays outside business state.

type RealityTargetChange

type RealityTargetChange struct {
	InitialRepair       *RealityInitialRepair `json:"initialRepair,omitempty"`
	RevertedAt          string                `json:"revertedAt,omitempty"`
	Reason              string                `json:"reason,omitempty"`
	PreviousTarget      string                `json:"previousTarget"`
	PreviousTargetIP    string                `json:"previousTargetIp"`
	PreviousServerNames []string              `json:"previousServerNames"`
	Target              string                `json:"target"`
	TargetIP            string                `json:"targetIp"`
	ServerName          string                `json:"serverName"`
	State               string                `json:"state"`
	ChangedAt           string                `json:"changedAt"`
	EvidenceSHA256      string                `json:"evidenceSha256,omitempty"`
	VerifiedAt          string                `json:"verifiedAt,omitempty"`
}

RealityTargetChange retains only fields needed for forward recovery. It never snapshots account secrets, quotas or traffic ledgers.

type RetiredLanding

type RetiredLanding struct {
	CertificateID string `json:"certificateId"`
	Revision      uint64 `json:"revision,string"`
}

RetiredLanding retains only a revocation fence, never a reusable credential.

type RouteGrant

type RouteGrant struct {
	// ClientChainID selects one retained three-hop path without replacing a direct peer.
	ClientChainID string         `json:"clientChainId,omitempty"`
	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) PeerKey

func (g RouteGrant) PeerKey() string

func (RouteGrant) Publishable

func (g RouteGrant) Publishable() bool

Publishable follows configured authorization; runtime observations are advisory.

func (RouteGrant) Validate

func (g RouteGrant) Validate() error

type RoutePeer

type RoutePeer struct {
	ClientChainID string            `json:"clientChainId,omitempty"`
	Relay         *ClientChainRelay `json:"relay,omitempty"`
	Transport     PrivateTransport  `json:"transport,omitzero"`
	EgressID      string            `json:"egressId"`
	Address       string            `json:"address"`
	Port          int               `json:"port"`
	ExitFamily    EgressPolicy      `json:"exitFamily,omitempty"`
	Ready         bool              `json:"ready,omitempty"`
}

func (RoutePeer) DialTransport

func (p RoutePeer) DialTransport() PrivateTransport

DialTransport is the only socket opened by the entry. The final SS2022 connection is carried inside the separately authorized intermediate hop.

func (RoutePeer) PeerKey

func (p RoutePeer) PeerKey() string

func (RoutePeer) ServerOutbounds

func (p RoutePeer) ServerOutbounds(tag string) []any

ServerOutbounds retains both independent issued credentials and chains the final proxy through the relay. Neither outbound has a direct fallback.

func (RoutePeer) Validate

func (p RoutePeer) Validate() error

type SubscriptionItem

type SubscriptionItem struct {
	ID       string       `json:"id"`
	Kind     string       `json:"kind"`
	Name     string       `json:"name"`
	Protocol ProtocolKind `json:"protocol"`
}

SubscriptionItem identifies an actual selectable output without its credential.

func RenderMihomo

func RenderMihomo(entries []NativeEntry, accountID string, mode PublishingMode, routes []PublishedRoute, order []string, chains ...PublishedClientChain) ([]byte, []SubscriptionItem, error)

type SubscriptionOrder

type SubscriptionOrder struct {
	Revision uint64   `json:"revision,string"`
	IDs      []string `json:"ids"`
}

SubscriptionOrder is presentation-only account data in the encrypted business source. Its revision is independent of node configurations and traffic.

func (SubscriptionOrder) Validate

func (o SubscriptionOrder) 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 {
	ClientLinks       []PrivateClientPolicy `json:"clientLinks,omitempty"`
	PublicSSH         *PublicSSHPolicy      `json:"publicSSH,omitempty"`
	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"`
}

Directories

Path Synopsis
cmd
glivela command
Glivela owns node communication; the installer only supplies bootstrap files.
Glivela owns node communication; the installer only supplies bootstrap files.
Package control implements Glivela's direct, authenticated node channel.
Package control implements Glivela's direct, authenticated node channel.
internal
Package ipquality defines the bounded, public subset of an IPQuality report.
Package ipquality defines the bounded, public subset of an IPQuality report.
Package landing contains the node-local boundary for optional SOCKS5 egress.
Package landing contains the node-local boundary for optional SOCKS5 egress.
tools
alpine-acceptance command
Isolated native-runtime acceptance fixture.
Isolated native-runtime acceptance fixture.

Jump to

Keyboard shortcuts

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