config

package
v0.0.0-...-6d513be Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultOutbound = []OutboundRule{
		{
			Port:   "any",
			Proto:  "any",
			Host:   []string{"0.0.0.0/0"},
			Action: "allow",
		},
	}
)

Functions

This section is empty.

Types

type Config

type Config struct {
	//StaticHostMap map[string][]string `yaml:"static_host_map"`
	//Lighthouse    LighthouseConfig    `yaml:"lighthouse"`
	//Listen        ListenConfig        `yaml:"listen"`
	//Tun           TunConfig           `yaml:"tun"`
	//Handshake     HandshakeConfig     `yaml:"handshake"`
	//Outbound      []OutboundRule      `yaml:"outbound"`
	//Inbound       []InboundRule       `yaml:"inbound"`
	Persistence Persistence `yaml:"persistence"`
	Http        HttpConfig  `yaml:"http"`
	Email       EmailConfig `yaml:"email"`
}

func Load

func Load(filename string) (*Config, error)

type EmailConfig

type EmailConfig struct {
	Enable   bool   `yaml:"enable"`
	Host     string `yaml:"host"`
	Port     int    `yaml:"port"`
	Username string `yaml:"username"`
	Password string `yaml:"password"`
}

type HandshakeConfig

type HandshakeConfig struct {
	HandshakeHost  time.Duration
	SyncLighthouse time.Duration
	TryInterval    time.Duration // 尝试间隔
	Retries        int           // 尝试次数
	TriggerBuffer  int           // 触发缓冲
	UseRelays      bool          // 是否使用中继
}

HandshakeConfig 握手配置

type HostConfig

type HostConfig struct {
	StaticHostMap map[string][]string `yaml:"static_host_map"`
	Lighthouse    LighthouseConfig    `yaml:"lighthouse"`
	Listen        ListenConfig        `yaml:"listen"`
	Tun           TunConfig           `yaml:"tun"`
	Handshake     HandshakeConfig     `yaml:"handshake"`
	Outbound      []OutboundRule      `yaml:"outbound"`
	Inbound       []InboundRule       `yaml:"inbound"`
}

func GenerateConfigTemplate

func GenerateConfigTemplate() HostConfig

GenerateConfigTemplate 生成通用配置模板

func GenerateLighthouseConfigTemplate

func GenerateLighthouseConfigTemplate() HostConfig

type HttpConfig

type HttpConfig struct {
	Addr   string    `yaml:"addr"`
	Server string    `yaml:"server"`
	JWT    JwtConfig `yaml:"jwt"`
}

type InboundRule

type InboundRule struct {
	Port  string   `yaml:"port"`
	Proto string   `yaml:"proto"`
	Host  []string `yaml:"host"`
	// "allow" or "deny"
	Action string `yaml:"action"`
}

func (InboundRule) String

func (r InboundRule) String() string

type JwtConfig

type JwtConfig struct {
	Secret string        `yaml:"secret"`
	Expiry time.Duration `yaml:"expire"`
}

type LighthouseConfig

type LighthouseConfig struct {
	Enabled        bool           `yaml:"enabled"`
	Interval       int            `yaml:"interval"`
	Hosts          []string       `yaml:"hosts"`
	LocalAllowList LocalAllowList `yaml:"local_allow_list"`
}

type ListenConfig

type ListenConfig struct {
	Host        string `yaml:"host"`
	Port        int    `yaml:"port"`
	Batch       int    `yaml:"batch"`
	ReadBuffer  int    `yaml:"read_buffer"`
	WriteBuffer int    `yaml:"write_buffer"`
	Routines    int    `yaml:"routines"`
}

type LocalAllowList

type LocalAllowList struct {
	Interfaces map[string]bool `yaml:"ports"`
}

type OutboundRule

type OutboundRule struct {
	Port  string   `yaml:"port"`
	Proto string   `yaml:"proto"`
	Host  []string `yaml:"host"`
	// "allow" or "deny"
	Action string `yaml:"action"`
}

func (OutboundRule) String

func (r OutboundRule) String() string

type Persistence

type Persistence struct {
	Enabled bool   `yaml:"enabled"`
	Url     string `yaml:"url"`
	Type    string `yaml:"type"`
	DB      string `yaml:"db"`
}

type TunConfig

type TunConfig struct {
	Disabled bool `yaml:"disabled"`
	// Dev Name of the device. If not set, a default will be chosen by the OS.
	// For macOS: if set, must be in the form `utun[0-9]+`.
	// For NetBSD: Required to be set, must be in the form `tun[0-9]+`
	Dev                string `yaml:"dev"`
	IP                 string `yaml:"ip"`
	Mask               string `yaml:"mask"`
	DropLocalBroadcast bool   `yaml:"drop_local_broadcast"`
	DropMulticast      bool   `yaml:"drop_multicast"`
	TxQueue            int    `yaml:"tx_queue"`
	MTU                int    `yaml:"mtu"`
}

Jump to

Keyboard shortcuts

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