proxy

package
v0.0.0-...-37a43e1 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: LGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MemoryStorage describes in-memory data storage.
	MemoryStorage = ":memory:"
)
View Source
const SO_ORIGINAL_DST = 0x50

SO_ORIGINAL_DST get the original destination for the socket when redirect by linux iptables refer to https://raw.githubusercontent.com/missdeer/avege/master/src/inbound/redir/redir_iptables.go

Variables

View Source
var DialerDirect = netproxy.Direct

DialerDirect is a direct proxy: one that makes network connections directly, good for testing

Functions

func NewDialerHTTPConnect

func NewDialerHTTPConnect(forwardDialer netproxy.Dialer, forwardUrl *url.URL, user, pass, country string) *dialerHTTPConnect

NewDialerHTTPConnect returns a new Dialer that dials through the provided proxy server's network and address.

func NewDomainTracer

func NewDomainTracer() *domainTracer

NewDomainTracer creates new domain tracer instace.

func NewNoopTracer

func NewNoopTracer() *noopTracer

NewNoopTracer creates new noop domain tracer instace.

func NewServer

func NewServer(
	allowedSubnets []*net.IPNet,
	allowedIPs []net.IP,
	upstreamDialer netproxy.Dialer,
	mapper StickyMapper,
	dt domainTracker,
	portMap map[string]string,
	handlerMiddleware handlerMiddleware,
) *proxyServer

NewServer returns new instance of HTTP transparent proxy server

func NewStickyMapper

func NewStickyMapper(path string) (*stickyMapper, error)

NewStickyMapper creates database for storing IP to UserID mapping.

Types

type Conn

type Conn struct {
	net.Conn

	Context *Context
}

Conn wraps net.Conn with intercepts of read/write events.

func NewConn

func NewConn(conn net.Conn, context *Context) *Conn

NewConn returns net.Conn wrapped with metrics.

func (Conn) Read

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

Read bytes from net.Conn and count read bytes

func (Conn) Write

func (c Conn) Write(b []byte) (n int, err error)

Write bytes to net.Conn and counts written bytes

type Connection

type Connection struct {
	net.Conn
	// contains filtered or unexported fields
}

Connection wraps net.Conn to provide extra method for establishing CONNECT session.

func (*Connection) ConnectTo

func (c *Connection) ConnectTo(conn io.ReadWriter, address string, userID string) error

ConnectTo establishes new CONNECT session within existing connection. It allows to pass UserID to enable sticky sessions.

type Context

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

Context is the Proxy context, contains useful information about every request.

func (*Context) Hostname

func (c *Context) Hostname() string

Hostname returns hostname.

func (*Context) RequestType

func (c *Context) RequestType() string

RequestType HTTP or HTTPS.

func (*Context) WaitHostname

func (c *Context) WaitHostname() string

WaitHostname waits for hostname to be set and returns it.

type StickyMapper

type StickyMapper interface {
	Save(ip, userID string)
	Hash(ip string) (hash string)
}

StickyMapper represent connection stickiness storage.

Jump to

Keyboard shortcuts

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