proxy

package
v0.0.0-...-01afcf0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2025 License: MulanPSL-2.0 Imports: 16 Imported by: 0

Documentation

Overview

* Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. * PilotGo-plugin-logs licensed under the Mulan Permissive Software License, Version 2. * See LICENSE file for more details. * Author: Wangjunqi123 <wangjunqi@kylinos.cn> * Date: Mon Dec 16 08:43:58 2024 +0800

* Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. * PilotGo-plugin-logs licensed under the Mulan Permissive Software License, Version 2. * See LICENSE file for more details. * Author: Wangjunqi123 <wangjunqi@kylinos.cn> * Date: Mon Dec 16 08:43:58 2024 +0800

* Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. * PilotGo-plugin-logs licensed under the Mulan Permissive Software License, Version 2. * See LICENSE file for more details. * Author: Wangjunqi123 <wangjunqi@kylinos.cn> * Date: Mon Dec 16 08:43:58 2024 +0800

* Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. * PilotGo-plugin-logs licensed under the Mulan Permissive Software License, Version 2. * See LICENSE file for more details. * Author: Wangjunqi123 <wangjunqi@kylinos.cn> * Date: Mon Dec 16 08:43:58 2024 +0800

Index

Constants

View Source
const (
	WebsocketProxyReadError int = iota
	WebsocketProxyWriteError
	WebsocketProxySingleError
)

Variables

View Source
var (
	DefaultUpgrader = &websocket.Upgrader{
		ReadBufferSize:  1024,
		WriteBufferSize: 1024,
		CheckOrigin: func(r *http.Request) bool {
			return true
		},
	}

	DefaultDialer = &websocket.Dialer{
		Proxy:            nil,
		HandshakeTimeout: 45 * time.Second,
		TLSClientConfig: &tls.Config{
			InsecureSkipVerify: true,
		},
	}
)
View Source
var WebsocketProxyCtx = context.Background()

Functions

func CreateWebsocketProxyManagement

func CreateWebsocketProxyManagement()

func InitWebServerTcpHijackProxy

func InitWebServerTcpHijackProxy()

Types

type WebsocketError

type WebsocketError struct {
	Code       int
	SrcConn    *websocket.Conn
	DstConn    *websocket.Conn
	SingleConn *websocket.Conn
	Text       string
}

func (*WebsocketError) Error

func (we *WebsocketError) Error() string

type WebsocketForwardProxy

type WebsocketForwardProxy struct {
	ID string

	Active bool

	Upgrader *websocket.Upgrader

	Dialer *websocket.Dialer

	CancelCtx  context.Context
	CancelFunc context.CancelFunc
	// contains filtered or unexported fields
}

func NewWebsocketForwardProxy

func NewWebsocketForwardProxy() *WebsocketForwardProxy

func (*WebsocketForwardProxy) Close

func (w *WebsocketForwardProxy) Close(_close_A, _close_C, _close_T bool)

func (*WebsocketForwardProxy) ResponseDirector

func (w *WebsocketForwardProxy) ResponseDirector(_resp *http.Response, _header *http.Header)

func (*WebsocketForwardProxy) ServeHTTP

func (w *WebsocketForwardProxy) ServeHTTP(_w http.ResponseWriter, _r *http.Request)

websocket代理:双端websocket连接转发

type WebsocketProxyManagement

type WebsocketProxyManagement struct {
	// key: web client id
	WebsocketProxyMap map[string]*WebsocketForwardProxy
	// contains filtered or unexported fields
}
var WebsocketProxyManager *WebsocketProxyManagement

func (*WebsocketProxyManagement) Add

func (wpm *WebsocketProxyManagement) Add(_id string, _wsproxy *WebsocketForwardProxy)

func (*WebsocketProxyManagement) CloseAll

func (wpm *WebsocketProxyManagement) CloseAll()

func (*WebsocketProxyManagement) Delete

func (wpm *WebsocketProxyManagement) Delete(_id string)

type WebsocketTcpHijackProxy

type WebsocketTcpHijackProxy struct{}

func (*WebsocketTcpHijackProxy) ServeHTTP

func (h *WebsocketTcpHijackProxy) ServeHTTP(_w http.ResponseWriter, _r *http.Request)

func (*WebsocketTcpHijackProxy) TransferMessages

func (h *WebsocketTcpHijackProxy) TransferMessages(_srcConn, _destConn net.Conn, _err_ch chan error)

实现两个tcp net.conn间的数据传输,暂时弃用

Jump to

Keyboard shortcuts

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