miniweb

package
v0.0.0-...-895c899 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2021 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownBrowserKind = fmt.Errorf("supported browser kinds are: 'chromium'")

ErrUnknownBrowserKind indicates use of an unknown/unsupported browser family name

Functions

func ListenAndServe

func ListenAndServe(config ServerConfig) error

ListenAndServe creates/runs a miniweb server until an error interrupts it

Types

type Browser

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

Browser is a launch structure for viewing proxied miniweb resource in a Web browser

func NewBrowser

func NewBrowser(kind, exe string, socksPort int) Browser

NewBrowser constructs a Browser for a given kind/exe path and with a given SOCKS5 port on localhost

func (*Browser) Arg

func (b *Browser) Arg(arg ...string)

Arg appends a CLI argument to the list of extra arguments passed after the proxy settings and before the URL

func (*Browser) Launch

func (b *Browser) Launch(url string) error

Launch launches the given browser with the given SOCKS5 proxy, opening the given URL as the initial document

type Server

type Server struct {
	// Public information
	Config ServerConfig // Config is the initial configuration (ports, paths) used to initialize the server
	// contains filtered or unexported fields
}

Server encapsulates the inner state of a running miniweb server (ports, filesystem root, configurations, caches, etc.)

func (*Server) GetCert

func (ws *Server) GetCert(info *tls.ClientHelloInfo) (*tls.Certificate, error)

GetCert retrieves the TLS cert to use for a particular DNS name from the miniweb file tree/configuration

func (*Server) Resolve

func (ws *Server) Resolve(ctx context.Context, name string) (context.Context, net.IP, error)

Resolve a DNS name against the miniweb file tree

func (*Server) Rewrite

func (ws *Server) Rewrite(ctx context.Context, request *socks.Request) (context.Context, *socks.AddrSpec)

Rewrite an HTTP[S] request coming through SOCKS to target our local HTTP[S] server (or to a custom server, if a socks-rewriter is configured)

func (*Server) ServeHTTP

func (ws *Server) ServeHTTP(writer http.ResponseWriter, req *http.Request)

ServeHTTP responses from the miniweb file tree and/or configuration settings

type ServerConfig

type ServerConfig struct {
	HTTPPort   int    // HTTPPort is the TCP port (on localhost, exclusively) from which we will serve redirected HTTP requests
	HTTPSPort  int    // HTTPSPort is like HTTPPort but for redirected TLS connections
	SOCKS5Addr string // SOCKS5Port is the TCP endpoint at which we will accept SOCKS5 requests to resolve/redirect DNS names and HTTP[S] requests
	DataRoot   string // Full path to miniweb data store (top level directory names == DNS names, contents == HTTP[S] document root tree)
}

ServerConfig defines the operating parameters of a miniweb server: TCP ports to bind and filesystem root

Jump to

Keyboard shortcuts

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