Core

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MethodGet     = 0x47
	MethodConnect = 0x43
	MethodPost    = 0x50
	MethodPut     = 0x50
	MethodDelete  = 0x44
	MethodOptions = 0x4F
	MethodHead    = 0x48
	SocksFive     = 0x5
)
View Source
const (
	// 预留位
	Rsv = 0x00
	// 命令
	CommandConn = 0x01
	CommandBind = 0x02
	CommandUdp  = 0x03
	// 目标类型
	TargetIpv4   = 0x01
	TargetIpv6   = 0x04
	TargetDomain = 0x03
	Version      = 0x5
)
View Source
const (
	GssApi                = 0x01
	UsernamePassword      = 0x02
	IanaAssignedMin       = 0x03
	IanaAssignedMax       = 0x7F
	ReservedForPrivateMin = 0x80
	ReservedForPrivateMax = 0xFE
	NoAcceptMethod        = 0xFF
)
View Source
const ConnectFailed = "HTTP/1.1 502 Bad Gateway\r\n\r\n"
View Source
const ConnectSuccess = "HTTP/1.1 200 Connection Established\r\n\r\n"
View Source
const SocketClient = "client"
View Source
const SocketServer = "server"
View Source
const SslFileHost = "shermie-proxy.io"
View Source
const TcpClient = "client"
View Source
const TcpServer = "server"

Variables

View Source
var Cache = NewStorage()

Functions

func GetAction

func GetAction(hostname string) func() (interface{}, error)

Types

type Certificate

type Certificate struct {
	RootKey    *rsa.PrivateKey
	RootCa     *x509.Certificate
	RootCaStr  []byte
	RootKeyStr []byte
}
var Cert *Certificate

func NewCertificate

func NewCertificate() *Certificate

func (*Certificate) GenerateKeyPair

func (i *Certificate) GenerateKeyPair() (*rsa.PrivateKey, error)

生成一对具有指定字位数的RSA密钥

func (*Certificate) GeneratePem

func (i *Certificate) GeneratePem(host string) ([]byte, []byte, error)

用根证书生成新的子证书

func (*Certificate) GenerateRootPemFile

func (i *Certificate) GenerateRootPemFile(host string) (*pem.Block, *pem.Block, error)

生成新的根证书

func (*Certificate) Init

func (i *Certificate) Init() error

初始化根证书

type ConnPeer

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

type HttpRequestEvent

type HttpRequestEvent func(message []byte, request *http.Request, resolve ResolveHttpRequest, conn net.Conn) bool

type HttpResponseEvent

type HttpResponseEvent func(message []byte, response *http.Response, resolve ResolveHttpResponse, conn net.Conn) bool

type ProxyHttp

type ProxyHttp struct {
	ConnPeer
	// contains filtered or unexported fields
}

func (*ProxyHttp) DialContext

func (i *ProxyHttp) DialContext() func(ctx context.Context, network, addr string) (conn net.Conn, err error)

func (*ProxyHttp) Handle

func (i *ProxyHttp) Handle()

tcp连接处理入口

func (*ProxyHttp) ReadRequestBody

func (i *ProxyHttp) ReadRequestBody(reader io.Reader) ([]byte, error)

读取http请求体

func (*ProxyHttp) ReadResponseBody

func (i *ProxyHttp) ReadResponseBody(response *http.Response) ([]byte, error)

func (*ProxyHttp) RemoveHeader

func (i *ProxyHttp) RemoveHeader(header http.Header)

移除请求头

func (*ProxyHttp) RemoveWsHeader

func (i *ProxyHttp) RemoveWsHeader()

移除ws请求头

func (*ProxyHttp) SetRequest

func (i *ProxyHttp) SetRequest(request *http.Request) *http.Request

设置请求头

func (*ProxyHttp) SslReceiveSend

func (i *ProxyHttp) SslReceiveSend()

tls数据接收发送

func (*ProxyHttp) Transport

func (i *ProxyHttp) Transport(request *http.Request) (*http.Response, error)

http请求转发

func (*ProxyHttp) WsIsConnected

