cloudflared

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package cloudflared locates, downloads and runs the cloudflared binary.

Index

Constants

View Source
const ReleaseBase = "https://github.com/cloudflare/cloudflared/releases/latest/download/"

ReleaseBase is where the official binaries live.

Variables

View Source
var ErrNotFound = errors.New("cloudflared was not found")

ErrNotFound means no cloudflared binary is available yet.

Functions

func AssetName

func AssetName(goos, goarch string) (name string, tarball bool, err error)

AssetName returns the release asset for the current platform and whether it is a gzipped tarball rather than a bare binary.

func BinaryName

func BinaryName() string

BinaryName is the platform-specific file name.

Types

type Manager

type Manager struct {
	BinDir  string
	BaseURL string
	HTTP    *http.Client
}

Manager owns linko's private copy of cloudflared.

func New

func New(binDir string) *Manager

New returns a manager storing binaries in binDir.

func (*Manager) Command

func (m *Manager) Command(ctx context.Context, path string, opts RunOptions) *exec.Cmd

Command builds the exec.Cmd that runs the tunnel.

func (*Manager) Download

func (m *Manager) Download(ctx context.Context) (string, error)

Download fetches the current release for this platform.

func (*Manager) Ensure

func (m *Manager) Ensure(ctx context.Context, progress io.Writer) (string, error)

Ensure returns a cloudflared path, downloading it if necessary.

func (*Manager) Locate

func (m *Manager) Locate() (string, error)

Locate returns a usable cloudflared: linko's own copy first, then $PATH.

func (*Manager) Path

func (m *Manager) Path() string

Path is where linko keeps its own copy.

func (*Manager) Version

func (m *Manager) Version(ctx context.Context, path string) (string, error)

Version runs `cloudflared --version` and returns the trimmed output.

type RunOptions

type RunOptions struct {
	// Token is the tunnel run token. It is passed via the environment so it
	// does not show up in the process list.
	Token string
	// LogLevel is cloudflared's --loglevel (debug, info, warn, error, fatal).
	LogLevel string
	// ExtraArgs are appended after `run`.
	ExtraArgs []string
}

RunOptions configures a cloudflared run.

Jump to

Keyboard shortcuts

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