protocol

package
v0.0.0-...-f50c79f Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: GPL-3.0 Imports: 57 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NaiveConfigureHTTP3ListenerFunc func(
	ctx context.Context,
	logger logger.Logger,
	listener *listener.Listener,
	handler http.Handler,
	tlsConfig tls.ServerConfig,
	options option.NaiveInboundOptions,
) (io.Closer, error)

NaiveConfigureHTTP3ListenerFunc is set by the naivequic init package (built with the with_quic tag) to wire up HTTP/3 + QUIC support.

View Source
var NaiveWrapError func(error) error

NaiveWrapError is set by the naivequic init package to wrap QUIC errors.

Functions

func RegisterAnyTLS

func RegisterAnyTLS(registry *inbound.Registry)

func RegisterHysteria2

func RegisterHysteria2(registry *inbound.Registry)

func RegisterNaive

func RegisterNaive(registry *inbound.Registry)

func RegisterShadowTLS

func RegisterShadowTLS(registry *inbound.Registry)

RegisterShadowTLS overrides the built-in ShadowTLS factory in registry.

func RegisterShadowsocks

func RegisterShadowsocks(registry *inbound.Registry)

RegisterShadowsocks overrides the built-in Shadowsocks factory in registry.

func RegisterTUIC

func RegisterTUIC(registry *inbound.Registry)

RegisterTUIC overrides the built-in TUIC factory in registry.

func RegisterTrojan

func RegisterTrojan(registry *inbound.Registry)

RegisterTrojan overrides the built-in Trojan factory in registry.

func RegisterVLESS

func RegisterVLESS(registry *inbound.Registry)

RegisterVLESS overrides the built-in VLESS factory in registry.

func RegisterVMess

func RegisterVMess(registry *inbound.Registry)

RegisterVMess overrides the built-in VMess factory in registry.

Types

type AnyTLSInbound

type AnyTLSInbound struct {
	inbound.Adapter
	// contains filtered or unexported fields
}

func (*AnyTLSInbound) AddUsers

func (h *AnyTLSInbound) AddUsers(users []option.AnyTLSUser) error

func (*AnyTLSInbound) Close

func (h *AnyTLSInbound) Close() error

func (*AnyTLSInbound) DelUsers

func (h *AnyTLSInbound) DelUsers(names []string) error

func (*AnyTLSInbound) NewConnection

func (h *AnyTLSInbound) NewConnection(ctx context.Context, conn net.Conn, metadata adapter.InboundContext, onClose N.CloseHandlerFunc)

func (*AnyTLSInbound) Start

func (h *AnyTLSInbound) Start(stage adapter.StartStage) error

type Hysteria2Inbound

type Hysteria2Inbound struct {
	inbound.Adapter
	// contains filtered or unexported fields
}

func (*Hysteria2Inbound) AddUsers

func (h *Hysteria2Inbound) AddUsers(users []option.Hysteria2User) error

func (*Hysteria2Inbound) Close

func (h *Hysteria2Inbound) Close() error

func (*Hysteria2Inbound) DelUsers

func (h *Hysteria2Inbound) DelUsers(names []string) error

func (*Hysteria2Inbound) NewConnectionEx

func (h *Hysteria2Inbound) NewConnectionEx(ctx context.Context, conn net.Conn, source M.Socksaddr, destination M.Socksaddr, onClose N.CloseHandlerFunc)

func (*Hysteria2Inbound) NewPacketConnectionEx

func (h *Hysteria2Inbound) NewPacketConnectionEx(ctx context.Context, conn N.PacketConn, source M.Socksaddr, destination M.Socksaddr, onClose N.CloseHandlerFunc)

func (*Hysteria2Inbound) Start

func (h *Hysteria2Inbound) Start(stage adapter.StartStage) error

type NaiveInbound

type NaiveInbound struct {
	inbound.Adapter
	// contains filtered or unexported fields
}

func (*NaiveInbound) AddUsers

func (h *NaiveInbound) AddUsers(users []auth.User) error

func (*NaiveInbound) Close

