base

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2022 License: MIT Imports: 12 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(10240)
View Source
const DEFAULT_MAX_PROXY_COUNT = 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 GetGlobalConnections

func GetGlobalConnections() int64

func GetGlobalMaxConnections

func GetGlobalMaxConnections() int64

func GetGlobalMaxProxyCount

func GetGlobalMaxProxyCount() int64

func GetProxyKey

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

func GetSingleProxyMaxConnections

func GetSingleProxyMaxConnections(m *int64) int64

func GloBalCOnnectionsAdd

func GloBalCOnnectionsAdd(add int64) int64

func SetGlobalMaxConnections

func SetGlobalMaxConnections(max int64)

func SetGlobalMaxProxyCount

func SetGlobalMaxProxyCount(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) FromRule

func (p *BaseProxyConf) FromRule() string

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)

func (*BaseProxyConf) SetFromRule

func (p *BaseProxyConf) SetFromRule(rule string)

type Proxy

type Proxy interface {
	StartProxy()
	StopProxy()

	ReceiveDataCallback(int64)
	SendDataCallback(int64)
	GetProxyType() string
	GetStatus() string
	GetListenIP() string
	GetListenPort() int
	GetKey() string
	GetCurrentConnections() int64
	SetFromRule(string)
	FromRule() string
	String() string
	GetTrafficIn() int64
	GetTrafficOut() int64
	SafeCheck(ip string) bool
}

func CreateProxy

func CreateProxy(proxyType, listenIP, targetHost string, balanceTargetAddressList *[]string, listenPort, targetPort int, options *RelayRuleOptions) (p Proxy, err error)

type RelayRuleOptions

type RelayRuleOptions struct {
	UDPPackageSize            int    `json:"UDPPackageSize,omitempty"`
	SingleProxyMaxConnections int64  `json:"SingleProxyMaxConnections,omitempty"`
	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(proxyType, listenIP, targetIP string, balanceTargetAddressList *[]string, listenPort, targetPort int, options *RelayRuleOptions) *TCPProxy

func (*TCPProxy) GetCurrentCon

func (p *TCPProxy) GetCurrentCon() int64

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) CheckConnections

func (p *TCPUDPProxyCommonConf) CheckConnections() bool

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) PrintConnectionsInfo

func (p *TCPUDPProxyCommonConf) PrintConnectionsInfo()

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
	// contains filtered or unexported fields
}

func CreateUDPProxy

func CreateUDPProxy(proxyType, listenIP, targetIP string, balanceTargetAddressList *[]string, listenPort, targetPort int, options *RelayRuleOptions) *UDPProxy

func (*UDPProxy) CheckTargetUDPConn

func (p *UDPProxy) CheckTargetUDPConn()

func (*UDPProxy) Forwarder

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

func (*UDPProxy) GetStatus

func (p *UDPProxy) GetStatus() string

func (*UDPProxy) GetUDPPacketSize

func (p *UDPProxy) GetUDPPacketSize() int

func (*UDPProxy) ListenFunc

func (p *UDPProxy) ListenFunc(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