Help us shape the future of Go! Take the 2026 Go Developer Survey

render

package
v1.21.2 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package render builds the client configurations of subscription delivery and template previews: it maps nodes to the proxies a client template renders and executes the template in the application's output format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	Type           string            // Protocol type
	SiteName       string            // Site name
	Servers        []*node.Node      // Nodes the configuration lists
	UserInfo       User              // Subscriber the configuration is for
	ClientTemplate string            // Client configuration template
	OutputFormat   string            // Output format, base64 by default
	SubscribeName  string            // Subscription (plan) name
	Params         map[string]string // Template parameters
}

Adapter collects what a client configuration is rendered from.

func NewAdapter

func NewAdapter(tpl string, opts ...Option) *Adapter

func (*Adapter) Client

func (adapter *Adapter) Client() (*Client, error)

func (*Adapter) Proxies

func (adapter *Adapter) Proxies(servers []*node.Node) ([]Proxy, error)

type Client

type Client struct {
	SiteName       string            // Name of the site
	SubscribeName  string            // Name of the subscription
	ClientTemplate string            // Template for the entire client configuration
	OutputFormat   string            // json, yaml, etc.
	Proxies        []Proxy           // List of proxy configurations
	UserInfo       User              // User information
	Params         map[string]string // Additional parameters
}

func (*Client) Build

func (c *Client) Build() ([]byte, error)

type Option

type Option func(*Adapter)

func WithOutputFormat

func WithOutputFormat(format string) Option

WithOutputFormat sets the output format.

func WithParams

func WithParams(params map[string]string) Option

func WithServers

func WithServers(servers []*node.Node) Option

WithServers sets the nodes the configuration lists.

func WithSiteName

func WithSiteName(name string) Option

WithSiteName sets the site name.

func WithSubscribeName

func WithSubscribeName(name string) Option

WithSubscribeName sets the subscription (plan) name.

func WithUserInfo

func WithUserInfo(user User) Option

WithUserInfo sets the subscriber the configuration is for.

type Proxy

type Proxy struct {
	Sort    int
	Name    string
	Server  string
	Port    uint16
	Type    string
	Tags    []string
	Version int
	Mode    string
	Network string

	// Security Options
	Security         string
	SNI              string // Server Name Indication for TLS
	ALPN             []string
	AllowInsecure    bool   // Allow insecure connections (skip certificate verification)
	Fingerprint      string // Client fingerprint for TLS connections
	RealityPublicKey string // Reality public key for authentication
	RealityShortId   string // Reality short ID for authentication
	// Transport Options
	Transport   string // Transport protocol (e.g., ws, http, grpc)
	Host        string // For WebSocket/HTTP/HTTPS
	Path        string // For HTTP/HTTPS
	ServiceName string // For gRPC
	// Shadowsocks Options
	Method              string
	ServerKey           string // For Shadowsocks 2022
	Plugin              string
	PluginOptions       any
	UoT                 bool // UDP over TCP
	UoTVersion          int  // UoT version (1 or 2)
	AcceptProxyProtocol bool

	// Vmess/Vless/Trojan Options
	Flow string // Flow for Vmess/Vless/Trojan
	// Hysteria2 Options
	HopPorts     string // Comma-separated list of hop ports
	HopInterval  int    // Interval for hop ports in seconds
	ObfsPassword string // Obfuscation password for Hysteria2
	UpMbps       int    // Upload speed in Mbps
	DownMbps     int    // Download speed in Mbps

	// Tuic Options
	DisableSNI            bool // Disable SNI
	ReduceRtt             bool // Reduce RTT
	Heartbeat             int
	UDPRelayMode          string // UDP relay mode (e.g., "full", "partial")
	CongestionController  string // Congestion controller (e.g., "cubic", "bbr")
	QUICCongestionControl string

	// AnyTLS
	PaddingScheme string

	// Protocol-independent multiplexing and Mieru options.
	Multiplex           string
	TrafficPattern      string
	UserHintIsMandatory bool

	// ShadowsocksR and compatible obfuscation options.
	Obfs          string
	SSRProtocol   string
	ProtocolParam string
	ObfsParam     string
	ObfsHost      string
	ObfsPath      string

	// Vless
	XhttpMode  string // xhttp mode
	XhttpExtra string // xhttp path

	// encryption
	Encryption              string // encryption, 'none', 'mlkem768x25519plus'
	EncryptionMode          string // encryption mode, 'native', 'xorpub', 'random'
	EncryptionRtt           string // encryption rtt, '0rtt', '1rtt'
	EncryptionClientPadding string // encryption client padding
	EncryptionPassword      string // encryption password

	// ECH
	EchEnable     bool   // ECH enable
	EchServerName string // ECH SNI

	Ratio    float64 // Traffic ratio, default is 1
	CertMode string  // Certificate mode, `none`|`http`|`dns`|`self`
	// The DNS provider and its credentials (CertDNSProvider, CertDNSEnv) and
	// the REALITY handshake target (RealityServerAddr, RealityServerPort)
	// stay on the server: a client only needs the pin below, the SNI and the
	// REALITY public key and short id.
	CertPinSHA256 string // SHA256 fingerprint of the self-signed certificate (lowercase hex)
}

type User

type User struct {
	ID           int64
	Password     string
	ExpiredAt    time.Time
	Download     int64
	Upload       int64
	Traffic      int64
	SubscribeURL string
}

Jump to

Keyboard shortcuts

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