func (i *ProxyHttp) WsIsConnected(conn *Websocket.Conn) bool

连接是否可用

type ProxyServer

type ProxyServer struct {
	OnHttpRequestEvent     HttpRequestEvent
	OnHttpResponseEvent    HttpResponseEvent
	OnWsRequestEvent       WsRequestEvent
	OnWsResponseEvent      WsResponseEvent
	OnSocks5ResponseEvent  Socks5ResponseEvent
	OnSocks5RequestEvent   Socks5RequestEvent
	OnTcpConnectEvent      TcpConnectEvent
	OnTcpCloseEvent        TcpClosetEvent
	OnTcpServerStreamEvent TcpServerStreamEvent
	OnTcpClientStreamEvent TcpClientStreamEvent
	// contains filtered or unexported fields
}

func NewProxyServer

func NewProxyServer(port string, nagle bool, proxy string, to string, network string) *ProxyServer
func (i *ProxyServer) Logo()

func (*ProxyServer) MultiListen

func (i *ProxyServer) MultiListen()

func (*ProxyServer) Start

func (i *ProxyServer) Start() error

func (*ProxyServer) Stop

func (i *ProxyServer) Stop() error

type ProxySocks5

type ProxySocks5 struct {
	ConnPeer
	// contains filtered or unexported fields
}

func NewProxySocket

func NewProxySocket() *ProxySocks5

func (*ProxySocks5) ByteToInt

func (i *ProxySocks5) ByteToInt(input []byte) int32

字节转整型

func (*ProxySocks5) Handle

func (i *ProxySocks5) Handle()

func (*ProxySocks5) IpV4

func (i *ProxySocks5) IpV4(ipAddr string) bool

func (*ProxySocks5) IpV6

func (i *ProxySocks5) IpV6(ipAddr string) bool

func (*ProxySocks5) Transport

func (i *ProxySocks5) Transport(out chan<- error, originConn net.Conn, targetConn net.Conn, role string)

type ProxyTcp

type ProxyTcp struct {
	ConnPeer
	// contains filtered or unexported fields
}

func (*ProxyTcp) Handle

func (i *ProxyTcp) Handle()

func (*ProxyTcp) Transport

func (i *ProxyTcp) Transport(out chan<- error, originConn net.Conn, targetConn net.Conn, role string)

type ResolveHttpRequest

type ResolveHttpRequest func(message []byte, request *http.Request)

type ResolveHttpResponse

type ResolveHttpResponse func(message []byte, response *http.Response)

type ResolveSocks5

type ResolveSocks5 func(buff []byte) (int, error)

type ResolveTcp

type ResolveTcp func(buff []byte) (int, error)

type ResolveWs

type ResolveWs func(msgType int, message []byte) error

type Socks5RequestEvent

type Socks5RequestEvent func(message []byte, resolve ResolveSocks5, conn net.Conn) (int, error)

type Socks5ResponseEvent

type Socks5ResponseEvent func(message []byte, resolve ResolveSocks5, conn net.Conn) (int, error)

type Storage

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

func NewStorage

func NewStorage() *Storage

func (*Storage) GetCertificate

func (i *Storage) GetCertificate(hostname string, port string) (interface{}, error)

type TcpClientStreamEvent

type TcpClientStreamEvent func(message []byte, resolve ResolveTcp, conn net.Conn) (int, error)

type TcpClosetEvent

type TcpClosetEvent func(conn net.Conn)

type TcpConnectEvent

type TcpConnectEvent func(conn net.Conn)

type TcpServerStreamEvent

type TcpServerStreamEvent func(message []byte, resolve ResolveTcp, conn net.Conn) (int, error)

type WsRequestEvent

type WsRequestEvent func(msgType int, message []byte, resolve ResolveWs, conn net.Conn) error

type WsResponseEvent

type WsResponseEvent func(msgType int, message []byte, resolve ResolveWs, conn net.Conn) error

Directories

Path Synopsis
Package websocket implements the WebSocket protocol defined in RFC 6455.
Package websocket implements the WebSocket protocol defined in RFC 6455.

Jump to

Keyboard shortcuts

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