func (h *NaiveInbound) Close() error

func (*NaiveInbound) DelUsers

func (h *NaiveInbound) DelUsers(names []string) error

func (*NaiveInbound) ServeHTTP

func (h *NaiveInbound) ServeHTTP(writer http.ResponseWriter, request *http.Request)

func (*NaiveInbound) Start

func (h *NaiveInbound) Start(stage adapter.StartStage) error

type ShadowTLSInbound

type ShadowTLSInbound struct {
	inbound.Adapter
	// contains filtered or unexported fields
}

ShadowTLSInbound is a full sing-box ShadowTLS inbound with zero-downtime user management. The shadowtls.Service is recreated and swapped atomically on user changes — the listener and TLS layer never restart.

Connection-safety guarantee: existing connections are NEVER closed when users are removed. shadowtls.Service has no UpdateUsers method, so we rebuild a new service object and atomically swap the pointer. Goroutines that are mid-handshake on the OLD service continue running to completion: they hold a reference to the old service via closure, keeping it alive in the GC until all those goroutines finish. After the handshake, the routed connection is owned by the router goroutine — entirely independent of whichever service pointer h.service currently holds.

func (*ShadowTLSInbound) AddUsers

func (h *ShadowTLSInbound) AddUsers(users []option.ShadowTLSUser) error

AddUsers upserts ShadowTLS users by Name (v3 only; recreates service atomically).

func (*ShadowTLSInbound) Close

func (h *ShadowTLSInbound) Close() error

func (*ShadowTLSInbound) DelUsers

func (h *ShadowTLSInbound) DelUsers(names []string) error

DelUsers removes ShadowTLS users by Name (v3 only; recreates service atomically).

func (*ShadowTLSInbound) NewConnection

func (h *ShadowTLSInbound) NewConnection(ctx context.Context, conn net.Conn, metadata adapter.InboundContext, onClose N.CloseHandlerFunc)

func (*ShadowTLSInbound) Start

func (h *ShadowTLSInbound) Start(stage adapter.StartStage) error

type ShadowsocksInbound

type ShadowsocksInbound struct {
	inbound.Adapter
	// contains filtered or unexported fields
}

func (*ShadowsocksInbound) AddUsers

func (h *ShadowsocksInbound) AddUsers(users []option.ShadowsocksUser) error

AddUsers upserts Shadowsocks users by Name. Existing slots are updated in-place; new names get a fresh slot. Thread-safe, no restart required.

func (*ShadowsocksInbound) Close

func (h *ShadowsocksInbound) Close() error

func (*ShadowsocksInbound) DelUsers

func (h *ShadowsocksInbound) DelUsers(names []string) error

DelUsers removes users by Name. Deleted slots are zeroed but never reused, so in-flight authenticated connections can never be remapped to another user.

func (*ShadowsocksInbound) NewConnection

func (h *ShadowsocksInbound) NewConnection(ctx context.Context, conn net.Conn, metadata adapter.InboundContext, onClose N.CloseHandlerFunc)

func (*ShadowsocksInbound) NewError

func (h *ShadowsocksInbound) NewError(ctx context.Context, err error)

func (*ShadowsocksInbound) NewPacket

func (h *ShadowsocksInbound) NewPacket(buffer *buf.Buffer, source M.Socksaddr)

func (*ShadowsocksInbound) SetTracker

func (h *ShadowsocksInbound) SetTracker(tracker adapter.SSMTracker)

func (*ShadowsocksInbound) Start

func (h *ShadowsocksInbound) Start(stage adapter.StartStage) error

func (*ShadowsocksInbound) UpdateUsers

func (h *ShadowsocksInbound) UpdateUsers(users []string, uPSKs []string) error

UpdateUsers replaces the entire user list atomically and pushes the new set into the Shadowsocks service. Indices are assigned 0…N-1 in order.

type TUICInbound

type TUICInbound struct {
	inbound.Adapter
	// contains filtered or unexported fields
}

TUICInbound is a full sing-box TUIC inbound with zero-downtime user management.

