Documentation
¶
Overview ¶
Package tailscale 托管 tailscaled 并通过 tailscale 命令完成登录与状态展示, 把本机加入 Tailscale 或 Headscale 组网,可发布子网路由与出口节点。 支持多个实例:每个实例是一个独立的 tailscaled(状态目录、控制套接字与进程互不相同),可分别加入不同的 tailnet。
Index ¶
- Constants
- type Instance
- type InstanceView
- type Module
- func (m *Module) ID() string
- 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 Options
- type PeerView
- type Settings
- type SettingsView
- type StatusView
Constants ¶
const ID = "tailscale"
ID 是模块标识。
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Instance ¶ added in v0.6.5
type Instance struct {
Key string `json:"key"`
Name string `json:"name"`
// Group 为列表中的分组名称,只影响管理界面的展示,留空为未分组
Group string `json:"group"`
Enable bool `json:"enable"`
Options
Remark string `json:"remark"`
// LegacyStateDir 表示实例由 0.6.4 及更早版本的单实例配置迁移而来:stateDir 留空时沿用升级前的默认目录
// <配置目录>/tailscale,节点身份不变。由服务端维护,修改时保留原值,复制时清除
LegacyStateDir bool `json:"legacyStateDir,omitempty"`
}
Instance 是一个 tailscaled 实例:独立的状态目录、控制套接字与进程,可分别加入不同的 tailnet。
func (*Instance) DaemonArgs ¶ added in v0.6.5
DaemonArgs 生成 tailscaled 的命令行参数。
type InstanceView ¶ added in v0.6.5
type InstanceView struct {
Instance
// State 为托管的 tailscaled 进程状态
State proc.State `json:"state"`
// Error 为启动流程的错误(含与其他实例冲突而未启动的原因)
Error string `json:"error"`
// DefaultStateDir 为 stateDir 留空时使用的状态目录
DefaultStateDir string `json:"defaultStateDir"`
}
InstanceView 是界面展示的实例,认证密钥已脱敏。
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module 是 Tailscale 模块。
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 Options ¶ added in v0.6.5
type Options struct {
// ManageDaemon 为 true 时由 Gately 运行 tailscaled;为 false 时使用系统已有的 tailscaled,只负责 tailscale up 与状态展示
ManageDaemon bool `json:"manageDaemon"`
// StateDir 保存登录状态,留空为配置目录下的 tailscale/<实例 key>;可填已有的状态目录以沿用原节点身份
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"`
}
Options 是一个 tailscaled 的运行与登录参数。
func DefaultOptions ¶ added in v0.6.5
func DefaultOptions() Options
DefaultOptions 是新实例的默认参数:托管 tailscaled 并使用用户态网络。
func (*Options) DaemonEnvList ¶ added in v0.6.5
DaemonEnvList 返回传给 tailscaled 的环境变量(KEY=VALUE 形式),格式错误的行已在 Validate 中拒绝。
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 {
// TailscaledPath、TailscalePath 为空时依次在配置目录 bin 与 PATH 下查找
TailscaledPath string `json:"tailscaledPath"`
TailscalePath string `json:"tailscalePath"`
// InstallProxy 为在线安装使用的下载代理,空表示沿用全局“更新代理”;只通过安装接口修改
InstallProxy string `json:"installProxy"`
}
Settings 是模块级(程序级)设置,所有实例共用。
type SettingsView ¶ added in v0.6.5
type SettingsView struct {
Settings Settings `json:"settings"`
// CLI 为实际使用的 tailscale 命令路径,找不到时为空
CLI string `json:"cli"`
}
SettingsView 是 GET /settings 的返回内容。
type StatusView ¶
type StatusView struct {
// Key、Name 为实例的 key 与名称
Key string `json:"key"`
Name string `json:"name"`
Enable bool `json:"enable"`
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 是一个实例的连接状态。