front

package module
v0.1.20231210031356 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: MIT Imports: 14 Imported by: 0

README

front

这是一个简单的http/https/ws/wss均衡负载、故障转移路由/代理,通过定时刷新配置不中断地:

  • 动态后端
  • 路径继承
  • 自定权重
  • 故障转移
  • 自定义头

支持嵌入到其他项目中/独立运行

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoHttp          = errors.New("ErrNoHttp")
	ErrNoWs            = errors.New("ErrNoWs")
	ErrCopy            = errors.New("ErrCopy")
	ErrReqCreFail      = errors.New("ErrReqCreFail")
	ErrReqDoFail       = errors.New("ErrReqDoFail")
	ErrResDoFail       = errors.New("ErrResDoFail")
	ErrHeaderCheckFail = errors.New("ErrHeaderCheckFail")
)

Functions

func LoadPeriod

func LoadPeriod(ctx context.Context, buf []byte, configF File, configS *[]Config, logger Logger) error

加载

func Run

func Run(ctx context.Context, configSP *Config, logger Logger)

转发

func Test

func Test(ctx context.Context, port int, logger Logger)

测试

Types

type Back

type Back struct {
	Sign string `json:"-"`

	Name        string   `json:"name"`
	To          string   `json:"to"`
	Weight      int      `json:"weight"`
	ErrBanSec   int      `json:"errBanSec"`
	PathAdd     bool     `json:"pathAdd"`
	MatchHeader []Header `json:"matchHeader"`
	ReqHeader   []Header `json:"reqHeader"`
	ResHeader   []Header `json:"resHeader"`
	// contains filtered or unexported fields
}

func GetBackByRequest added in v0.1.20231209195503

func GetBackByRequest(backs []*Back, r *http.Request) []*Back

func (*Back) Disable added in v0.1.20231203025759

func (t *Back) Disable()

func (*Back) IsLive added in v0.1.20231203025759

func (t *Back) IsLive() bool

func (*Back) SwapSign added in v0.1.20231209195503

func (t *Back) SwapSign() bool

type Config

type Config struct {
	Addr string `json:"addr"`
	TLS  struct {
		Config *tls.Config `json:"-"`
		Pub    string      `json:"pub"`
		Key    string      `json:"key"`
	} `json:"tls"`
	MatchRule string  `json:"matchRule"`
	Routes    []Route `json:"routes"`
	// contains filtered or unexported fields
}

type File added in v0.1.20231209073216

type File interface {
	Read(data []byte) (int, error)
}
type Header struct {
	Action string `json:"action"`
	Key    string `json:"key"`
	Value  string `json:"value"`
}

type Logger added in v0.1.20231209073216

type Logger interface {
	Error(msg string, args ...any)
	Debug(msg string, args ...any)
	Info(msg string, args ...any)
	Warn(msg string, args ...any)
}

type Route

type Route struct {
	Path        string `json:"path"`
	Sign        string `json:"-"`
	Splicing    int    `json:"splicing"`
	ErrRedirect bool   `json:"errRedirect"`
	Back        []Back `json:"back"`
}

func (*Route) GenBack

func (t *Route) GenBack() []*Back

func (*Route) SwapSign

func (t *Route) SwapSign() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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