sub

package
v2.8.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 1, 2026 License: GPL-3.0 Imports: 32 Imported by: 0

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

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

func (s *Server) GetCtx() context.Context

GetCtx returns the server's context for cancellation and deadline management.

func (*Server) Start

func (s *Server) Start() (err error)

Start initializes and starts the subscription server with configured settings.

func (*Server) Stop

func (s *Server) Stop() error

Stop gracefully shuts down the subscription server and closes the listener.

type ServerSetting

type ServerSetting struct {
	Password string `json:"password"`
	Level    int    `json:"level"`
	Address  string `json:"address"`
	Port     int    `json:"port"`
	Flow     string `json:"flow,omitempty"`
	Method   string `json:"method,omitempty"`
}

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.

func (*SubJsonService) GetJson

func (s *SubJsonService) GetJson(subId string, host string) (string, string, error)

GetJson generates a JSON subscription configuration for the given subscription ID and host.

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.

type UserVnext

type UserVnext struct {
	ID       string `json:"id"`
	Email    string `json:"email,omitempty"`
	Security string `json:"security,omitempty"`
}

type VnextSetting

type VnextSetting struct {
	Address string      `json:"address"`
	Port    int         `json:"port"`
	Users   []UserVnext `json:"users"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL