tailscale

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: Apache-2.0 Imports: 22 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 tailscale 托管 tailscaled 并通过 tailscale 命令完成登录与状态展示, 把本机加入 Tailscale 或 Headscale 组网,可发布子网路由与出口节点。

Index

Constants

View Source
const ID = "tailscale"

ID 是模块标识。

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

type Module struct {
	// contains filtered or unexported fields
}

Module 是 Tailscale 模块。

func New

func New() *Module

New 创建模块。

func (*Module) ID

func (m *Module) ID() string

ID 实现 module.Module。

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 PeerView

type PeerView struct {
	Name           string    `json:"name"`
	DNSName        string    `json:"dnsName"`
	IPs            []string  `json:"ips"`
	OS             string    `json:"os"`
	Online         bool      `json:"online"`
	Active         bool      `json:"active"`
	ExitNode       bool      `json:"exitNode"`
	ExitNodeOption bool      `json:"exitNodeOption"`
	Relay          string    `json:"relay,omitempty"`
	CurAddr        string    `json:"curAddr,omitempty"`
	Routes         []string  `json:"routes,omitempty"`
	RxBytes        int64     `json:"rxBytes"`
	TxBytes        int64     `json:"txBytes"`
	LastSeen       time.Time `json:"lastSeen,omitempty"`
}

PeerView 是界面展示的节点。

type Settings

type Settings struct {
	Enable bool `json:"enable"`
	// ManageDaemon 为 true 时由 Gately 运行 tailscaled;为 false 时使用系统已有的 tailscaled,只负责 tailscale up 与状态展示
	ManageDaemon   bool   `json:"manageDaemon"`
	TailscaledPath string `json:"tailscaledPath"`
	TailscalePath  string `json:"tailscalePath"`
	// StateDir 保存登录状态,留空为配置目录下的 tailscale 子目录
	StateDir string `json:"stateDir"`
	// Socket 为 tailscaled 的控制套接字,托管时留空为 StateDir 下的 tailscaled.sock,外部守护进程留空使用系统默认
	Socket string `json:"socket"`
	// Userspace 使用用户态网络,无需 TUN 设备与特权,适合容器;此时本机服务经 Socks5 访问其他节点
	Userspace bool `json:"userspace"`
	// Socks5 为用户态网络下的 SOCKS5 代理监听地址,例如 localhost:1055
	Socks5 string `json:"socks5"`
	// AuthKey 为认证密钥,留空时需要在状态面板中打开登录链接完成认证
	AuthKey     string `json:"authKey"`
	Hostname    string `json:"hostname"`
	LoginServer string `json:"loginServer"`
	// AdvertiseRoutes 是向 tailnet 发布的子网路由(CIDR)
	AdvertiseRoutes   []string `json:"advertiseRoutes"`
	AdvertiseExitNode bool     `json:"advertiseExitNode"`
	AcceptRoutes      bool     `json:"acceptRoutes"`
	AcceptDNS         bool     `json:"acceptDns"`
	// ExtraUpArgs 追加到 tailscale up 之后,以空白分隔
	ExtraUpArgs string `json:"extraUpArgs"`
	// Port 为 tailscaled 的 WireGuard UDP 监听端口,0 表示由 tailscaled 自行选择;固定后便于在防火墙放行直连
	Port int `json:"port"`
	// DaemonExtraArgs 追加到 tailscaled 命令行之后,以空白分隔
	DaemonExtraArgs string `json:"daemonExtraArgs"`
	// DaemonEnv 是传给 tailscaled 的环境变量,每行一个 KEY=VALUE,例如 TS_DEBUG_FIREWALL_MODE=nftables
	DaemonEnv string `json:"daemonEnv"`
}

Settings 是 Tailscale 配置。

func DefaultSettings

func DefaultSettings() Settings

DefaultSettings 是首次使用的默认配置:托管 tailscaled 并使用用户态网络。

func (*Settings) CLIArgs

func (s *Settings) CLIArgs(configDir string) []string

CLIArgs 生成 tailscale 命令的全局参数。

func (*Settings) DaemonArgs

func (s *Settings) DaemonArgs(configDir string) []string

DaemonArgs 生成 tailscaled 的命令行参数。

func (*Settings) DaemonEnvList

func (s *Settings) DaemonEnvList() []string

DaemonEnvList 返回传给 tailscaled 的环境变量(KEY=VALUE 形式),格式错误的行已在 Validate 中拒绝。

func (*Settings) UpArgs

func (s *Settings) UpArgs() []string

UpArgs 生成 tailscale up 的参数。使用 --reset 让界面配置成为唯一的事实来源, 否则 tailscale 会要求列出所有非默认参数。

func (*Settings) Validate

func (s *Settings) Validate() error

Validate 校验并规范化配置。

type StatusView

type StatusView struct {
	Daemon  proc.State `json:"daemon"`
	CLI     string     `json:"cli"`
	Version string     `json:"version"`
	// Error 为启动流程或状态查询的错误
	Error          string     `json:"error"`
	BackendState   string     `json:"backendState"`
	AuthURL        string     `json:"authUrl,omitempty"`
	Tailnet        string     `json:"tailnet,omitempty"`
	MagicDNSSuffix string     `json:"magicDnsSuffix,omitempty"`
	Health         []string   `json:"health,omitempty"`
	Self           *PeerView  `json:"self,omitempty"`
	Peers          []PeerView `json:"peers"`
}

StatusView 是 /status 接口的返回内容。

Jump to

Keyboard shortcuts

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