service

package
v0.0.0-...-37f8b3f Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*edgeVPNClient.Client
	// contains filtered or unexported fields
}

Client 是 edgeVPN 客户端的封装 包含额外的元数据和语法糖

func NewClient

func NewClient(serviceID string, c *edgeVPNClient.Client) *Client

NewClient 返回一个与指定服务 ID 关联的新客户端

func (Client) ActiveNodes

func (c Client) ActiveNodes() (active []string, err error)

ActiveNodes 返回活跃节点列表

func (Client) Advertize

func (c Client) Advertize(uuid string) error

Advertize 将给定的 UUID 广播到账本

func (Client) AdvertizingNodes

func (c Client) AdvertizingNodes() (active []string, err error)

AdvertizingNodes 返回正在广播的节点列表

func (Client) Clean

func (c Client) Clean() error

Clean 清理与 serviceID 关联的数据

func (Client) Get

func (c Client) Get(args ...string) (string, error)

Get 从 API 获取通用数据 例如:get("ip", uuid)

func (Client) ListItems

func (c Client) ListItems(serviceID, suffix string) (strs []string, err error)

ListItems 返回与 serviceID 和给定后缀关联的项目列表

func (Client) Set

func (c Client) Set(thing, uuid, value string) error

Set 向 API 设置通用数据 例如:set("ip", uuid, "value")

type Node

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

Node 是服务节点。 它有一组定义的可用角色,网络中的节点可以承担这些角色。 它接受网络令牌或生成一个

func NewNode

func NewNode(o ...Option) (*Node, error)

NewNode 返回一个新的服务节点 服务节点可以应用角色,这些角色由 API 轮询。 这允许使用 API 协调节点来引导服务 并在之后应用角色(例如,使用动态接收的 IP 启动 VPN 等)

func (*Node) Clean

func (k *Node) Clean()

Clean 停止并清理节点

func (*Node) Start

func (k *Node) Start(ctx context.Context) error

Start 使用上下文启动节点

func (*Node) Stop

func (k *Node) Stop()

Stop 通过调用停止角色来停止节点

type Option

type Option func(k *Node) error

Option 是节点选项

func WithAPIAddress

func WithAPIAddress(s string) Option

WithAPIAddress 设置 EdgeVPN API 地址

func WithAssets

func WithAssets(assets ...string) Option

WithAssets 是要复制到临时状态目录的资产列表 它与 WithFS 一起使用以简化二进制嵌入

func WithClient

func WithClient(e *Client) Option

WithClient 设置服务客户端

func WithDefaultRoles

func WithDefaultRoles(roles string) Option

WithDefaultRoles 允许为节点设置逗号分隔的默认角色列表。 注意,设置此选项后,节点将拒绝任何分配的角色

func WithFS

func WithFS(fs embed.FS) Option

WithFS 接受一个 embed.FS 文件系统,从中复制二进制文件

func WithLogger

func WithLogger(l log.StandardLogger) Option

WithLogger 定义在整个执行过程中使用的日志记录器

func WithMinNodes

func WithMinNodes(i int) Option

WithMinNodes 设置最小节点数

func WithNetworkToken

func WithNetworkToken(token string) Option

WithNetworkToken 允许设置网络令牌。 如果未设置,则会自动生成

func WithPersistentRoles

func WithPersistentRoles(roles string) Option

WithPersistentRoles 允许设置持久应用的逗号分隔角色列表

func WithRoles

func WithRoles(k ...RoleKey) Option

WithRoles 定义一组角色键

func WithStateDir

func WithStateDir(s string) Option

WithStateDir 设置节点状态目录。 它将包含解压的资产(如果有)和 角色生成的进程状态。

func WithStopRoles

func WithStopRoles(roles string) Option

WithStopRoles 允许设置在清理期间应用的逗号分隔角色列表

func WithTokenfile

func WithTokenfile(s string) Option

WithTokenfile 设置令牌文件。 如果找不到令牌文件和网络令牌,则会写入该文件

func WithUUID

func WithUUID(s string) Option

WithUUID 设置节点 UUID

type ProcessController

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

ProcessController go-processmanager 的语法糖封装

func NewProcessController

func NewProcessController(statedir string) *ProcessController

NewProcessController 返回一个与状态目录关联的新进程控制器

func (*ProcessController) BinaryPath

func (a *ProcessController) BinaryPath(b string) string

BinaryPath 返回请求的程序二进制路径。 二进制路径相对于进程状态目录

func (*ProcessController) Process

func (a *ProcessController) Process(state, p string, opts ...process.Option) *process.Process

Process 返回一个与状态目录中二进制文件关联的进程

func (*ProcessController) Run

func (a *ProcessController) Run(command string, args ...string) (string, error)

Run 从状态目录中的二进制文件运行命令

type Role

type Role string

Role 是服务角色。 它由一个唯一的字符串标识,通过网络发送 并流式传输到/从客户端。 角色可以直接应用,也可以在 API 中的角色内分配

func (Role) Apply

func (rr Role) Apply(opts ...RoleOption)

Apply 应用角色并接受选项列表

type RoleConfig

type RoleConfig struct {
	Client                                              *Client
	UUID, ServiceID, StateDir, APIAddress, NetworkToken string
	Logger                                              log.StandardLogger
	// contains filtered or unexported fields
}

RoleConfig 是角色配置结构,包含角色可以使用的所有对象

type RoleKey

type RoleKey struct {
	RoleHandler func(c *RoleConfig) error
	Role        Role
}

RoleKey 是角色(字符串)和处理程序之间的关联 处理程序实际完成角色功能

type RoleOption

type RoleOption func(c *RoleConfig)

RoleOption 是角色选项

func WithRole

func WithRole(f map[Role]func(c *RoleConfig) error) RoleOption

WithRole 设置可用角色

func WithRoleAPIAddress

func WithRoleAPIAddress(s string) RoleOption

WithRoleAPIAddress 设置执行期间使用的 API 地址

func WithRoleClient

func WithRoleClient(e *Client) RoleOption

WithRoleClient 为角色设置客户端

func WithRoleLogger

func WithRoleLogger(l log.StandardLogger) RoleOption

WithRoleLogger 为角色操作设置日志记录器

func WithRoleServiceID

func WithRoleServiceID(s string) RoleOption

WithRoleServiceID 设置角色服务 ID

func WithRoleStateDir

func WithRoleStateDir(s string) RoleOption

WithRoleStateDir 设置角色的状态目录

func WithRoleToken

func WithRoleToken(s string) RoleOption

WithRoleToken 设置角色可以使用的网络令牌

func WithRoleUUID

func WithRoleUUID(u string) RoleOption

WithRoleUUID 设置执行角色的 UUID

Jump to

Keyboard shortcuts

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