app

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Config = ConfigYaml{}

配置

View Source
var FrontendWebsocketChan = make(chan *FrontendWebsocket, 1)

消息队列:添加 Frontend 和 Proxy 的连接

View Source
var FrontendWebsocketDelChan = make(chan string, 1)

消息队列:删除 Frontend 和 Proxy 的连接

View Source
var FrontendWebsockets = []*FrontendWebsocket{}

Frontend 和 Proxy 的连接

View Source
var Log = &log.Logger{}

日志组件

View Source
var ProxyWebsockets = []*websocket.Conn{}

Proxy 和 Frontend 的连接

View Source
var ReplyMessageQueues = []chan ReplyMessage{}

消息队列:待回复的消息

View Source
var RequestMessageChan = make(chan []byte, 1000)

消息队列:待发送到代理服务器消息

View Source
var ResponseChanMap = map[string]chan Response{}

接收响应的通道集合

View Source
var ResponseChanMapActionChan = make(chan ResponseChanMapAction, 1000)

消息队列:对 ResponseChanMap 的操作

Functions

func InitConfig

func InitConfig()

读取配置文件

func InitLog added in v1.1.0

func InitLog()

初始化日志组件

Types

type ConfigYaml

type ConfigYaml struct {
	Log struct {
		Level         string `yaml:"Level"`
		ExportConsole int    `yaml:"ExportConsole"`
		ExportFile    struct {
			Path string `yaml:"Path"`
		} `yaml:"ExportFile"`
	} `yaml:"Log"`
	Frontend struct {
		HttpPort      int    `yaml:"HttpPort"`
		HttpTimeout   int    `yaml:"HttpTimeout"`
		HttpsCertFile string `yaml:"HttpsCertFile"`
		HttpsKeyFile  string `yaml:"HttpsKeyFile"`
		WebsocketPort int    `yaml:"WebsocketPort"`
		WebsocketPath string `yaml:"WebsocketPath"`
		SecretKey     string `yaml:"SecretKey"`
	} `yaml:"Frontend"`
	Proxy struct {
		FrontendUrl  string `yaml:"FrontendUrl"`
		BackendHost  string `yaml:"BackendHost"`
		WebsocketNum int    `yaml:"WebsocketNum"`
		SecretKey    string `yaml:"SecretKey"`
	} `yaml:"Proxy"`
	Backend struct {
		HttpPort int `yaml:"HttpPort"`
	} `yaml:"Backend"`
}

配置数据结构

type FrontendWebsocket added in v1.1.1

type FrontendWebsocket struct {
	Id   string
	Conn *websocket.Conn
}

Frontend 和 Proxy 的连接

type ReplyMessage added in v1.1.0

type ReplyMessage struct {
	Type int
	Data []byte
}

回复的消息

type Request

type Request struct {
	Id      string
	Method  string
	Uri     string
	Header  map[string][]string
	Body    []byte
	Timeout int
}

请求

type Response

type Response struct {
	RequestId  string
	StatusCode int
	Header     map[string][]string
	Body       []byte
}

响应

type ResponseChanMapAction

type ResponseChanMapAction struct {
	Name         string // add、del、write
	Request      Request
	RequestId    string
	ResponseChan chan Response
	Response     Response
}

对 ResponseChanMap 的一次操作

Jump to

Keyboard shortcuts

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