mieru

package
v0.1.7 Latest Latest
Warning

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

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

Documentation

Overview

Package mieru provides Sing2's Mieru inbound — a drop-in replacement for the base fork's, adding the hot user updates the base cannot do (doc/13 T6). See inbound.go for why it exists.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewInbound

func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.MieruInboundOptions) (adapter.Inbound, error)

func RegisterInbound

func RegisterInbound(registry *inbound.Registry)

RegisterInbound installs Sing2's Mieru inbound, replacing whatever is already registered for C.TypeMieru. Call it on the registry AFTER include.InboundRegistry().

Types

type AuthStats added in v0.0.4

type AuthStats struct {
	// Direct is the cheap path: an established session whose cipher is already
	// bound to a user. No search involved.
	Direct       int64
	FailedDirect int64

	// HintMatch counts decrypt attempts against users the nonce hint narrowed
	// down to — normally exactly one. Failed ones are hint collisions (the hint
	// is 4 bytes) or junk that happened to collide.
	HintMatch       int64
	FailedHintMatch int64

	// Iterate counts full try-every-user sweeps. THIS is the expensive path.
	// FailedIterate is the subset that matched nobody, i.e. pure waste — the
	// clearest signal that a node is being made to burn CPU on traffic that
	// could never authenticate.
	Iterate       int64
	FailedIterate int64
}

AuthStats is a snapshot of mieru's server-side decryption counters.

func ReadAuthStats added in v0.0.4

func ReadAuthStats() AuthStats

ReadAuthStats snapshots the counters. Cheap — six atomic loads.

func (AuthStats) IsZero added in v0.0.4

func (s AuthStats) IsZero() bool

IsZero reports whether nothing at all happened in this window.

func (AuthStats) Sub added in v0.0.4

func (s AuthStats) Sub(prev AuthStats) AuthStats

Sub returns s minus prev, for turning cumulative counters into a rate.

func (AuthStats) Total added in v0.0.4

func (s AuthStats) Total() int64

Total returns the number of user-level decrypt attempts represented, which is what actually correlates with CPU.

type Inbound

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

Inbound is a Mieru server inbound backed directly by mieru's protocol.Mux.

func (*Inbound) Close

func (h *Inbound) Close() error

func (*Inbound) Start

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

func (*Inbound) UpdateUsers

func (h *Inbound) UpdateUsers(users []option.MieruUser) error

UpdateUsers replaces the authoritative user set on the RUNNING server.

This is the whole point of the package: established connections keep working (mieru leaves existing TCPUnderlays and Sessions alone), new handshakes immediately see the new set, and removed users can no longer authenticate. Before Start it just records the set, which Start then installs.

It is also where a node that started with zero users finally comes up — see the deferred-start comment in Start.

Jump to

Keyboard shortcuts

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