socketproxy

package
v1.10.8 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Copyright 2022 gdy, 272288813@qq.com

Copyright 2022 gdy, 272288813@qq.com

Copyright 2022 gdy, 272288813@qq.com

Copyright 2022 gdy, 272288813@qq.com

Copyright 2022 gdy, 272288813@qq.com

Index

Constants

View Source
const DEFAULT_GLOBAL_MAX_CONNECTIONS = int64(1024)
View Source
const DEFAULT_GLOBAL_UDPReadTargetDataMaxgoroutineCount = int64(1024)
View Source
const DEFAULT_MAX_PORTFORWARDS_LIMIT = int64(128)
View Source
const TCPUDP_DEFAULT_SINGLE_PROXY_MAX_CONNECTIONS = int64(256)
View Source
const TCP_DEFAULT_STREAM_BUFFERSIZE = 128
View Source
const UDP_DEFAULT_PACKAGE_SIZE = 1500

Variables

This section is empty.

Functions

func GetGlobalMaxPortForwardsCountLimit added in v1.5.1

func GetGlobalMaxPortForwardsCountLimit() int64

func GetGlobalTCPPortForwardConnections added in v1.5.1

func GetGlobalTCPPortForwardConnections() int64

func GetGlobalTCPPortforwardMaxConnections added in v1.5.1

func GetGlobalTCPPortforwardMaxConnections() int64

func GetGlobalUDPPortForwardGroutineCount added in v1.5.1

func GetGlobalUDPPortForwardGroutineCount() int64

func GetGlobalUDPReadTargetDataMaxgoroutineCountLimit added in v1.5.1

func GetGlobalUDPReadTargetDataMaxgoroutineCountLimit() int64

func GetProxyKey

func GetProxyKey(proxyType, listenIP string, listenPort int) string

func GloBalTCPPortForwardConnectionsAdd added in v1.5.1

func GloBalTCPPortForwardConnectionsAdd(add int64) int64

func GloBalUDPPortForwardGroutineCountAdd added in v1.5.1

func GloBalUDPPortForwardGroutineCountAdd(add int64) int64

func SetGlobalMaxPortForwardsCountLimit added in v1.5.1

func SetGlobalMaxPortForwardsCountLimit(max int64)

func SetGlobalTCPPortforwardMaxConnections added in v1.5.1

func SetGlobalTCPPortforwardMaxConnections(max int64)

func SetGlobalUDPReadTargetDataMaxgoroutineCountLimit added in v1.5.1

func SetGlobalUDPReadTargetDataMaxgoroutineCountLimit(max int64)

func SetSafeCheck

func SetSafeCheck(f func(mode, ip string) bool)

Types

type BaseProxyConf

type BaseProxyConf struct {
	TrafficIn  int64
	TrafficOut int64

	ProxyType string // tcp tcp4 tcp6 udp udp4 udp6
	// contains filtered or unexported fields
}

func (*BaseProxyConf) CopyBuffer

func (p *BaseProxyConf) CopyBuffer(dst io.Writer, src io.Reader, buf []byte, writedataCallback func(int64)) (written int64, err error)

func (*BaseProxyConf) GetProxyType

func (p *BaseProxyConf) GetProxyType() string

func (*BaseProxyConf) GetStatus

func (p *BaseProxyConf) GetStatus() string

func (*BaseProxyConf) GetTrafficIn

func (p *BaseProxyConf) GetTrafficIn() int64

func (*BaseProxyConf) GetTrafficOut

func (p *BaseProxyConf) GetTrafficOut() int64

func (*BaseProxyConf) ReceiveDataCallback

func (p *BaseProxyConf) ReceiveDataCallback(nw int64)

func (*BaseProxyConf) SendDataCallback

func (p *BaseProxyConf) SendDataCallback(nw int64)

type Proxy

type Proxy interface {
	StartProxy()
	StopProxy()

	ReceiveDataCallback(int64)
	SendDataCallback(int64)
	GetProxyType() string
	GetStatus() string
	GetListenIP() string
	GetListenPort() int
	GetKey() string
	GetCurrentConnections() int64

	String() string
	GetTrafficIn() int64
	GetTrafficOut() int64
	SafeCheck(ip string) bool
}

func CreateProxy

func CreateProxy(log *logrus.Logger, proxyType, listenIP string, targetAddressList []string, listenPort, targetPort int, options *RelayRuleOptions) (p Proxy, err error)

type RelayRuleOptions

