localproxy

package
v1.3.9 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package localproxy runs a built-in proxy on the tunnel's exit side, so a node can be its own backend: instead of forwarding to a separate service (xray, a panel, …) that has to be installed and kept running, the tunnel forwards to a proxy this binary serves itself.

It is optional and off by default. The operator picks the port — nothing is assumed — and maps a forwarded port to 127.0.0.1:<that port> like any other backend, so the tunnel engine is untouched.

Index

Constants

This section is empty.

Variables

Dir is where the config lives; a variable so tests can point it elsewhere.

Functions

func Run

func Run(ctx context.Context)

Run serves the configured proxy until ctx is cancelled. It is a no-op when the proxy is disabled or has no port, so the service can run unconditionally.

func Save

func Save(c Config) error

Save persists the config (0600 — it may hold a password).

Types

type Config

type Config struct {
	Enabled bool `json:"enabled"`
	// Type is "socks5" or "http".
	Type Kind `json:"type"`
	// Port is chosen by the operator; there is no default, so nothing starts
	// listening on a well-known port by surprise.
	Port int `json:"port"`
	// Username/Password gate the proxy. Empty means no authentication, which is
	// safe here: the proxy binds loopback and is only reachable through the
	// token-authenticated tunnel.
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
}

Config is the persisted built-in-proxy configuration.

func Load

func Load() Config

Load reads the config, returning a disabled zero value if none exists.

func (Config) Addr

func (c Config) Addr() string

Addr is the loopback address the proxy listens on. Loopback only: the proxy is meant to be reached through the tunnel, never from the open internet.

type Kind

type Kind string

Kind is which proxy protocol to serve on the port.

const (
	SOCKS5 Kind = "socks5"
	HTTP   Kind = "http"
)

Jump to

Keyboard shortcuts

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