fakeproxy

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package fakeproxy is a fake HTTP proxy (CONNECT tunnels and requests in absolute form, optionally over TLS) and a fake SOCKS5 proxy (CONNECT, optionally with username and password authentication), for the tests of the outbound package and for `muster dev`. Both record every target they connect to, and resolve the names in their Hosts first, so that a test can name a target only the proxy can resolve. Both also answer GET /_fake/requests on their own port with the connections they made, so that a live check can see what went through them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	Target    string `json:"target"`
	LocalAddr string `json:"local_addr"`
}

Connection is a connection the proxy made: the target as the client asked for it, and the local address of the proxy's connection to it, which is the remote address the target sees.

type Kind

type Kind string

Kind is the protocol a fake proxy speaks.

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

type Options

type Options struct {
	// Username and Password, when set, are required: Proxy-Authorization Basic for HTTP, RFC 1929 for SOCKS5.
	Username, Password string
	// Hosts maps names that only the proxy resolves to the host:port it connects to instead.
	Hosts map[string]string
	// TLS, when set, makes an HTTP proxy serve TLS, as an https proxy.
	TLS *tls.Config
}

Options configure a fake proxy.

type Server

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

Server is a running fake proxy.

func Start

func Start(ctx context.Context, kind Kind, addr string, opts Options) (*Server, error)

Start starts a fake proxy of kind on addr, such as 127.0.0.1:0; it runs until Close or the end of ctx.

func (*Server) Addr

func (s *Server) Addr() string

Addr is the host:port the proxy listens on.

func (*Server) Close

func (s *Server) Close() error

Close stops the proxy, closes its connections and waits for them to end.

func (*Server) Connections

func (s *Server) Connections() []Connection

Connections lists the connections the proxy made, oldest first.

func (*Server) Refused

func (s *Server) Refused() int

Refused counts the requests the proxy refused for missing or wrong credentials.

func (*Server) Targets

func (s *Server) Targets() []string

Targets lists the targets the proxy connected to, oldest first.

Jump to

Keyboard shortcuts

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