type RelayRuleOptions struct {
	UDPPackageSize                                int    `json:"UDPPackageSize,omitempty"`
	SingleProxyMaxTCPConnections                  int64  `json:"SingleProxyMaxTCPConnections,omitempty"`
	SingleProxyMaxUDPReadTargetDatagoroutineCount int64  `json:"SingleProxyMaxUDPReadTargetDatagoroutineCount"`
	UDPProxyPerformanceMode                       bool   `json:"UDPProxyPerformanceMode,omitempty"`
	UDPShortMode                                  bool   `json:"UDPShortMode,omitempty"`
	SafeMode                                      string `json:"SafeMode,omitempty"`
}

type TCPProxy

type TCPProxy struct {
	TCPUDPProxyCommonConf
	// contains filtered or unexported fields
}

func CreateTCPProxy

func CreateTCPProxy(log *logrus.Logger, proxyType, listenIP string, targetAddressList []string, listenPort, targetPort int, options *RelayRuleOptions) *TCPProxy

func (*TCPProxy) CheckConnectionsLimit added in v1.5.1

func (p *TCPProxy) CheckConnectionsLimit() error

func (*TCPProxy) GetStatus

func (p *TCPProxy) GetStatus() string

func (*TCPProxy) StartProxy

func (p *TCPProxy) StartProxy()

func (*TCPProxy) StopProxy

func (p *TCPProxy) StopProxy()

type TCPUDPProxyCommonConf

type TCPUDPProxyCommonConf struct {
	CurrentConnectionsCount   int64
	SingleProxyMaxConnections int64

	BaseProxyConf
	// contains filtered or unexported fields
}

func (*TCPUDPProxyCommonConf) AddCurrentConnections

func (p *TCPUDPProxyCommonConf) AddCurrentConnections(a int64)

func (*TCPUDPProxyCommonConf) GetCurrentConnections

func (p *TCPUDPProxyCommonConf) GetCurrentConnections() int64

func (*TCPUDPProxyCommonConf) GetKey

func (p *TCPUDPProxyCommonConf) GetKey() string

func (*TCPUDPProxyCommonConf) GetListenIP

func (p *TCPUDPProxyCommonConf) GetListenIP() string

func (*TCPUDPProxyCommonConf) GetListenPort

func (p *TCPUDPProxyCommonConf) GetListenPort() int

func (*TCPUDPProxyCommonConf) GetListentAddress

func (p *TCPUDPProxyCommonConf) GetListentAddress() string

func (*TCPUDPProxyCommonConf) GetTargetAddress

func (p *TCPUDPProxyCommonConf) GetTargetAddress() string

func (*TCPUDPProxyCommonConf) SafeCheck

func (p *TCPUDPProxyCommonConf) SafeCheck(remodeAddr string) bool

func (*TCPUDPProxyCommonConf) SetMaxConnections

func (p *TCPUDPProxyCommonConf) SetMaxConnections(max int64)

func (*TCPUDPProxyCommonConf) String

func (p *TCPUDPProxyCommonConf) String() string

type UDPProxy

type UDPProxy struct {
	//BaseProxyConf
	TCPUDPProxyCommonConf

	Upm       bool //性能模式
	ShortMode bool

	SingleProxyMaxUDPReadTargetDatagoroutineCount int64
	// contains filtered or unexported fields
}

func CreateUDPProxy

func CreateUDPProxy(log *logrus.Logger, proxyType, listenIP string, targetAddressList []string, listenPort, targetPort int, options *RelayRuleOptions) *UDPProxy

func (*UDPProxy) CheckReadTargetDataGoroutineLimit added in v1.5.1

func (p *UDPProxy) CheckReadTargetDataGoroutineLimit() error

func (*UDPProxy) CheckTargetUDPConnectSessions added in v1.5.1

func (p *UDPProxy) CheckTargetUDPConnectSessions()

func (*UDPProxy) Forwarder

func (p *UDPProxy) Forwarder(kk int, replych chan *udpPackge)

func (*UDPProxy) GetUDPPacketSize

func (p *UDPProxy) GetUDPPacketSize() int

func (*UDPProxy) ListenHandler added in v1.5.1

func (p *UDPProxy) ListenHandler(ln *net.UDPConn)

func (*UDPProxy) ReadFromTargetOnce

func (p *UDPProxy) ReadFromTargetOnce() bool

ReadFromTargetOnce one clientAddr only read once,short mode eg: udp dns

func (*UDPProxy) SetUDPPacketSize

func (p *UDPProxy) SetUDPPacketSize(size int)

func (*UDPProxy) StartProxy

func (p *UDPProxy) StartProxy()

func (*UDPProxy) StopProxy

func (p *UDPProxy) StopProxy()

Jump to

Keyboard shortcuts

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