glivela

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

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

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

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 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 = 3

XrayRenderVersion identifies the deterministic entry configuration format. Bit zero retains the REALITY UDP 443 policy. Bit one removes the retired management-port blacklist. Versions 0/1 are immutable snapshot readers only.

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 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 RenderLinks(entries []NativeEntry, accountID string, mode PublishingMode, routes []PublishedRoute, order []string, encoded bool) ([]byte, error)

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 {
	Shared bool `json:"shared,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 ClientLanding

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

ClientLanding is a client-only credential owned by one account. 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 {
	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 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 {
	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 immutable migration evidence/history, never a second live configuration source. Do not send this material in a node receipt or publish it in 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 PrivateTransport

type PrivateTransport struct {
	Protocol      string `json:"protocol,omitempty"`
	Key           string `json:"key,omitempty"`
	PublicAddress string `json:"publicAddress,omitempty"`
}

PrivateTransport belongs only to the entry-to-landing connection. Its key must never be included in public subscriptions or diagnostic output. Empty values describe the retained pre-migration SOCKS configuration, not fallback.

func (PrivateTransport) Endpoint

func (t PrivateTransport) Endpoint(privateAddress string) string

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 {
	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 RealityTargetChange

type RealityTargetChange struct {
	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 endpoint fields needed for a forward-revision cancellation. It never snapshots account secrets, quotas or traffic ledgers.

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

Publishable follows configured authorization; runtime observations are advisory.

func (RouteGrant) Validate

func (g RouteGrant) Validate() error

type RoutePeer

type RoutePeer struct {
	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) 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 {
	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.

Jump to

Keyboard shortcuts

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