Documentation
¶
Overview ¶
Package sub provides subscription server functionality for the 3x-ui panel, including HTTP/HTTPS servers for serving subscription links and JSON configurations.
Index ¶
- type Outbound
- type PageData
- type SUBController
- type Server
- type ServerSetting
- type SubJsonService
- type SubService
- func (s *SubService) BuildPageData(subId string, hostHeader string, traffic xray.ClientTraffic, lastOnline int64, ...) PageData
- func (s *SubService) BuildURLs(scheme, hostWithPort, subPath, subJsonPath, subId string) (subURL, subJsonURL string)
- func (s *SubService) GetSubs(subId string, host string) ([]string, int64, xray.ClientTraffic, error)
- func (s *SubService) ResolveRequest(c *gin.Context) (scheme string, host string, hostWithPort string, hostHeader string)
- type UserVnext
- type VnextSetting
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Outbound ¶
type Outbound struct {
Protocol string `json:"protocol"`
Tag string `json:"tag"`
StreamSettings json_util.RawMessage `json:"streamSettings"`
Mux json_util.RawMessage `json:"mux,omitempty"`
Settings map[string]any `json:"settings,omitempty"`
}
type PageData ¶
type PageData struct {
Host string
BasePath string
SId string
Download string
Upload string
Total string
Used string
Remained string
Expire int64
LastOnline int64
Datepicker string
DownloadByte int64
UploadByte int64
TotalByte int64
SubUrl string
SubJsonUrl string
Result []string
}
PageData is a view model for subpage.html PageData contains data for rendering the subscription information page.
type SUBController ¶
type SUBController struct {
// contains filtered or unexported fields
}
SUBController handles HTTP requests for subscription links and JSON configurations.
func NewSUBController ¶
func NewSUBController( g *gin.RouterGroup, subPath string, jsonPath string, jsonEnabled bool, encrypt bool, showInfo bool, rModel string, update string, jsonFragment string, jsonNoise string, jsonMux string, jsonRules string, subTitle string, ) *SUBController
NewSUBController creates a new subscription controller with the given configuration.
func (*SUBController) ApplyCommonHeaders ¶
func (a *SUBController) ApplyCommonHeaders(c *gin.Context, header, updateInterval, profileTitle string)
ApplyCommonHeaders sets common HTTP headers for subscription responses including user info, update interval, and profile title.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents the subscription server that serves subscription links and JSON configurations.
func NewServer ¶
func NewServer() *Server
NewServer creates a new subscription server instance with a cancellable context.
func (*Server) GetCtx ¶
GetCtx returns the server's context for cancellation and deadline management.
type ServerSetting ¶
type SubJsonService ¶
type SubJsonService struct {
SubService *SubService
// contains filtered or unexported fields
}
SubJsonService handles JSON subscription configuration generation and management.
func NewSubJsonService ¶
func NewSubJsonService(fragment string, noises string, mux string, rules string, subService *SubService) *SubJsonService
NewSubJsonService creates a new JSON subscription service with the given configuration.
type SubService ¶
type SubService struct {
// contains filtered or unexported fields
}
SubService provides business logic for generating subscription links and managing subscription data.
func NewSubService ¶
func NewSubService(showInfo bool, remarkModel string) *SubService
NewSubService creates a new subscription service with the given configuration.
func (*SubService) BuildPageData ¶
func (s *SubService) BuildPageData(subId string, hostHeader string, traffic xray.ClientTraffic, lastOnline int64, subs []string, subURL, subJsonURL string, basePath string) PageData
BuildPageData parses header and prepares the template view model. BuildPageData constructs page data for rendering the subscription information page.
func (*SubService) BuildURLs ¶
func (s *SubService) BuildURLs(scheme, hostWithPort, subPath, subJsonPath, subId string) (subURL, subJsonURL string)
BuildURLs constructs absolute subscription and JSON subscription URLs for a given subscription ID. It prioritizes configured URIs, then individual settings, and finally falls back to request-derived components.
func (*SubService) GetSubs ¶
func (s *SubService) GetSubs(subId string, host string) ([]string, int64, xray.ClientTraffic, error)
GetSubs retrieves subscription links for a given subscription ID and host.
func (*SubService) ResolveRequest ¶
func (s *SubService) ResolveRequest(c *gin.Context) (scheme string, host string, hostWithPort string, hostHeader string)
ResolveRequest extracts scheme and host info from request/headers consistently. ResolveRequest extracts scheme, host, and header information from an HTTP request.