cloudflared

package
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 16 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 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) Routes

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

Routes 实现 module.Module。

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 为空时依次在 PATH 与配置目录 bin 下查找 cloudflared
	BinPath string `json:"binPath"`
}

Settings 是模块级配置。

type Tunnel

type Tunnel struct {
	Key    string `json:"key"`
	Name   string `json:"name"`
	Enable bool   `json:"enable"`
	Mode   string `json:"mode"`
	// Token 为 ModeToken 的隧道令牌
	Token string `json:"token"`
	// 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"`
}

TunnelView 是界面展示的隧道。

Jump to

Keyboard shortcuts

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