Documentation
¶
Overview ¶
Package cloudflared 托管 cloudflared 隧道: 使用 Cloudflare Zero Trust 的隧道令牌运行已配置的隧道,或创建无需账号的临时公网隧道。
Index ¶
- Constants
- type DNSResult
- type IngressRule
- type Module
- func (m *Module) ID() string
- func (m *Module) ImportLucky(doc luckyimport.Document, opts luckyimport.Options) (*luckyimport.Report, error)
- func (m *Module) Init(env module.Env) error
- func (m *Module) ProgramInstallers() []*binstall.Installer
- func (m *Module) Routes(r module.Router)
- func (m *Module) SetHTTPClient(fn func() *http.Client)
- func (m *Module) Start(context.Context) error
- func (m *Module) Stop() error
- func (m *Module) Summary() []module.SummaryItem
- func (m *Module) Title() string
- type Settings
- type Tunnel
- type TunnelView
Constants ¶
const ( // ModeToken 使用在 Cloudflare 控制台创建的隧道令牌,公网主机名与回源服务在控制台配置 ModeToken = "token" // ModeQuick 创建 trycloudflare.com 临时隧道,把本地服务暴露到随机公网地址 ModeQuick = "quick" )
隧道模式。
const ID = "cloudflared"
ID 是模块标识。
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DNSResult ¶ added in v0.6.2
type DNSResult struct {
Hostname string `json:"hostname"`
Status string `json:"status"`
Existing string `json:"existing,omitempty"`
Error string `json:"error,omitempty"`
}
DNSResult 是一个主机名的 DNS 记录同步结果。Existing 为冲突时已有记录的类型与内容。
type IngressRule ¶ added in v0.6.2
type IngressRule struct {
Hostname string `json:"hostname,omitempty"`
Path string `json:"path,omitempty"`
Service string `json:"service"`
OriginRequest map[string]any `json:"originRequest,omitempty"`
}
IngressRule 是一条路由规则。OriginRequest 为回源设置,界面只编辑常用项,其余字段原样保留。
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module 是 cloudflared 模块。
func (*Module) ImportLucky ¶ added in v0.4.0
func (m *Module) ImportLucky(doc luckyimport.Document, opts luckyimport.Options) (*luckyimport.Report, error)
ImportLucky 实现 luckyimport.Importer,迁移使用隧道令牌运行的隧道。
func (*Module) ProgramInstallers ¶ added in v0.6.4
ProgramInstallers 返回模块托管的程序安装器,供 Gately 自动检查更新时一并检查托管程序。
func (*Module) SetHTTPClient ¶ added in v0.5.9
SetHTTPClient 实现 module.HTTPClientAware。
func (*Module) Summary ¶
func (m *Module) Summary() []module.SummaryItem
Summary 实现 module.Summarizer。
type Settings ¶
type Settings struct {
// BinPath 为空时依次在配置目录 bin 与 PATH 下查找 cloudflared
BinPath string `json:"binPath"`
}
Settings 是模块级配置。
type Tunnel ¶
type Tunnel struct {
Key string `json:"key"`
Name string `json:"name"`
// Group 为列表中的分组名称,只影响管理界面的展示,留空为未分组
Group string `json:"group"`
Enable bool `json:"enable"`
Mode string `json:"mode"`
// Token 为 ModeToken 的隧道令牌
Token string `json:"token"`
// APIToken 为 ModeToken 可选的 Cloudflare API 令牌(需要 Cloudflare Tunnel 编辑权限,同步 DNS 还需要 DNS 编辑权限),
// 填写后可在 Gately 中编辑隧道的路由规则
APIToken string `json:"apiToken,omitempty"`
// Service 为 ModeQuick 要暴露的本地服务地址,例如 http://localhost:8080
Service string `json:"service"`
// Protocol 为边缘连接协议:auto、quic、http2
Protocol string `json:"protocol"`
// EdgeIPVersion 为 auto、4、6
EdgeIPVersion string `json:"edgeIpVersion"`
Remark string `json:"remark"`
}
Tunnel 是一条隧道。
type TunnelView ¶
type TunnelView struct {
Tunnel
State proc.State `json:"state"`
Error string `json:"error"`
// URL 为临时隧道的公网地址
URL string `json:"url,omitempty"`
// Connections 为已注册的边缘连接数
Connections int `json:"connections"`
// TunnelID 为从令牌解析出的隧道 ID
TunnelID string `json:"tunnelId,omitempty"`
}
TunnelView 是界面展示的隧道。