Documentation
¶
Overview ¶
Package store is the SQLite-backed persistence layer. The DB is the single source of truth; the Xray config is always derived from it.
Index ¶
- func InspectDB(path string) (users, admins int, secret string, err error)
- type Store
- func (s *Store) ActiveDeviceCounts(since int64) (map[int64]int, error)
- func (s *Store) AddConnection(userID int64, ip string, ts int64) error
- func (s *Store) AddDailyTraffic(userID int64, day string, up, down int64) error
- func (s *Store) CancelPaymentOrderIfPending(id int64) error
- func (s *Store) Checkpoint() error
- func (s *Store) ClearUserTelegramChat(userID int64) error
- func (s *Store) ClearUserTgLinkCode(userID int64) error
- func (s *Store) Close() error
- func (s *Store) CountAdmins() (int, error)
- func (s *Store) CountUsersOnPlan(planID int64) (int, error)
- func (s *Store) CreateAPIKey(name string) (*model.APIKey, error)
- func (s *Store) CreateAdmin(username, passwordHash string) (int64, error)
- func (s *Store) CreatePaymentOrder(userID, planID int64, amountRub int) (*model.PaymentOrder, error)
- func (s *Store) CreateSession(adminID int64, ttl time.Duration) (string, error)
- func (s *Store) CreateUser(name, uuid, password, subToken string, dataLimit, expireAt int64, ...) (*model.User, error)
- func (s *Store) CreateWebhook(url string, events []string) (*model.Webhook, error)
- func (s *Store) DeleteSession(token string) error
- func (s *Store) DeleteSessionsForAdmin(adminID int64) error
- func (s *Store) DeleteSessionsForAdminExcept(adminID int64, keepToken string) error
- func (s *Store) DeleteTariffPlan(id int64) error
- func (s *Store) DeleteUser(id int64) error
- func (s *Store) DeleteUsers(ids []int64) (int64, error)
- func (s *Store) DeleteWebhook(id int64) error
- func (s *Store) EnabledWebhooksForEvent(event string) ([]model.Webhook, error)
- func (s *Store) GetAdminAuth(username string) (id int64, hash string, err error)
- func (s *Store) GetAdminHash(id int64) (string, error)
- func (s *Store) GetDetachedUserByPrevChat(chatID int64) (*model.User, error)
- func (s *Store) GetPaymentOrder(id int64) (*model.PaymentOrder, error)
- func (s *Store) GetPaymentOrderByProvider(provider, providerID string) (*model.PaymentOrder, error)
- func (s *Store) GetSettings() (*model.Settings, error)
- func (s *Store) GetTariffPlan(id int64) (*model.TariffPlan, error)
- func (s *Store) GetUser(id int64) (*model.User, error)
- func (s *Store) GetUserBySubToken(token string) (*model.User, error)
- func (s *Store) GetUserByTelegramChatID(chatID int64) (*model.User, error)
- func (s *Store) GetUserByTgLinkCode(code string) (*model.User, error)
- func (s *Store) GetWebhook(id int64) (*model.Webhook, error)
- func (s *Store) LatestPendingManualOrder(userID, planID int64) (*model.PaymentOrder, error)
- func (s *Store) LatestPendingProviderOrder(userID int64) (*model.PaymentOrder, error)
- func (s *Store) LatestPendingProviderOrderForPlan(userID, planID int64, provider string) (*model.PaymentOrder, error)
- func (s *Store) ListAPIKeys() ([]model.APIKey, error)
- func (s *Store) ListPaymentOrders(status string, limit int) ([]model.PaymentOrder, error)
- func (s *Store) ListTariffPlans(includeDisabled bool) ([]model.TariffPlan, error)
- func (s *Store) ListUsers() ([]model.User, error)
- func (s *Store) ListWebhooks() ([]model.Webhook, error)
- func (s *Store) LookupAPIKey(raw string) (*model.APIKey, error)
- func (s *Store) LookupSession(token string) (adminID int64, username string, ok bool)
- func (s *Store) MarkConfigApplied() error
- func (s *Store) MarkPaymentOrderPaidIfPending(id, paidAt int64) (bool, error)
- func (s *Store) MarkWebhookResult(id int64, status int, errStr string) error
- func (s *Store) MustChangePassword() (bool, error)
- func (s *Store) PaidByProvider() ([]model.ProviderStat, error)
- func (s *Store) PaidSumSince(since int64) (int, error)
- func (s *Store) PendingProviderOrders(limit int) ([]model.PaymentOrder, error)
- func (s *Store) PendingTotals() (count, sum int, err error)
- func (s *Store) RecentConnections(userID int64, limit int) ([]model.Connection, error)
- func (s *Store) ReencryptSensitiveFields() error
- func (s *Store) ResetDailyStats() error
- func (s *Store) ResetTraffic(id, lastUp, lastDown int64) error
- func (s *Store) ResetUserQuota(id, now, lastUp, lastDown int64) error
- func (s *Store) RevertPaymentOrderToPending(id int64) error
- func (s *Store) RevokeAPIKey(id int64) error
- func (s *Store) SaveTariffPlan(p *model.TariffPlan) error
- func (s *Store) SetACMEProvider(provider, eabKID, eabHMAC string) error
- func (s *Store) SetAPIPath(p string) error
- func (s *Store) SetAdminEvents(mask int64) error
- func (s *Store) SetAntiDPI(tlsFragment, tlsMin13, blockQUIC bool, realityMaxTimeDiff int) error
- func (s *Store) SetBillingSettings(st *model.Settings) error
- func (s *Store) SetConfigError(msg string) error
- func (s *Store) SetDecoyTemplate(name string) error
- func (s *Store) SetFingerprints(vless, trojan, reality string) error
- func (s *Store) SetHysteriaPorts(port, hopStart, hopEnd int, interval string) error
- func (s *Store) SetMustChangePassword(must bool) error
- func (s *Store) SetOpera(enabled bool, country string, port int) error
- func (s *Store) SetPanelName(name string) error
- func (s *Store) SetPanelTheme(themeJSON string) error
- func (s *Store) SetPaymentOrderProvider(id int64, provider, providerID, payURL string) error
- func (s *Store) SetPaymentOrderStatus(id int64, status string, paidAt int64) error
- func (s *Store) SetPaymentSettings(st *model.Settings) error
- func (s *Store) SetPaymentWebhookSecret(secret string) error
- func (s *Store) SetProtocolEnabled(name string, enabled bool) error
- func (s *Store) SetProtocolNames(vless, reality, trojan, hysteria string) error
- func (s *Store) SetProxyMode(enabled bool, typ string, port int, user, pass string) error
- func (s *Store) SetRealityKeys(priv, pub, shortID, serviceName string) error
- func (s *Store) SetRealityPorts(port int, dest string) error
- func (s *Store) SetResetPeriod(id int64, period string, now int64) error
- func (s *Store) SetRoutingConfig(cfg model.RoutingConfig) error
- func (s *Store) SetSecretPath(p string) error
- func (s *Store) SetSetupDone(done bool) error
- func (s *Store) SetSubSettings(st *model.Settings) error
- func (s *Store) SetSubToken(id int64, token string) error
- func (s *Store) SetTLS(host, sni, mode, certPath, keyPath string) error
- func (s *Store) SetTLSMode(mode, host, sni, acmeEmail string) error
- func (s *Store) SetTelegramBot(enabled bool, token, cron string) error
- func (s *Store) SetTelegramChats(csv string) error
- func (s *Store) SetTelegramLinkCode(code string) error
- func (s *Store) SetTelegramUserBot(enabled bool, token string, regEnabled bool) error
- func (s *Store) SetTimezone(tz string) error
- func (s *Store) SetUserEnabled(id int64, enabled bool) error
- func (s *Store) SetUserLimits(id, dataLimit, expireAt int64, deviceLimit int) error
- func (s *Store) SetUserName(id int64, name string) error
- func (s *Store) SetUserPlan(userID, planID int64, trialUsed bool) error
- func (s *Store) SetUserTelegramChat(userID, chatID int64) error
- func (s *Store) SetUserTgLinkCode(userID int64, code string) error
- func (s *Store) SetUsersEnabled(ids []int64, enabled bool) (int64, error)
- func (s *Store) SetWSPath(p string) error
- func (s *Store) SetWarp(st *model.Settings) error
- func (s *Store) SetXrayDNS(dns string) error
- func (s *Store) StatsByUser(from, to string) ([]model.UserTotal, error)
- func (s *Store) StatsSeries(userID int64, from, to string) ([]model.DailyPoint, error)
- func (s *Store) TouchLastSeen(userID, ts int64) error
- func (s *Store) UpdateAdminPassword(id int64, passwordHash string) error
- func (s *Store) UpdateAdminUsername(id int64, username string) error
- func (s *Store) UpdateTraffic(id, addUp, addDown, lastUp, lastDown int64) error
- func (s *Store) UpdateWebhook(id int64, url string, events []string, enabled bool) error
- func (s *Store) UserIDsOnPlan(planID int64) ([]int64, error)
- func (s *Store) UsersWithExpiredPlan(now int64) ([]model.User, error)
- func (s *Store) WorkingUsers(now int64) ([]model.User, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InspectDB ¶
InspectDB opens the database file at path read-only and reports whether it's a usable rospanel database, along with its user/admin counts and configured secret path. A non-nil error means the file isn't a valid panel DB (missing, corrupt, or — the classic empty-backup case — a header with no tables because the data was left in an unbacked-up WAL).
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store wraps the SQLite connection pool.
func Open ¶
Open opens (creating if needed) the SQLite database at path, applies pragmas, and runs pending migrations.
func (*Store) ActiveDeviceCounts ¶ added in v0.3.0
ActiveDeviceCounts returns how many distinct source IPs were seen per user since the given unix timestamp (typically now - DeviceOnlineWindow).
func (*Store) AddConnection ¶
AddConnection records activity from a source IP for a user (upserting the per-IP row) and bumps the user's last_seen.
func (*Store) AddDailyTraffic ¶
AddDailyTraffic adds up/down deltas to a user's row for the given UTC day.
func (*Store) CancelPaymentOrderIfPending ¶ added in v0.11.0
CancelPaymentOrderIfPending cancels an order only while it's still pending, so a stale-order sweep or a provider "canceled" status can't clobber an order a concurrent webhook just marked paid.
func (*Store) Checkpoint ¶
Checkpoint flushes the write-ahead log into the main database file and truncates it, so an on-disk copy (e.g. a backup) captures all committed data. Without this a live backup would copy a near-empty .db with everything still in the uncheckpointed .db-wal (which backups intentionally exclude).
func (*Store) ClearUserTelegramChat ¶ added in v0.3.0
ClearUserTelegramChat unlinks a VPN user's Telegram chat, remembering the chat in tg_prev_chat_id so the same chat can restore this exact account (keeping its plan and consumed trial) by registering again — instead of getting a brand-new trial user. Only overwrites tg_prev_chat_id when actually detaching a chat, so a redundant clear can't wipe a prior pointer.
func (*Store) ClearUserTgLinkCode ¶ added in v0.4.0
ClearUserTgLinkCode burns a user's pending Telegram bind code (after a successful link or on demand).
func (*Store) CountAdmins ¶
CountAdmins returns the number of admin accounts.
func (*Store) CountUsersOnPlan ¶ added in v0.4.0
CountUsersOnPlan returns how many users currently have this plan assigned.
func (*Store) CreateAPIKey ¶ added in v0.10.0
CreateAPIKey mints a new named key, stores only its HMAC hash, and returns the model record with RawKey populated (shown to the operator exactly once).
func (*Store) CreateAdmin ¶
CreateAdmin inserts an admin with the given username and password hash.
func (*Store) CreatePaymentOrder ¶ added in v0.4.0
func (*Store) CreateSession ¶
CreateSession issues a new opaque session token for an admin and stores only its HMAC hash. The raw token is returned to set as a cookie.
func (*Store) CreateUser ¶
func (s *Store) CreateUser(name, uuid, password, subToken string, dataLimit, expireAt int64, deviceLimit int) (*model.User, error)
CreateUser inserts a user with one credential set (UUID for VLESS, password for Trojan + Hysteria2), a subscription token, and optional quota/expiry.
func (*Store) CreateWebhook ¶ added in v0.10.0
CreateWebhook stores a new endpoint, generating a random HMAC signing secret (encrypted at rest) and returning the record with the plaintext secret.
func (*Store) DeleteSession ¶
DeleteSession revokes a session by its raw token.
func (*Store) DeleteSessionsForAdmin ¶ added in v0.4.0
DeleteSessionsForAdmin revokes every session for an admin.
func (*Store) DeleteSessionsForAdminExcept ¶
DeleteSessionsForAdminExcept revokes every session belonging to an admin except the one identified by keepToken — used after a credential change so a previously stolen cookie can't outlive the change, while the admin doing the change stays logged in.
func (*Store) DeleteTariffPlan ¶ added in v0.4.0
func (*Store) DeleteUsers ¶ added in v0.7.0
DeleteUsers removes many users in one statement, returning how many were deleted.
func (*Store) DeleteWebhook ¶ added in v0.10.0
DeleteWebhook removes an endpoint.
func (*Store) EnabledWebhooksForEvent ¶ added in v0.10.0
EnabledWebhooksForEvent returns the enabled endpoints subscribed to event — the dispatcher's fan-out set. Subscription is filtered in Go (the events CSV is tiny) so "empty = all" stays in one place (model.Webhook.Subscribed).
func (*Store) GetAdminAuth ¶
GetAdminAuth returns the admin id and password hash for a username.
func (*Store) GetAdminHash ¶
GetAdminHash returns an admin's current password hash by id (for re-authenticating a credential change against the current password).
func (*Store) GetDetachedUserByPrevChat ¶ added in v0.11.0
GetDetachedUserByPrevChat finds an account this chat was previously unlinked from and that is still detached (no active chat), so registration can restore it instead of creating a new trial user. Returns sql.ErrNoRows when none.
func (*Store) GetPaymentOrder ¶ added in v0.4.0
func (s *Store) GetPaymentOrder(id int64) (*model.PaymentOrder, error)
func (*Store) GetPaymentOrderByProvider ¶ added in v0.6.0
func (s *Store) GetPaymentOrderByProvider(provider, providerID string) (*model.PaymentOrder, error)
GetPaymentOrderByProvider finds a pending-or-any order by its external id.
func (*Store) GetSettings ¶
GetSettings returns the singleton settings row.
func (*Store) GetTariffPlan ¶ added in v0.4.0
func (s *Store) GetTariffPlan(id int64) (*model.TariffPlan, error)
func (*Store) GetUserBySubToken ¶
GetUserBySubToken resolves a subscription token to its user.
func (*Store) GetUserByTelegramChatID ¶ added in v0.3.0
GetUserByTelegramChatID resolves a linked Telegram chat to its VPN user.
func (*Store) GetUserByTgLinkCode ¶ added in v0.4.0
GetUserByTgLinkCode resolves a pending one-time Telegram bind code to its user, rejecting codes that are blank, unknown, or expired.
func (*Store) GetWebhook ¶ added in v0.10.0
GetWebhook returns one endpoint by id.
func (*Store) LatestPendingManualOrder ¶ added in v0.11.0
func (s *Store) LatestPendingManualOrder(userID, planID int64) (*model.PaymentOrder, error)
LatestPendingManualOrder returns the newest still-pending manual order (no provider set) for a user+plan, or sql.ErrNoRows. Lets callers reuse an order instead of piling up duplicates when the user re-taps "Pay".
func (*Store) LatestPendingProviderOrder ¶ added in v0.11.0
func (s *Store) LatestPendingProviderOrder(userID int64) (*model.PaymentOrder, error)
LatestPendingProviderOrder returns the newest still-pending order that went through an automatic provider for a user (or sql.ErrNoRows). Used by the subscription page to show a "payment processing" state after the user returns from the provider until the webhook/poll confirms it.
func (*Store) LatestPendingProviderOrderForPlan ¶ added in v0.11.0
func (s *Store) LatestPendingProviderOrderForPlan(userID, planID int64, provider string) (*model.PaymentOrder, error)
LatestPendingProviderOrderForPlan returns the newest pending order for a user+plan+provider (or sql.ErrNoRows). Lets the pay flow reuse a fresh order instead of creating duplicates on repeated taps.
func (*Store) ListAPIKeys ¶ added in v0.10.0
ListAPIKeys returns all keys (active and revoked), newest first. RawKey is never populated here — it exists only in the CreateAPIKey response.
func (*Store) ListPaymentOrders ¶ added in v0.4.0
func (*Store) ListTariffPlans ¶ added in v0.4.0
func (s *Store) ListTariffPlans(includeDisabled bool) ([]model.TariffPlan, error)
ListTariffPlans returns plans sorted for display.
func (*Store) ListWebhooks ¶ added in v0.10.0
ListWebhooks returns every configured endpoint, newest first.
func (*Store) LookupAPIKey ¶ added in v0.10.0
LookupAPIKey resolves a raw key to its record, ignoring revoked keys. The lookup is by HMAC hash (a UNIQUE-indexed column) so the DB does the comparison; the raw key never touches storage. last_used_at is bumped on a successful, non-revoked match. Returns (nil, nil) when no active key matches.
func (*Store) LookupSession ¶
LookupSession resolves a raw session token to its admin. Expired sessions are deleted and treated as invalid.
func (*Store) MarkConfigApplied ¶
MarkConfigApplied bumps the config revision and clears any prior error.
func (*Store) MarkPaymentOrderPaidIfPending ¶ added in v0.8.1
MarkPaymentOrderPaidIfPending atomically transitions an order pending→paid and reports whether THIS call performed the transition. Exactly one of several concurrent confirmers (provider webhook + the poll fallback + a re-delivered webhook) wins the CAS; a caller that gets false must not apply the plan, so a single payment can never extend the user twice.
func (*Store) MarkWebhookResult ¶ added in v0.10.0
MarkWebhookResult records the outcome of a delivery attempt (status is the HTTP code, 0 on a connection-level failure; errStr is "" on success).
func (*Store) MustChangePassword ¶
MustChangePassword reports whether the admin must replace the default password before the rest of the panel unlocks (set at first-run bootstrap, cleared on the first password change).
func (*Store) PaidByProvider ¶ added in v0.10.0
func (s *Store) PaidByProvider() ([]model.ProviderStat, error)
PaidByProvider returns paid-order revenue grouped by provider ("" = manual), highest-earning first. Queried against payment_orders directly (no user join) so revenue from since-deleted users is still counted.
func (*Store) PaidSumSince ¶ added in v0.10.0
PaidSumSince returns the total paid revenue whose paid_at is at or after since.
func (*Store) PendingProviderOrders ¶ added in v0.6.0
func (s *Store) PendingProviderOrders(limit int) ([]model.PaymentOrder, error)
PendingProviderOrders returns pending orders that were started through a payment provider (for the polling fallback). Stale ones (older than maxAge seconds) are skipped — the caller marks them cancelled.
func (*Store) PendingTotals ¶ added in v0.10.0
PendingTotals returns the count and rouble total of orders awaiting payment.
func (*Store) RecentConnections ¶
RecentConnections returns a user's source IPs, most recent first.
func (*Store) ReencryptSensitiveFields ¶ added in v0.4.0
ReencryptSensitiveFields migrates legacy plaintext secrets to enc:v1: at-rest blobs.
func (*Store) ResetDailyStats ¶
ResetDailyStats clears the entire per-day traffic history.
func (*Store) ResetTraffic ¶
ResetTraffic zeroes a user's usage (so a "limited" user works again) and re-baselines the raw counters to the supplied live Xray values, so the next stats poll measures the delta from now. Passing 0/0 would make the poll re-add the user's whole lifetime Xray total straight back onto the freshly-zeroed usage. Does not touch enabled or expiry — an expired user stays expired.
func (*Store) ResetUserQuota ¶
ResetUserQuota zeroes a user's usage and records the reset time (automatic reset scheduler). It re-baselines the raw counters to the supplied live Xray values so the next stats poll measures the delta from now — passing 0/0 would make the poll re-add the whole lifetime total back. enabled/expiry untouched; status is derived on read.
func (*Store) RevertPaymentOrderToPending ¶ added in v0.8.1
RevertPaymentOrderToPending puts a claimed order back to pending so the polling fallback retries — used when applying the plan failed after the paid claim.
func (*Store) RevokeAPIKey ¶ added in v0.10.0
RevokeAPIKey marks a key revoked (idempotent). The row is kept so a revoked key still shows in the UI with its metadata; the hash stays so the same raw key can never be silently re-lived.
func (*Store) SaveTariffPlan ¶ added in v0.4.0
func (s *Store) SaveTariffPlan(p *model.TariffPlan) error
func (*Store) SetACMEProvider ¶
SetACMEProvider persists the ACME CA selection and (for ZeroSSL) the External Account Binding credentials. An empty provider defaults to "letsencrypt".
func (*Store) SetAPIPath ¶ added in v0.10.0
SetAPIPath persists the external-API URL segment (empty disables the surface).
func (*Store) SetAdminEvents ¶ added in v0.7.0
SetAdminEvents persists the admin notification bitmask (model.AdminEvent* flags).
func (*Store) SetAntiDPI ¶
SetAntiDPI persists the anti-DPI transport-hardening settings (Settings → Подключения): client-config shaping (TLS fragmentation, QUIC block) and the server-inbound knobs (TLS 1.3 floor, REALITY anti-replay window + donor port).
func (*Store) SetBillingSettings ¶ added in v0.4.0
func (*Store) SetConfigError ¶
SetConfigError records the last failed config-apply error.
func (*Store) SetDecoyTemplate ¶
SetDecoyTemplate persists the masquerade (decoy) template slug.
func (*Store) SetFingerprints ¶
SetFingerprints persists the per-connection uTLS fingerprints used in links.
func (*Store) SetHysteriaPorts ¶
SetHysteriaPorts persists the Hysteria2 base port, hop range, and hop interval.
func (*Store) SetMustChangePassword ¶
SetMustChangePassword sets or clears the forced-password-change gate.
func (*Store) SetOpera ¶
SetOpera persists the Opera VPN egress settings (enable flag, region, and the local proxy port the opera-proxy helper listens on).
func (*Store) SetPanelName ¶ added in v0.5.0
func (*Store) SetPanelTheme ¶ added in v0.5.0
func (*Store) SetPaymentOrderProvider ¶ added in v0.6.0
SetPaymentOrderProvider links an order to an external provider payment.
func (*Store) SetPaymentOrderStatus ¶ added in v0.4.0
func (*Store) SetPaymentSettings ¶ added in v0.6.0
SetPaymentSettings persists the payment-provider config (secrets encrypted).
func (*Store) SetPaymentWebhookSecret ¶ added in v0.6.0
SetPaymentWebhookSecret stores the random webhook URL segment.
func (*Store) SetProtocolEnabled ¶
SetProtocolEnabled flips a single protocol's on/off toggle.
func (*Store) SetProtocolNames ¶ added in v0.11.0
SetProtocolNames persists the custom per-connection display names (empty ⇒ the default protocol label is used at render time).
func (*Store) SetProxyMode ¶
SetProxyMode persists the forward-proxy inbound configuration.
func (*Store) SetRealityKeys ¶
SetRealityKeys persists a freshly generated REALITY keypair, shortId, and gRPC service name.
func (*Store) SetRealityPorts ¶
SetRealityPorts persists the REALITY port and destination (SNI/serverName).
func (*Store) SetResetPeriod ¶
SetResetPeriod sets a user's automatic quota-reset period and anchors the cycle at now.
func (*Store) SetRoutingConfig ¶
func (s *Store) SetRoutingConfig(cfg model.RoutingConfig) error
SetRoutingConfig persists the structured routing configuration as JSON.
func (*Store) SetSecretPath ¶
SetSecretPath persists the hidden panel path segment.
func (*Store) SetSetupDone ¶
SetSetupDone marks the first-run wizard as completed.
func (*Store) SetSubSettings ¶
SetSubSettings persists the subscription delivery settings.
func (*Store) SetSubToken ¶ added in v0.3.0
SetSubToken replaces a user's subscription capability token. The old URL stops working immediately; protocol credentials (UUID/password) are unchanged.
func (*Store) SetTLSMode ¶
SetTLSMode persists the TLS mode, domain (host), SNI and ACME e-mail.
func (*Store) SetTelegramBot ¶ added in v0.2.0
SetTelegramBot persists the bot's enable flag, token, and backup schedule (a 5-field cron expression in the operator timezone; empty disables scheduling).
func (*Store) SetTelegramChats ¶ added in v0.2.0
SetTelegramChats replaces the comma-separated set of authorized chat IDs.
func (*Store) SetTelegramLinkCode ¶ added in v0.2.0
SetTelegramLinkCode stores (or clears, with "") the pending one-time linking code.
func (*Store) SetTelegramUserBot ¶ added in v0.3.0
SetTelegramUserBot persists the public user bot's enable flag, token, and the self-registration toggle.
func (*Store) SetTimezone ¶
SetTimezone persists the operator's IANA timezone (e.g. "Europe/Moscow").
func (*Store) SetUserEnabled ¶
SetUserEnabled sets the independent manual on/off flag. Expiry/quota are separate and never change this.
func (*Store) SetUserLimits ¶
SetUserLimits sets the data limit (bytes), expiry (unix, 0 = none), and the simultaneous device cap (0 = unlimited). Does not touch the manual enabled flag; status is derived on read.
func (*Store) SetUserName ¶
SetUserName updates a user's display name.
func (*Store) SetUserPlan ¶ added in v0.4.0
func (*Store) SetUserTelegramChat ¶ added in v0.3.0
SetUserTelegramChat links a Telegram chat to a VPN user, first detaching the chat from any other user (one chat ⇒ at most one account).
func (*Store) SetUserTgLinkCode ¶ added in v0.4.0
SetUserTgLinkCode stores (or clears, with "") a user's pending Telegram bind code, stamping the issue time so it can expire.
func (*Store) SetUsersEnabled ¶ added in v0.7.0
SetUsersEnabled flips the manual enabled flag for many users in one statement, returning how many rows changed. Empty ids is a no-op.
func (*Store) SetXrayDNS ¶
SetXrayDNS persists the operator's Xray DNS servers.
func (*Store) StatsByUser ¶
StatsByUser returns each user's traffic total over the period (users with no traffic appear with zeros), busiest first.
func (*Store) StatsSeries ¶
StatsSeries returns per-day totals between from and to (inclusive, YYYY-MM-DD). userID == 0 aggregates across all users.
func (*Store) TouchLastSeen ¶
TouchLastSeen updates a user's last activity time (used by the poller too).
func (*Store) UpdateAdminPassword ¶
UpdateAdminPassword replaces an admin's password hash.
func (*Store) UpdateAdminUsername ¶
UpdateAdminUsername changes an admin's login name.
func (*Store) UpdateTraffic ¶
UpdateTraffic adds deltas to lifetime totals and records the raw counters.
func (*Store) UpdateWebhook ¶ added in v0.10.0
UpdateWebhook replaces the mutable fields (url, events, enabled) of an endpoint.
func (*Store) UserIDsOnPlan ¶ added in v0.11.0
UserIDsOnPlan returns the ids of users currently assigned to a plan (used to migrate them when a plan is retired).
func (*Store) UsersWithExpiredPlan ¶ added in v0.4.0
func (*Store) WorkingUsers ¶
WorkingUsers returns users that should be in the proxy config right now: manually enabled AND not expired AND within their data limit AND within their device limit. enabled is an independent manual flag — expiry/quota/devices never change it, they just exclude the user from the config here.