Documentation
¶
Overview ¶
Package sub builds the per-user subscription: the machine payload consumed by VPN clients and the human-facing page (QR + one-tap import buttons).
Index ¶
- func AppRedirect(href template.URL) ([]byte, error)
- func Base64Payload(links []string) string
- func ClashWithTemplate(u model.User, set *model.Settings, template string) string
- func ClashYAML(u model.User, set *model.Settings) string
- func Logo() []byte
- func Page(u model.User, set *model.Settings, billing Billing) ([]byte, error)
- func ShareLinks(u model.User, set *model.Settings) []string
- func SingBoxJSON(u model.User, set *model.Settings) string
- func SubTitle(u model.User, set *model.Settings) string
- func URL(set *model.Settings, token string) string
- type Billing
- type BillingPay
- type BillingPlan
- type DeepLink
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppRedirect ¶ added in v0.11.0
AppRedirect renders the deep-link hand-off page for one client's share link.
func Base64Payload ¶
Base64Payload is the universal v2ray-style subscription body: the links joined by newlines, base64-encoded. Consumed by v2rayNG, Hiddify, Streisand, NekoBox, Shadowrocket, etc.
func ClashWithTemplate ¶
ClashWithTemplate injects the user's proxies into a RoscomVPN-style Mihomo routing template. The template carries two "# LEAVE THIS LINE!" markers: the `proxies:` line (full proxy definitions) and a slot inside the main select group (proxy node names). Falls back to the plain config if the template has no proxies marker.
func ClashYAML ¶
ClashYAML renders a minimal self-contained Clash-Meta (Mihomo) configuration: the user's proxies plus a single select group and a catch-all rule.
func Page ¶
Page renders the human-facing subscription page (usage stats, QR of the sub URL, copy button, per-client import buttons, and the raw links).
func ShareLinks ¶
ShareLinks returns the enabled protocol links for a user, in client-import order. Protocols switched off in the Connections panel are omitted.
func SingBoxJSON ¶
SingBoxJSON renders an importable sing-box configuration (current 1.11+ schema) with a tun inbound, the enabled protocol outbounds, an auto urltest + manual selector, and a minimal route. Targeted at official SFA/SFI/SFM clients; other sing-box-based clients (Hiddify, NekoBox) consume the base64 list instead.
Types ¶
type Billing ¶ added in v0.11.0
type Billing struct {
Show bool
CurrentPlan string // active plan name ("" = none / manual)
ExpireText string // "до DD.MM.YYYY" for a paid expiry, else ""
Plans []BillingPlan // paid plans offered for purchase/renewal
Providers []BillingPay // enabled payment methods (empty ⇒ manual only)
Manual bool // no automatic provider ⇒ pay button creates a manual order
Note string // manual-payment instructions when no provider is set
PayPath string // POST target that starts a payment (<SubURL>/pay)
OrderPath string // GET target that reports a pending provider payment (<SubURL>/order)
// Locked is true while a paid plan is active: only that plan (renewal) is shown,
// switching to another is blocked, and Cancelable offers cancellation instead.
Locked bool
Cancelable bool
CancelPath string // POST target that cancels the active plan (<SubURL>/cancel)
}
Billing is the optional "renew / pay" block on the subscription page. It's built by the server (which has plan + payment-provider access) and left zero (Show false) when billing is off or no paid plans exist.
type BillingPay ¶ added in v0.11.0
BillingPay is one payment method the user can choose.
type BillingPlan ¶ added in v0.11.0
type BillingPlan struct {
ID int64
Name string
Label string // price + period, e.g. "199 ₽ / 30 дн."
Current bool // the user's currently active plan
}
BillingPlan is one purchasable paid tariff shown on the page.