netproxy

package
v0.0.0-...-7ca97a9 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDialTimeout   = 2 * time.Second
	DefaultSocketTimeout = 3 * time.Minute
)
View Source
const (
	HttpProxyAddr = "127.0.0.1:9118"
)
View Source
const (
	Socks5ProxyAddr = "127.0.0.1:9119"
)

Variables

View Source
var (
	NETPROXY_ENABLED = os.Getenv("NETPROXY_ENABLED") == "true"
	HttpProxyURL, _  = url.Parse(fmt.Sprintf("http://%s", HttpProxyAddr))
)
View Source
var (
	Socks5ProxyURL, _ = url.Parse(fmt.Sprintf("socks5://%s", Socks5ProxyAddr))
)

Functions

func AddHttpProxyHandler

func AddHttpProxyHandler(handler HttpHandler)

func AddTcpProxyHandler

func AddTcpProxyHandler(handler TcpHandler)

func CreateServerInternalErrorResp

func CreateServerInternalErrorResp(req *http.Request, extra string) *http.Response

func HandleHttpProxy

func HandleHttpProxy(req *http.Request, ctx *goproxy.ProxyCtx) (*http.Request, *http.Response)

func HandleHttpProxyByExec

func HandleHttpProxyByExec(pod *cri.Pod, req *http.Request, ctx *goproxy.ProxyCtx) (*http.Request, *http.Response)

func HandleHttpProxyByNsenter

func HandleHttpProxyByNsenter(pod *cri.Pod, req *http.Request, forceIp string) (*http.Request, *http.Response)

func TcpProxy

func TcpProxy(ctx context.Context, i cri.Interface, c *cri.Container, addr string, dialTimeout time.Duration) (net.Conn, error)

Types

type CriHandle

type CriHandle struct {
	Cri cri.Interface
	// contains filtered or unexported fields
}

CriHandle implements socks5.Handler interface

func (*CriHandle) Init

func (h *CriHandle) Init()

func (*CriHandle) TCPHandle

func (h *CriHandle) TCPHandle(s *socks5.Server, c *net.TCPConn, r *socks5.Request) error

TCPHandle handle tcp socks5 proxy request.

func (*CriHandle) UDPHandle

func (h *CriHandle) UDPHandle(s *socks5.Server, addr *net.UDPAddr, d *socks5.Datagram) error

UDPHandle auto handle packet. You may prefer to do yourself.

type HttpHandler

type HttpHandler func(ctx context.Context, pod *cri.Pod, req *http.Request) (*http.Request, *http.Response, error)

type PortForwardTask

type PortForwardTask struct {
	Addr string
}

func (*PortForwardTask) Start

func (t *PortForwardTask) Start(ctx context.Context) (string, error)

type TcpHandler

type TcpHandler func(ctx context.Context, i cri.Interface, c *cri.Container, addr string, dialTimeout time.Duration) (net.Conn, error)

Jump to

Keyboard shortcuts

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