cloudflared

package
v0.6.8 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 24 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cloudflared 托管 cloudflared 隧道: 使用 Cloudflare Zero Trust 的隧道令牌运行已配置的隧道,或创建无需账号的临时公网隧道。

Index

Constants

View Source
const (
	// ModeToken 使用在 Cloudflare 控制台创建的隧道令牌,公网主机名与回源服务在控制台配置
	ModeToken = "token"
	// ModeQuick 创建 trycloudflare.com 临时隧道,把本地服务暴露到随机公网地址
	ModeQuick = "quick"
)

隧道模式。

View Source
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 New

func New() *Module

New 创建模块。

func (*Module) ID

func (m *Module) ID() string

ID 实现 module.Module。

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) Init

func (m *Module) Init(env module.Env) error

Init 实现 module.Module。

func (*Module) ProgramInstallers added in v0.6.4

func (m *Module) ProgramInstallers() []*binstall.Installer

ProgramInstallers 返回模块托管的程序安装器,供 Gately 自动检查更新时一并检查托管程序。

func (*Module) Routes

func (m *Module) Routes(r module.Router)

Routes 实现 module.Module。

func (*Module) SetHTTPClient added in v0.5.9

func (m *Module) SetHTTPClient(fn func() *http.Client)

SetHTTPClient 实现 module.HTTPClientAware。

func (*Module) Start

func (m *Module) Start(context.Context) error

Start 实现 module.Module。

func (*Module) Stop

func (m *Module) Stop() error

Stop 实现 module.Module。

func (*Module) Summary

func (m *Module) Summary() []module.SummaryItem

Summary 实现 module.Summarizer。

func (*Module) Title

func (m *Module) Title() string

Title 实现 module.Module。

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 是一条隧道。

func (*Tunnel) Args

func (t *Tunnel) Args() (args, env []string)

Args 生成 cloudflared 命令行参数与环境变量。令牌通过环境变量传递,避免出现在进程列表中。

func (*Tunnel) Validate

func (t *Tunnel) Validate() error

Validate 校验并规范化隧道配置。

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 是界面展示的隧道。

Jump to

Keyboard shortcuts

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