Documentation
¶
Overview ¶
Package subscription turns a user's hosts into client-ready connection links.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Base64 ¶
Base64 renders the classic base64 subscription payload understood by nearly every client.
func Clash ¶
Clash renders a Mihomo/Clash.Meta profile. It is emitted as YAML by hand because the document is small, fixed in shape, and hand-writing it avoids a YAML dependency in the panel.
func Headers ¶
Headers are the subscription-userinfo style metadata clients read to display quota and expiry without opening the panel.
func SingBox ¶
SingBox renders a sing-box client configuration with a selector and a urltest group over every host.
func XrayJSON ¶ added in v0.1.1
XrayJSON renders the "JSON subscription" that v2rayN, v2rayNG, Happ and Streisand accept: an array of complete Xray client configurations, one per host, each ready to run as-is. It is the most faithful of the formats — a vless:// link has to squeeze every stream setting through a query string, while this carries the same structure xray-core actually parses.
Every entry is self-contained on purpose. Clients present them as a server list and switch between them, so an entry that leaned on a shared block would stop working the moment the user picked a different one.
Types ¶
type Bundle ¶
type Bundle struct {
User *domain.User
Hosts []domain.Host
// Title is shown as the profile name in client apps.
Title string
SupportURL string
// UpdateInterval is how often clients should refresh, in hours.
UpdateInterval int
}
Bundle is everything a subscription response is built from.
type Format ¶
type Format string
Format is a subscription encoding a client understands.
func DetectClientFormat ¶ added in v0.1.1
DetectClientFormat reports the format a client needs when it names itself. The second return distinguishes "this client requires Clash" from "no idea what this is" — the caller has a configured default for the second case, and collapsing the two would apply that default to clients that cannot read it.
func DetectFormat ¶
DetectFormat picks an encoding from the client's User-Agent, falling back to the base64 list that every client understands.
func (Format) ContentType ¶
ContentType is what the response should be served as.
type Info ¶
type Info struct {
Username string `json:"username"`
Status string `json:"status"`
UsedBytes int64 `json:"usedTrafficBytes"`
LimitBytes int64 `json:"trafficLimitBytes"`
LifetimeBytes int64 `json:"lifetimeUsedTrafficBytes"`
ExpireAt *time.Time `json:"expireAt"`
SubscriptionURL string `json:"subscriptionUrl"`
Links []string `json:"links"`
Title string `json:"title"`
SupportURL string `json:"supportUrl,omitempty"`
DaysLeft *int `json:"daysLeft,omitempty"`
}
Info is the JSON payload the subscription page renders.