Documentation
¶
Overview ¶
Package singbox renders sing-box server configurations.
It earns its place beside xray and hysteria for two reasons. One binary serves TUIC, Hysteria2, VLESS, VMess, Trojan and Shadowsocks, so a protocol added here costs a renderer rather than another process on every node. And unlike hysteria it ships an offline validator — `sing-box check` — which means a document can be refused while the operator is still looking at it, instead of on a node at restart time.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoInbounds = errors.New("a sing-box config needs at least one inbound") ErrBadConfig = errors.New("invalid sing-box config") )
Functions ¶
func Render ¶
func Render(profile json.RawMessage, opts RenderOptions) ([]byte, string, error)
Render writes the users into each inbound in the shape its type expects, and returns the bytes a node runs plus their hash.
func Starter ¶
func Starter(domain string) json.RawMessage
Starter is a working TUIC + Hysteria2 document to edit rather than write from nothing, in the same spirit as the VLESS + REALITY starter.
func Validate ¶
func Validate(config json.RawMessage) error
Types ¶
type Inbound ¶
Inbound is the part of an inbound the panel needs to know about: enough to let a squad grant it and a host publish it.
func ParseInbounds ¶
func ParseInbounds(config json.RawMessage) ([]Inbound, error)
ParseInbounds pulls out the inbounds a squad can grant.
type RenderOptions ¶
type User ¶
type User struct {
// Name is what sing-box logs and counts traffic against. It carries the
// uuid so a figure can be charged back even if a username is reused later.
Name string
UUID string
Password string
Flow string
}
User is one subscriber. Which fields matter depends on the inbound type, so all of them travel and the renderer picks.