config

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicAuth

type BasicAuth struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type BasicListener

type BasicListener struct {
	// Custom name recorded in logs
	Tag     string `json:"tag"`
	Network string `json:"network"`
	Addr    string `json:"addr"`

	TLS TLS `json:"tls"`
}

type Bridge

type Bridge struct {
	Tag string `json:"tag"`
	// connect url
	//  * "ws://host/path"
	//  * "wss://host/path"
	//  * "http://host/path"
	//  * "https://host/path"
	//  * "basic://host:port"
	//  * "basic+tls://host:port"
	URL string `json:"url"`
	// optional connect address
	Addr string `json:"addr"`
	// optional network
	Network string `json:"network"`
	// If true, do not verify whether the certificate is valid when connecting to the tls server
	AllowInsecure bool `json:"allowInsecure"`
	// http method, default "POST"
	Method string `json:"method"`
	// Optional credentials, only valid for http protocol
	Access string `jsong:"access"`
	// Specify forwarding destination in "basic" mode
	Dialer ConnectDialer `json:"dialer"`

	// ping http default '40s'
	Ping string `json:"ping"`
}

type Config

type Config struct {
	Logger Logger `json:"logger"`
	Pool   Pool   `json:"pool"`
	// Listener to receive incoming traffic
	Listener []*Listener `json:"listener"`
	// Outgoing traffic, how to connect to the remote end
	Dialer []*Dialer `json:"dialer"`
	// Outgoing traffic, how to connect to the remote end
	Bridge []*Bridge `json:"bridge"`
}

func (*Config) Load

func (c *Config) Load(filename string) (e error)

func (*Config) Print added in v0.0.2

func (c *Config) Print(filename string) (e error)

type ConnectDialer

type ConnectDialer struct {
	// Connect dialer with tag 'tcp'
	Tag string `json:"tag"`
	// After one end of the connection is disconnected, wait for one second before closing the other end
	// (waiting for untransmitted data to continue transmitting)
	// Default "1s"
	Close string `json:"close"`
}

type Dialer

type Dialer struct {
	// Must be unique
	Tag string `json:"tag"`
	// Connect timeout
	// Default 500ms
	Timeout string `json:"timeout"`
	// connect url
	//  * "ws://host/path"
	//  * "wss://host/path"
	//  * "http://host/path"
	//  * "https://host/path"
	//  * "basic://host:port"
	//  * "basic+tls://host:port"
	URL string `json:"url"`
	// optional connect address
	Addr string `json:"addr"`
	// optional network
	Network string `json:"network"`
	// If true, do not verify whether the certificate is valid when connecting to the tls server
	AllowInsecure bool `json:"allowInsecure"`
	// If dialing fails, how many times to retry
	Retry int `json:"retry"`
	// http method, default "POST"
	Method string `json:"method"`
	// Optional credentials, only valid for http protocol
	Access string `jsong:"access"`

	// ping http default '40s'
	Ping string `json:"ping"`
}

type Listener

type Listener struct {
	BasicListener
	// work mode, "basic" or "http" or "portal"
	// default is "basic"
	Mode string `json:"mode"`
	// Specify forwarding destination in "basic" mode
	Dialer ConnectDialer `json:"dialer"`
	// Specify route for http mode
	Router []*Router `json:"router"`
	Portal Portal    `json:"portal"`
}

Listener to receive incoming traffic

type Logger

type Logger struct {
	Level string `json:"level"`
	// add source
	Source bool `json:"source"`
}

type Pool

type Pool struct {
	// Read and write buffer size
	Size int `json:"size"`
	// How much memory to cache,
	// make([size]byte,cache)
	Cache int `json:"cache"`
}

type Portal

type Portal struct {
	Tag string `json:"tag"`
	// Wait connect timeout
	// Default 500ms
	Timeout string `json:"timeout"`
	// How often does an idle connection send a heartbeat?
	Heart string `json:"heart"`
	// Timeout for waiting for heartbeat response
	HeartTimeout string `json:"heartTimeout"`
}

type Router

type Router struct {
	// POST PUT PATCH WS
	Method string `json:"method"`
	// url match pattern
	Pattern string `json:"pattern"`
	// Specify forwarding destination
	Dialer ConnectDialer `json:"dialer"`
	// Access token, If non-empty, this value will be verified from the header and url parameters.
	//  * 'ws://example.com/anypath?access_token=access_token=Bearer%20' + rawURLBase64(XXXXX)
	//  * curl -H "Authorization: Bearer " + rawURLBase64(XXXXX)
	Access string `json:"access"`

	// basic auth
	Auth []BasicAuth `json:"auth"`

	// Portal tag, if not emoty, enable portal mode
	Portal Portal `json:"portal"`

	FS string `json:"fs"`
}

type TLS

type TLS struct {
	CertFile string   `json:"certFile"`
	KeyFile  string   `json:"keyFile"`
	Cert     string   `json:"cert"`
	Key      string   `json:"key"`
	Alpn     []string `json:"alpn"`
}

func (*TLS) Certificate

func (t *TLS) Certificate() (secure bool, certificate tls.Certificate, alpn []string, e error)

func (*TLS) Secure

func (t *TLS) Secure() bool

Jump to

Keyboard shortcuts

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