Documentation
¶
Index ¶
- type AuthConfig
- type ChainConfig
- type Client
- func (c *Client) CreateChain(ctx context.Context, chain *ChainConfig) error
- func (c *Client) CreateHop(ctx context.Context, hop *HopConfig) error
- func (c *Client) CreateService(ctx context.Context, svc *ServiceConfig) error
- func (c *Client) DeleteChain(ctx context.Context, name string) error
- func (c *Client) DeleteHop(ctx context.Context, name string) error
- func (c *Client) DeleteService(ctx context.Context, name string) error
- func (c *Client) GetAllServiceTrafficTotals(ctx context.Context) (map[string]*ServiceTrafficTotals, error)
- func (c *Client) GetChains(ctx context.Context) ([]*ChainConfig, error)
- func (c *Client) GetService(ctx context.Context, name string) (*ServiceConfig, error)
- func (c *Client) GetServiceStats(ctx context.Context, name string) (*ServiceStats, error)deprecated
- func (c *Client) GetServiceTrafficTotals(ctx context.Context, serviceNames []string) (map[string]*ServiceTrafficTotals, error)
- func (c *Client) GetServices(ctx context.Context) (*ServiceListResponse, error)
- func (c *Client) GetStats(ctx context.Context) (*StatsResponse, error)
- func (c *Client) HasMetricsEndpoint() bool
- func (c *Client) HealthCheck(ctx context.Context) error
- func (c *Client) Reload(ctx context.Context) error
- func (c *Client) UpdateService(ctx context.Context, name string, svc *ServiceConfig) error
- type Config
- type ConnectorConfig
- type CurrentStats
- type DialerConfig
- type ForwarderConfig
- type ForwarderNode
- type HandlerConfig
- type HopConfig
- type HopNode
- type ListenerConfig
- type Manager
- func (m *Manager) CheckNodeHealth(ctx context.Context, nodeID uint) error
- func (m *Manager) CreateChain(ctx context.Context, relayNodeID, exitNodeID uint, chainName string) error
- func (m *Manager) CreateForwardRule(ctx context.Context, rule *model.ForwardRule) error
- func (m *Manager) DeleteForwardRule(ctx context.Context, rule *model.ForwardRule) error
- func (m *Manager) GetClient(nodeID uint) (*Client, error)
- func (m *Manager) GetNodeStats(ctx context.Context, nodeID uint) (*StatsResponse, error)deprecated
- func (m *Manager) GetNodeTrafficTotals(ctx context.Context, nodeID uint) (map[string]*ServiceTrafficTotals, error)
- func (m *Manager) GetRuleStats(ctx context.Context, rule *model.ForwardRule) (*ServiceStats, error)
- func (m *Manager) RegisterNode(node *model.ForwardNode) error
- func (m *Manager) SyncAllRules(ctx context.Context) error
- func (m *Manager) SyncRuleToGost(ctx context.Context, rule *model.ForwardRule) error
- func (m *Manager) UnregisterNode(nodeID uint)
- func (m *Manager) UpdateForwardRule(ctx context.Context, rule *model.ForwardRule) error
- type SelectorConfig
- type ServiceConfig
- type ServiceEvent
- type ServiceListResponse
- type ServiceStats
- type ServiceTrafficTotals
- type StatsResponse
- type TLSConfig
- type TotalStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthConfig ¶
type AuthConfig struct {
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
}
AuthConfig 认证配置
type ChainConfig ¶
type ChainConfig struct {
Name string `json:"name"`
Selector *SelectorConfig `json:"selector,omitempty"`
Hops []string `json:"hops,omitempty"`
}
ChainConfig 转发链配置
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client gost API 客户端
func (*Client) CreateChain ¶
func (c *Client) CreateChain(ctx context.Context, chain *ChainConfig) error
CreateChain 创建转发链
func (*Client) CreateService ¶
func (c *Client) CreateService(ctx context.Context, svc *ServiceConfig) error
CreateService 创建服务
func (*Client) DeleteChain ¶
DeleteChain 删除转发链
func (*Client) DeleteService ¶
DeleteService 删除服务
func (*Client) GetAllServiceTrafficTotals ¶
func (c *Client) GetAllServiceTrafficTotals(ctx context.Context) (map[string]*ServiceTrafficTotals, error)
GetAllServiceTrafficTotals 从 gost 的 Prometheus /metrics 端点读取该节点所有 service 的累计流量, 用于节点级统计(不按具体 forward 过滤)。
func (*Client) GetChains ¶
func (c *Client) GetChains(ctx context.Context) ([]*ChainConfig, error)
GetChains 获取转发链列表
func (*Client) GetService ¶
GetService 获取单个服务
func (*Client) GetServiceStats
deprecated
func (*Client) GetServiceTrafficTotals ¶
func (c *Client) GetServiceTrafficTotals(ctx context.Context, serviceNames []string) (map[string]*ServiceTrafficTotals, error)
GetServiceTrafficTotals 从 gost 的 Prometheus /metrics 端点读取指定 service 的累计流量。 gost_service_transfer_input_bytes_total / _output_bytes_total 按 client IP 分行, 需要对同一个 service label 的所有行求和才是该服务的总流量。
func (*Client) GetServices ¶
func (c *Client) GetServices(ctx context.Context) (*ServiceListResponse, error)
GetServices 获取服务列表
func (*Client) GetStats ¶
func (c *Client) GetStats(ctx context.Context) (*StatsResponse, error)
GetStats 获取统计信息
func (*Client) HasMetricsEndpoint ¶
HasMetricsEndpoint 是否已配置 Prometheus /metrics 地址
func (*Client) HealthCheck ¶
HealthCheck 检查 gost API 是否可用
func (*Client) UpdateService ¶
UpdateService 更新服务
type Config ¶
type Config struct {
Host string // gost API 地址,如 "http://192.168.1.1:18080"
MetricsHost string // gost Prometheus /metrics 地址,如 "http://192.168.1.1:9000",为空表示未配置
APIToken string // API 认证令牌
Timeout time.Duration
}
Config 客户端配置
type ConnectorConfig ¶
type ConnectorConfig struct {
Type string `json:"type"`
Auth *AuthConfig `json:"auth,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
ConnectorConfig 连接器配置
type CurrentStats ¶
type CurrentStats struct {
Connections int `json:"connections"`
Handled int64 `json:"handled"`
InBytes int64 `json:"inBytes"`
OutBytes int64 `json:"outBytes"`
}
CurrentStats 当前统计
type DialerConfig ¶
type DialerConfig struct {
Type string `json:"type"`
Auth *AuthConfig `json:"auth,omitempty"`
TLS *TLSConfig `json:"tls,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
DialerConfig 拨号器配置
type ForwarderConfig ¶
type ForwarderConfig struct {
Nodes []ForwarderNode `json:"nodes,omitempty"`
Selector *SelectorConfig `json:"selector,omitempty"`
}
ForwarderConfig 转发器配置
type ForwarderNode ¶
type ForwarderNode struct {
Name string `json:"name"`
Addr string `json:"addr"`
Protocol string `json:"protocol,omitempty"`
}
ForwarderNode 转发目标节点
type HandlerConfig ¶
type HandlerConfig struct {
Type string `json:"type"`
Auth *AuthConfig `json:"auth,omitempty"`
Chain string `json:"chain,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
HandlerConfig 处理器配置
type HopConfig ¶
type HopConfig struct {
Name string `json:"name"`
Selector *SelectorConfig `json:"selector,omitempty"`
Nodes []HopNode `json:"nodes,omitempty"`
}
HopConfig 跳点配置
type HopNode ¶
type HopNode struct {
Name string `json:"name"`
Addr string `json:"addr"`
Interface string `json:"interface,omitempty"`
Connector *ConnectorConfig `json:"connector,omitempty"`
Dialer *DialerConfig `json:"dialer,omitempty"`
}
HopNode 跳点节点
type ListenerConfig ¶
type ListenerConfig struct {
Type string `json:"type"`
Auth *AuthConfig `json:"auth,omitempty"`
Chain string `json:"chain,omitempty"`
TLS *TLSConfig `json:"tls,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
ListenerConfig 监听器配置
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager gost 转发管理器
func (*Manager) CheckNodeHealth ¶
CheckNodeHealth 检查节点健康状态
func (*Manager) CreateChain ¶
func (m *Manager) CreateChain(ctx context.Context, relayNodeID, exitNodeID uint, chainName string) error
CreateChain 创建转发链(中转 -> 落地)
func (*Manager) CreateForwardRule ¶
CreateForwardRule 创建转发规则 对于中转节点(relay): 创建监听服务 对于落地节点(exit): 需要在中转节点上配置转发链
func (*Manager) DeleteForwardRule ¶
DeleteForwardRule 删除转发规则
func (*Manager) GetNodeStats
deprecated
func (*Manager) GetNodeTrafficTotals ¶
func (m *Manager) GetNodeTrafficTotals(ctx context.Context, nodeID uint) (map[string]*ServiceTrafficTotals, error)
GetNodeTrafficTotals 通过节点的 Prometheus /metrics 端点汇总该节点上所有 service 的流量, 用于节点级"同步统计",替代已失效的 GetNodeStats(REST /api/stats)。
func (*Manager) GetRuleStats ¶
func (m *Manager) GetRuleStats(ctx context.Context, rule *model.ForwardRule) (*ServiceStats, error)
GetRuleStats 获取规则统计信息
func (*Manager) RegisterNode ¶
func (m *Manager) RegisterNode(node *model.ForwardNode) error
RegisterNode 注册节点(创建客户端)
func (*Manager) SyncAllRules ¶
SyncAllRules 同步所有启用的规则到 gost
func (*Manager) SyncRuleToGost ¶
SyncRuleToGost 同步规则到 gost(用于规则状态变更)
func (*Manager) UnregisterNode ¶
UnregisterNode 注销节点(移除客户端)
func (*Manager) UpdateForwardRule ¶
UpdateForwardRule 更新转发规则
type SelectorConfig ¶
type SelectorConfig struct {
Strategy string `json:"strategy"` // round, rand, hash, failover
MaxFails int `json:"maxFails,omitempty"`
FailTimeout string `json:"failTimeout,omitempty"`
}
SelectorConfig 选择器配置
type ServiceConfig ¶
type ServiceConfig struct {
Name string `json:"name"`
Addr string `json:"addr"`
Interface string `json:"interface,omitempty"`
Handler *HandlerConfig `json:"handler,omitempty"`
Listener *ListenerConfig `json:"listener,omitempty"`
Forwarder *ForwarderConfig `json:"forwarder,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
ServiceConfig gost 服务配置
type ServiceEvent ¶
type ServiceEvent struct {
Time time.Time `json:"time"`
Type string `json:"type"`
Status string `json:"status"`
}
ServiceEvent 服务事件
type ServiceListResponse ¶
type ServiceListResponse struct {
Count int `json:"count"`
List []*ServiceConfig `json:"list"`
}
ServiceListResponse 服务列表响应
type ServiceStats ¶
type ServiceStats struct {
Name string `json:"name"`
Addr string `json:"addr"`
Events []ServiceEvent `json:"events"`
Current CurrentStats `json:"current"`
Total TotalStats `json:"total"`
}
ServiceStats 服务统计
type ServiceTrafficTotals ¶
ServiceTrafficTotals 单个 service 在所有 client 上的累计字节数
type StatsResponse ¶
type StatsResponse struct {
Services []ServiceStats `json:"services"`
}
StatsResponse 统计响应