config

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dir

func Dir() string

Dir 返回配置目录路径 便携模式:程序同级目录存在 portable 文件时,使用程序所在目录 普通模式:~/.cftunnel/

func Path

func Path() string

func Portable added in v0.5.0

func Portable() bool

Portable 返回当前是否处于便携模式

Types

type AuthConfig

type AuthConfig struct {
	APIToken  string `yaml:"api_token"`
	AccountID string `yaml:"account_id"`
}

type AuthProxy added in v0.6.0

type AuthProxy struct {
	Username   string `yaml:"username"`
	Password   string `yaml:"password"`
	SigningKey string `yaml:"signing_key,omitempty"`
	CookieTTL  int    `yaml:"cookie_ttl,omitempty"` // 秒,默认 86400
}

AuthProxy 鉴权代理配置

func (*AuthProxy) CookieTTLOrDefault added in v0.6.0

func (a *AuthProxy) CookieTTLOrDefault() int

CookieTTLOrDefault 返回 Cookie 有效期(秒),默认 86400

type CloudflaredConfig

type CloudflaredConfig struct {
	Path       string `yaml:"path"`
	AutoUpdate bool   `yaml:"auto_update"`
}

type Config

type Config struct {
	Version     int               `yaml:"version"`
	Auth        AuthConfig        `yaml:"auth"`
	Tunnel      TunnelConfig      `yaml:"tunnel"`
	Routes      []RouteConfig     `yaml:"routes"`
	Relay       RelayConfig       `yaml:"relay,omitempty"`
	Cloudflared CloudflaredConfig `yaml:"cloudflared"`
	SelfUpdate  SelfUpdateConfig  `yaml:"self_update"`
}

func Load

func Load() (*Config, error)

func (*Config) FindRelayRule added in v0.7.0

func (c *Config) FindRelayRule(name string) *RelayRule

FindRelayRule 查找中继规则

func (*Config) FindRoute

func (c *Config) FindRoute(name string) *RouteConfig

func (*Config) RemoveRelayRule added in v0.7.0

func (c *Config) RemoveRelayRule(name string) bool

RemoveRelayRule 删除中继规则

func (*Config) RemoveRoute

func (c *Config) RemoveRoute(name string) bool

func (*Config) Save

func (c *Config) Save() error

type RelayConfig added in v0.7.0

type RelayConfig struct {
	Server string      `yaml:"server,omitempty"`
	Token  string      `yaml:"token,omitempty"`
	Rules  []RelayRule `yaml:"rules,omitempty"`
}

RelayConfig 中继模式配置

type RelayRule added in v0.7.0

type RelayRule struct {
	Name       string `yaml:"name"`
	Proto      string `yaml:"proto"`              // tcp/udp/http/https/stcp
	LocalIP    string `yaml:"local_ip,omitempty"` // 默认 127.0.0.1
	LocalPort  int    `yaml:"local_port"`
	RemotePort int    `yaml:"remote_port,omitempty"` // HTTP 模式可选
	Domain     string `yaml:"domain,omitempty"`      // HTTP 模式用
}

RelayRule 中继穿透规则

type RouteConfig

type RouteConfig struct {
	Name        string     `yaml:"name"`
	Hostname    string     `yaml:"hostname"`
	Service     string     `yaml:"service"`
	ZoneID      string     `yaml:"zone_id"`
	DNSRecordID string     `yaml:"dns_record_id"`
	Auth        *AuthProxy `yaml:"auth,omitempty"`
}

type SelfUpdateConfig

type SelfUpdateConfig struct {
	AutoCheck bool `yaml:"auto_check"` // 启动时自动检查 cftunnel 更新
}

type TunnelConfig

type TunnelConfig struct {
	ID    string `yaml:"id"`
	Name  string `yaml:"name"`
	Token string `yaml:"token"`
}

Jump to

Keyboard shortcuts

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