Documentation
¶
Overview ¶
Package domain holds the entities shared by every layer of the panel.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIToken ¶
type APIToken struct {
UUID string `json:"uuid"`
Name string `json:"name"`
TokenHash string `json:"-"`
Preview string `json:"tokenPreview"`
CreatedBy string `json:"createdBy"`
LastUsedAt *time.Time `json:"lastUsedAt"`
ExpiresAt *time.Time `json:"expiresAt"`
CreatedAt time.Time `json:"createdAt"`
}
APIToken authenticates an external integration against the panel API.
type AdminRole ¶
type AdminRole string
type BillingCycle ¶
type BillingCycle string
BillingCycle is how often a node has to be paid for.
const ( BillingNone BillingCycle = "NONE" BillingMonthly BillingCycle = "MONTHLY" BillingQuarterly BillingCycle = "QUARTERLY" BillingYearly BillingCycle = "YEARLY" )
func (BillingCycle) Advance ¶
func (c BillingCycle) Advance(from time.Time) time.Time
Advance returns the next payment date one cycle after the given one.
func (BillingCycle) MonthlyCost ¶
func (c BillingCycle) MonthlyCost(amount float64) float64
MonthlyCost normalises a billing cycle onto a monthly figure so nodes on different cycles can be summed.
func (BillingCycle) Valid ¶
func (c BillingCycle) Valid() bool
type ConfigProfile ¶
type ConfigProfile struct {
UUID string `json:"uuid"`
Name string `json:"name"`
Config json.RawMessage `json:"config"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
Inbounds []ConfigProfileInbound `json:"inbounds,omitempty"`
NodeIDs []string `json:"nodeUuids,omitempty"`
}
ConfigProfile is a reusable xray-core configuration document. Nodes are bound to exactly one profile and serve a subset of its inbounds.
type ConfigProfileInbound ¶
type ConfigProfileInbound struct {
UUID string `json:"uuid"`
ConfigProfileID string `json:"profileUuid"`
ProfileName string `json:"profileName,omitempty"`
Tag string `json:"tag"`
Type string `json:"type"`
Network string `json:"network"`
Security string `json:"security"`
Port int `json:"port"`
}
ConfigProfileInbound mirrors one inbound of the profile document. It is extracted on save so squads and hosts can reference inbounds by identity instead of by fragile string tags.
type Device ¶
type Device struct {
UserID string `json:"userUuid"`
HWID string `json:"hwid"`
UserAgent string `json:"userAgent"`
Platform string `json:"platform"`
FirstSeen time.Time `json:"firstSeen"`
LastSeen time.Time `json:"lastSeen"`
}
Device is one client seen on a user's subscription.
type EventKind ¶
type EventKind string
EventKind classifies audit log records.
const ( EventNodeConnected EventKind = "NODE_CONNECTED" EventNodeDisconnected EventKind = "NODE_DISCONNECTED" EventNodeConfigPushed EventKind = "NODE_CONFIG_PUSHED" EventNodeError EventKind = "NODE_ERROR" EventUserCreated EventKind = "USER_CREATED" EventUserUpdated EventKind = "USER_UPDATED" EventUserDeleted EventKind = "USER_DELETED" EventUserLimited EventKind = "USER_LIMITED" EventUserExpired EventKind = "USER_EXPIRED" EventAdminLogin EventKind = "ADMIN_LOGIN" EventAdminLoginFailed EventKind = "ADMIN_LOGIN_FAILED" EventProfileUpdated EventKind = "PROFILE_UPDATED" EventNodePaymentDue EventKind = "NODE_PAYMENT_DUE" EventDeviceBlocked EventKind = "DEVICE_LIMIT_REACHED" EventSettingsUpdated EventKind = "SETTINGS_UPDATED" )
type Host ¶
type Host struct {
UUID string `json:"uuid"`
InboundID string `json:"inboundUuid"`
InboundTag string `json:"inboundTag,omitempty"`
InboundType string `json:"inboundType,omitempty"`
ProfileID string `json:"configProfileUuid,omitempty"`
ProfileName string `json:"configProfileName,omitempty"`
Remark string `json:"remark"`
Address string `json:"address"`
Port int `json:"port"`
Path string `json:"path"`
SNI string `json:"sni"`
HostHeader string `json:"hostHeader"`
ALPN string `json:"alpn"`
Fingerprint string `json:"fingerprint"`
PublicKey string `json:"publicKey"`
ShortID string `json:"shortId"`
SpiderX string `json:"spiderX"`
Flow string `json:"flow"`
Security string `json:"security"`
AllowInsecure bool `json:"allowInsecure"`
Tags []string `json:"tags"`
IsDisabled bool `json:"isDisabled"`
ViewPosition int `json:"viewPosition"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
Host is a client-facing entry point advertised in subscriptions. It points at one inbound of a config profile but may carry its own address/SNI/etc so a single inbound can be published behind many domains or CDNs.
type Node ¶
type Node struct {
UUID string `json:"uuid"`
Name string `json:"name"`
Address string `json:"address"`
CountryCode string `json:"countryCode"`
Description string `json:"description"`
TokenHash string `json:"-"`
// TokenPreview keeps the last characters of the enrolment token so the UI can
// tell two nodes apart without ever exposing the secret again.
TokenPreview string `json:"tokenPreview"`
IsDisabled bool `json:"isDisabled"`
Health NodeHealth `json:"health"`
ConfigProfileID *string `json:"configProfileUuid"`
ConfigProfileName string `json:"configProfileName,omitempty"`
ActiveInboundTags []string `json:"activeInboundTags"`
ConsumptionMultip float64 `json:"consumptionMultiplier"`
TrafficLimitBytes int64 `json:"trafficLimitBytes"`
TrafficUsedBytes int64 `json:"trafficUsedBytes"`
TrafficResetPolicy TrafficResetStrategy `json:"trafficResetStrategy"`
NotifyPercent int `json:"notifyPercent"`
LastTrafficResetAt *time.Time `json:"lastTrafficResetAt"`
AgentVersion string `json:"agentVersion"`
XrayVersion string `json:"xrayVersion"`
XrayRunning bool `json:"xrayRunning"`
XrayStartedAt *time.Time `json:"xrayStartedAt"`
ConfigHash string `json:"configHash"`
Hostname string `json:"hostname"`
OS string `json:"os"`
Arch string `json:"arch"`
Kernel string `json:"kernel"`
CPUCount int `json:"cpuCount"`
CPUModel string `json:"cpuModel"`
CPUUsage float64 `json:"cpuUsagePercent"`
TotalRAMBytes int64 `json:"totalRamBytes"`
UsedRAMBytes int64 `json:"usedRamBytes"`
LoadAvg1 float64 `json:"loadAvg1"`
OnlineUsers int `json:"onlineUsers"`
// Infrastructure billing: what this node costs and who it is rented from.
Provider string `json:"provider"`
ProviderURL string `json:"providerUrl"`
CostAmount float64 `json:"costAmount"`
CostCurrency string `json:"costCurrency"`
BillingCycle BillingCycle `json:"billingCycle"`
NextPaymentAt *time.Time `json:"nextPaymentAt"`
BillingNotes string `json:"billingNotes"`
Tags []string `json:"tags"`
StatusMessage string `json:"statusMessage"`
LastStatusAt *time.Time `json:"lastStatusChangeAt"`
LastConnectedAt *time.Time `json:"lastConnectedAt"`
ViewPosition int `json:"viewPosition"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
Node is a server running the agent and an xray-core process.
type NodeHealth ¶
type NodeHealth string
const ( NodeHealthUnknown NodeHealth = "UNKNOWN" NodeHealthConnecting NodeHealth = "CONNECTING" NodeHealthOnline NodeHealth = "ONLINE" NodeHealthDegraded NodeHealth = "DEGRADED" NodeHealthOffline NodeHealth = "OFFLINE" NodeHealthDisabled NodeHealth = "DISABLED" NodeHealthTrafficLimit NodeHealth = "TRAFFIC_LIMITED" )
type NodeUsageSample ¶
type NodeUsageSample struct {
NodeID string `json:"nodeUuid"`
NodeName string `json:"nodeName,omitempty"`
At time.Time `json:"at"`
Bytes int64 `json:"bytes"`
}
NodeUsageSample is one bucketed traffic measurement for a node.
type Settings ¶
type Settings struct {
BrandName string `json:"brandName"`
BrandTagline string `json:"brandTagline"`
BrandLogo string `json:"brandLogo"`
BrandAccent string `json:"brandAccent"`
SubscriptionTitle string `json:"subscriptionTitle"`
SupportURL string `json:"supportUrl"`
Currency string `json:"currency"`
UpdatedAt time.Time `json:"updatedAt"`
}
Settings holds the panel-wide knobs an operator can change at runtime, including white-label branding for corporate deployments.
type Squad ¶
type Squad struct {
UUID string `json:"uuid"`
Name string `json:"name"`
Info string `json:"info"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
InboundIDs []string `json:"inboundUuids"`
Inbounds []ConfigProfileInbound `json:"inbounds,omitempty"`
MemberCount int `json:"membersCount"`
}
Squad groups inbounds together; users are attached to squads rather than to individual inbounds, which keeps bulk membership changes cheap.
type TrafficResetStrategy ¶
type TrafficResetStrategy string
const ( ResetNever TrafficResetStrategy = "NO_RESET" ResetDay TrafficResetStrategy = "DAY" ResetWeek TrafficResetStrategy = "WEEK" ResetMonth TrafficResetStrategy = "MONTH" )
func (TrafficResetStrategy) Valid ¶
func (s TrafficResetStrategy) Valid() bool
type User ¶
type User struct {
UUID string `json:"uuid"`
ShortUUID string `json:"shortUuid"`
Username string `json:"username"`
SubscriptionUUID string `json:"subscriptionUuid"`
VlessUUID string `json:"vlessUuid"`
TrojanPassword string `json:"trojanPassword"`
SSPassword string `json:"ssPassword"`
Status UserStatus `json:"status"`
TrafficLimitBytes int64 `json:"trafficLimitBytes"`
UsedTrafficBytes int64 `json:"usedTrafficBytes"`
LifetimeTrafficBytes int64 `json:"lifetimeUsedTrafficBytes"`
TrafficResetPolicy TrafficResetStrategy `json:"trafficLimitStrategy"`
LastTrafficResetAt *time.Time `json:"lastTrafficResetAt"`
ExpireAt *time.Time `json:"expireAt"`
OnlineAt *time.Time `json:"onlineAt"`
Description string `json:"description"`
Tag string `json:"tag"`
Email string `json:"email"`
TelegramID *int64 `json:"telegramId"`
HWIDDeviceLimit int `json:"hwidDeviceLimit"`
SubLastUA string `json:"subLastUserAgent"`
SubLastOpenedAt *time.Time `json:"subLastOpenedAt"`
SubRevokedAt *time.Time `json:"subRevokedAt"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
SquadIDs []string `json:"squadUuids"`
Squads []Squad `json:"squads,omitempty"`
}
User is a VPN client.
type UserStatus ¶
type UserStatus string
const ( UserActive UserStatus = "ACTIVE" UserDisabled UserStatus = "DISABLED" UserLimited UserStatus = "LIMITED" UserExpired UserStatus = "EXPIRED" )
func (UserStatus) Valid ¶
func (s UserStatus) Valid() bool