apis

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: GPL-2.0 Imports: 6 Imported by: 0

README

Sudoku raw-stream API

apis exposes only the Sudoku appearance codec. It wraps an existing net.Conn so callers read and write original bytes while the wire stream is encoded as Sudoku traffic.

It does not provide HTTPMask, encryption, handshakes, UoT, or reverse proxy APIs.

cfg := apis.DefaultConfig()
cfg.Key = "same-client-server-uuid"
cfg.ASCII = "prefer_entropy"
cfg.EnablePureDownlink = false // default: packed server-to-client traffic

rawClient, _ := net.Dial("tcp", serverAddr)
conn, _ := apis.ClientConn(rawClient, cfg)

On the accepting side:

conn, _ := apis.ServerConn(rawAcceptedConn, cfg)

For mux, wrap the base connection first and then start the mux session:

mux, _ := apis.NewMuxClient(conn)
stream, _ := mux.Dial("example.com:443")

The server side can use apis.HandleMuxServer or apis.HandleMuxWithDialer on the matching wrapped connection.

Documentation

Overview

Package apis exposes the Sudoku appearance codec as a small raw-stream API.

The returned connections read and write the caller's original bytes while the underlying wire stream is encoded with the Sudoku byte layout. This package intentionally does not provide HTTP masking, encryption, handshakes, UoT, or reverse proxy helpers.

Index

Constants

View Source
const (
	// DefaultKey is a deterministic shared key for the appearance table.
	// Override it when the client and server should use a private table.
	DefaultKey = "2d8f2c94-3fd0-4a57-8d18-61f33aee2c44"

	// DefaultASCII is the default Sudoku byte layout preference.
	DefaultASCII = "prefer_entropy"
)

Variables

This section is empty.

Functions

func BuildTables added in v0.4.8

func BuildTables(cfg *Config) ([]*sudoku.Table, error)

BuildTables builds every configured table candidate.

func ClientConn added in v0.4.8

func ClientConn(raw net.Conn, cfg *Config) (net.Conn, error)

ClientConn wraps the client side of a raw connection.

func HandleMuxServer

func HandleMuxServer(conn net.Conn, onConnect func(targetAddr string)) error

HandleMuxServer runs a target-address mux server over an already-wrapped raw Sudoku appearance connection.

func HandleMuxWithDialer

func HandleMuxWithDialer(conn net.Conn, onConnect func(targetAddr string), dialTarget func(targetAddr string) (net.Conn, error)) error

HandleMuxWithDialer is like HandleMuxServer but lets the caller control how target addresses are opened.

func ServerConn added in v0.4.8

func ServerConn(raw net.Conn, cfg *Config) (net.Conn, error)

ServerConn wraps the server side of a raw connection.

func WrapConn added in v0.4.8

func WrapConn(raw net.Conn, cfg *Config, side Side) (net.Conn, error)

WrapConn returns a net.Conn that exposes original bytes to the caller and encodes/decodes the underlying wire stream with the Sudoku appearance layer.

Types

type Config added in v0.4.8

type Config struct {
	// Key seeds the Sudoku table. Both sides must use the same key.
	Key string

	// ASCII selects the byte layout: "prefer_entropy", "prefer_ascii", or a
	// directional value such as "up_ascii_down_entropy".
	ASCII string

	// CustomTables contains optional X/P/V byte-layout patterns.
	// With no handshake in this raw codec API, both sides must use the same TableIndex.
	CustomTables []string

	// TableIndex selects which configured table to use. The default table is index 0.
	TableIndex int

	// EnablePureDownlink keeps server-to-client traffic in classic Sudoku mode.
	// The default is false, which uses packed downlink.
	EnablePureDownlink bool

	// PaddingMin and PaddingMax are optional padding probabilities in percent.
	PaddingMin int
	PaddingMax int
}

Config describes only the Sudoku appearance layer.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default raw Sudoku appearance config.

func Normalize added in v0.4.8

func Normalize(cfg *Config) (Config, error)

Normalize returns a copy of cfg with defaults and canonical mode names applied.

func (*Config) BuildTables added in v0.4.8

func (c *Config) BuildTables() ([]*sudoku.Table, error)

BuildTables builds every configured table candidate.

func (*Config) Validate added in v0.4.8

func (c *Config) Validate() error

Validate checks the normalized config and custom table patterns.

type MuxClient

type MuxClient struct {
	// contains filtered or unexported fields
}

MuxClient opens multiple logical target streams over one already-wrapped raw Sudoku appearance connection. It has no HTTPMask dependency.

func NewMuxClient

func NewMuxClient(conn net.Conn) (*MuxClient, error)

NewMuxClient starts a mux session over conn.

func (*MuxClient) Close

func (c *MuxClient) Close() error

Close closes the mux session and its underlying connection.

func (*MuxClient) Dial

func (c *MuxClient) Dial(targetAddr string) (net.Conn, error)

Dial opens a logical stream to targetAddr.

func (*MuxClient) Done added in v0.4.8

func (c *MuxClient) Done() <-chan struct{}

Done is closed when the mux session ends.

func (*MuxClient) Err added in v0.4.8

func (c *MuxClient) Err() error

Err returns the terminal mux session error after Done closes.

type Side added in v0.4.8

type Side string

Side selects which traffic direction a wrapped connection should use.

const (
	// ClientSide writes uplink with the selected table and reads downlink with the opposite table.
	ClientSide Side = "client"
	// ServerSide reads uplink with the selected table and writes downlink with the opposite table.
	ServerSide Side = "server"
)

Jump to

Keyboard shortcuts

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