smallprox

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2019 License: MPL-2.0 Imports: 39 Imported by: 0

README

smallprox

Smallprox is small HTTP proxy with features such as HTTPS MITM and content manipulation, written in Go.

Usage

Usage of smallprox:
  -addr value
    	Proxy listen address(es)
  -auth string
    	Proxy authentication, username:password
  -blockHostsFile value
    	Block the hosts found in this file(s), one per line or in /etc/hosts format
  -cacert string
    	CA certificate file for HTTPS MITM
  -cakey string
    	CA private key file for HTTPS MITM
  -compress
    	Compress highly compressable content * (default true)
  -connectMITM
    	Enable man-in-the-middle for HTTP CONNECT connections (default true)
  -httpsMITM
    	Enable man-in-the-middle for HTTPS CONNECT connections
  -insecure
    	TLS config InsecureSkipVerify
  -limitContent value
    	Limit content to minimize excessive memory usage * (default 100MiB)
  -noscript
    	Remove JavaScript from HTML content *
  -shrinkImages
    	Make images/pictures smaller *
  -v	Verbose output
* only applies to CONNECT if MITM enabled

Docker

docker build --tag millerlogic/smallprox .

docker run --rm -it -p 127.0.0.1:8080:8080 --user=nobody:nobody --init millerlogic/smallprox

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TypeFilterFonts = []string{
	"application/x-font-ttf",
	"application/x-font-truetype",
	"application/x-font-opentype",
	"application/font-woff",
	"application/font-woff2",
	"application/vnd.ms-fontobject",
	"application/font-sfnt",
	"font/woff2",
	"font/opentype",

	"fon",
	"woff",
	"woff2",
	"otf",
	"ttf",
	"eot",
}

Functions

func ContainsHost

func ContainsHost(hosts []string, host string) bool

ContainsHost returns true if host is found in hosts.

func HasAnyFold

func HasAnyFold(all []string, s string) bool

func HasAnyHeaderValuePart

func HasAnyHeaderValuePart(from []string, value string) bool

func HasHeaderValuePart

func HasHeaderValuePart(x string, value string) bool

func LoadHosts

func LoadHosts(f io.Reader) ([]string, error)

LoadHosts loads one host per line or in /etc/hosts format.

func LoadHostsFile

func LoadHostsFile(path string) ([]string, error)

LoadHostsFile loads hosts from the file, see LoadHosts

Types

type CompressResponder

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

func (*CompressResponder) Enabled

func (t *CompressResponder) Enabled() bool

func (*CompressResponder) Response

func (er *CompressResponder) Response(req *http.Request, resp *http.Response) *http.Response

func (*CompressResponder) SetEnabled

func (t *CompressResponder) SetEnabled(enabled bool)

type CounterEncryptorRand

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

func NewCounterEncryptorRandFromKey

func NewCounterEncryptorRandFromKey(key interface{}, seed []byte) (r CounterEncryptorRand, err error)

func (*CounterEncryptorRand) Read

func (c *CounterEncryptorRand) Read(b []byte) (n int, err error)

func (*CounterEncryptorRand) Seed

func (c *CounterEncryptorRand) Seed(b []byte)

type ImageShrinkResponder

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

func (*ImageShrinkResponder) Enabled

func (t *ImageShrinkResponder) Enabled() bool

func (*ImageShrinkResponder) Response

func (er *ImageShrinkResponder) Response(req *http.Request, resp *http.Response) *http.Response

func (*ImageShrinkResponder) SetEnabled

func (t *ImageShrinkResponder) SetEnabled(enabled bool)

type LimitBytesResponder

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

func (*LimitBytesResponder) Limit

func (er *LimitBytesResponder) Limit() int64

func (*LimitBytesResponder) Response

func (er *LimitBytesResponder) Response(req *http.Request, resp *http.Response) *http.Response

func (*LimitBytesResponder) SetLimit

func (er *LimitBytesResponder) SetLimit(limitBytes int64)

type Mutable

type Mutable struct {
	bytes.Buffer
}

Mutable is a buffer which may be directly mutated.

func (*Mutable) Close

func (m *Mutable) Close() error

Close implements io.Closer

func (*Mutable) Peek added in v1.1.0

func (m *Mutable) Peek(n int) ([]byte, error)

type NoscriptResponder

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

func (*NoscriptResponder) Enabled

func (t *NoscriptResponder) Enabled() bool

func (*NoscriptResponder) Response

func (er *NoscriptResponder) Response(req *http.Request, resp *http.Response) *http.Response

func (*NoscriptResponder) SetEnabled

func (t *NoscriptResponder) SetEnabled(enabled bool)

type Options

type Options struct {
	Verbose            bool
	Addresses          []string
	InsecureSkipVerify bool
	BlockHosts         []string // list of hosts
	ConnectMITM        bool
	HTTPSMITM          bool
	CA                 tls.Certificate // Do not modify the pointers/arrays!
	Auth               string
}

Options includes the proxy options.

func (*Options) Copy

func (opts *Options) Copy() Options

Copy performs a readonly copy.

type Proxy

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

Proxy is the proxy.

func NewProxy

func NewProxy(opts Options) *Proxy

NewProxy creates a new proxy.

func (*Proxy) AddRequester

func (proxy *Proxy) AddRequester(req Requester)

func (*Proxy) AddResponder

func (proxy *Proxy) AddResponder(resp Responder)

func (*Proxy) Close added in v1.1.0

func (proxy *Proxy) Close() error

func (*Proxy) GetOptions

func (proxy *Proxy) GetOptions() Options

GetOptions gets the current options,

func (*Proxy) IsHostBlocked

func (proxy *Proxy) IsHostBlocked(host string) bool

func (*Proxy) ListenAndServe

func (proxy *Proxy) ListenAndServe() error

func (*Proxy) ListenAndServeContext

func (proxy *Proxy) ListenAndServeContext(ctx context.Context) error

func (*Proxy) ServeHTTP

func (proxy *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Proxy) SetOptions

func (proxy *Proxy) SetOptions(opts Options)

func (*Proxy) Shutdown

func (proxy *Proxy) Shutdown(ctx context.Context) error

type Requester

type Requester interface {
	Request(req *http.Request) (*http.Request, *http.Response)
}

Requester allows handling a request. Return a non-nil response to finish the request early. Use req.Context()

type Responder

type Responder interface {
	Response(req *http.Request, resp *http.Response) *http.Response
}

Responder allows handling a response. Use req.Context()

type TypeFilterResponder added in v1.1.0

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

func (*TypeFilterResponder) Block added in v1.1.0

func (er *TypeFilterResponder) Block(blocks ...string)

Block a file; a block is either a file extension (without preceeding dot), or a MIME type (with a slash).

func (*TypeFilterResponder) Enabled added in v1.1.0

func (t *TypeFilterResponder) Enabled() bool

func (*TypeFilterResponder) Response added in v1.1.0

func (er *TypeFilterResponder) Response(req *http.Request, resp *http.Response) *http.Response

func (*TypeFilterResponder) SetEnabled added in v1.1.0

func (t *TypeFilterResponder) SetEnabled(enabled bool)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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