func (*TUICInbound) AddUsers

func (h *TUICInbound) AddUsers(users []option.TUICUser) error

func (*TUICInbound) Close

func (h *TUICInbound) Close() error

func (*TUICInbound) DelUsers

func (h *TUICInbound) DelUsers(names []string) error

func (*TUICInbound) NewConnectionEx

func (h *TUICInbound) NewConnectionEx(ctx context.Context, conn net.Conn, source M.Socksaddr, destination M.Socksaddr, onClose N.CloseHandlerFunc)

func (*TUICInbound) NewPacketConnectionEx

func (h *TUICInbound) NewPacketConnectionEx(ctx context.Context, conn N.PacketConn, source M.Socksaddr, destination M.Socksaddr, onClose N.CloseHandlerFunc)

func (*TUICInbound) Start

func (h *TUICInbound) Start(stage adapter.StartStage) error

type TrojanInbound

type TrojanInbound struct {
	inbound.Adapter
	// contains filtered or unexported fields
}

TrojanInbound is a full sing-box Trojan inbound with zero-downtime user management.

func (*TrojanInbound) AddUsers

func (h *TrojanInbound) AddUsers(users []option.TrojanUser) error

func (*TrojanInbound) Close

func (h *TrojanInbound) Close() error

func (*TrojanInbound) DelUsers

func (h *TrojanInbound) DelUsers(names []string) error

func (*TrojanInbound) NewConnection

func (h *TrojanInbound) NewConnection(ctx context.Context, conn net.Conn, metadata adapter.InboundContext, onClose N.CloseHandlerFunc)

func (*TrojanInbound) Start

func (h *TrojanInbound) Start(stage adapter.StartStage) error

type VLESSInbound

type VLESSInbound struct {
	inbound.Adapter
	// contains filtered or unexported fields
}

VLESSInbound is a full sing-box VLESS inbound with zero-downtime user management via AddUsers / DelUsers.

Connection-safety guarantee: existing connections are NEVER closed when users are removed. Authentication (UUID lookup in service.userMap) happens exactly once per TCP connection inside Service.NewConnection. After that point the authenticated slot index is stored in ctx; the router goroutine runs entirely independently of the user table. Calling DelUsers zeroes the slot and calls service.UpdateUsers — new connections from that UUID are rejected, but in-flight connections are not touched.

func (*VLESSInbound) AddUsers

func (h *VLESSInbound) AddUsers(users []option.VLESSUser) error

AddUsers upserts VLESS users by Name. Existing slots are updated in-place; new names get a fresh slot. Thread-safe, no restart required.

func (*VLESSInbound) Close

func (h *VLESSInbound) Close() error

func (*VLESSInbound) DelUsers

func (h *VLESSInbound) DelUsers(names []string) error

DelUsers removes users by Name. Deleted slots are zeroed but never reused, so in-flight authenticated connections can never be remapped to another user.

func (*VLESSInbound) NewConnection

func (h *VLESSInbound) NewConnection(ctx context.Context, conn net.Conn, metadata adapter.InboundContext, onClose N.CloseHandlerFunc)

func (*VLESSInbound) Start

func (h *VLESSInbound) Start(stage adapter.StartStage) error

type VMessInbound

type VMessInbound struct {
	inbound.Adapter
	// contains filtered or unexported fields
}

VMessInbound is a full sing-box VMess inbound with zero-downtime user management.

func (*VMessInbound) AddUsers

func (h *VMessInbound) AddUsers(users []option.VMessUser) error

func (*VMessInbound) Close

func (h *VMessInbound) Close() error

func (*VMessInbound) DelUsers

func (h *VMessInbound) DelUsers(names []string) error

func (*VMessInbound) NewConnection

func (h *VMessInbound) NewConnection(ctx context.Context, conn net.Conn, metadata adapter.InboundContext, onClose N.CloseHandlerFunc)

func (*VMessInbound) Start

func (h *VMessInbound) Start(stage adapter.StartStage) error

Jump to

Keyboard shortcuts

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