Documentation
¶
Overview ¶
Verbatim copy of sing-box protocol/tuic/inbound.go, moved into this module so the panel can reach the unexported `service`/`users` fields that the sing-box Inbound type does not expose. That access is what lets core.UpdateInboundUsers swap an inbound's user table in place instead of tearing the listener down (see core/inbound_users.go).
UPGRADING sing-box: re-copy this file from the new tag and re-apply the changes below. Nothing here will fail to compile if you forget, it will just silently keep running the old implementation.
Local change vs sing-box: the service is keyed by user name (Service[string]) instead of by list position (Service[int]). sing-box never rewrites a user list in place, so a position is a stable identity there; UpdateUsers does rewrite it, under live sessions, and a position is not. Deleting a user shifted every later one, which mis-attributed traffic and could index past the end of the name slice outright (upstream #1231).
Second local change: one line installs the user-session registry
inbound.router = withUserSessions(inbound.router)
which is what lets an already authenticated session be reached when its user is removed from the inbound -- swapping the user table alone only decides who may start a new one. That line is the whole of it here; everything it reaches lives in users.go, which the copy check skips. See core/usersession.
Index ¶
- func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLogger, ...) (adapter.Inbound, error)
- func RegisterInbound(registry *inbound.Registry)
- type Inbound
- func (h *Inbound) KickUser(user string) usersession.Result
- func (h *Inbound) NewConnectionEx(ctx context.Context, conn net.Conn, source M.Socksaddr, ...)
- func (h *Inbound) NewPacketConnectionEx(ctx context.Context, conn N.PacketConn, source M.Socksaddr, ...)
- func (h *Inbound) Start(stage adapter.StartStage, scope *adapter.Scope) error
- func (h *Inbound) UpdateUsers(users []option.TUICUser) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewInbound ¶
func RegisterInbound ¶
Types ¶
type Inbound ¶
func (*Inbound) KickUser ¶ added in v1.9.0
func (h *Inbound) KickUser(user string) usersession.Result
KickUser cuts the sessions of a user who stays on the inbound -- see Core.DisconnectUser.
func (*Inbound) NewConnectionEx ¶
func (*Inbound) NewPacketConnectionEx ¶
func (*Inbound) UpdateUsers ¶
UpdateUsers swaps the user table of a running inbound and disconnects everyone who just left it. Both halves are needed: the table alone only decides who may open a new session, while a client that authenticated before the change keeps opening streams on the one it already has.
The second half is not something this layer can do to a QUIC session, so when a removed user is still connected it reports ErrRestartRequired and the caller rebuilds the inbound instead. That disconnects everyone on it once, which is why it is reported rather than done unconditionally: an update that removes nobody, or removes nobody who is connected, still costs nothing.