Documentation
¶
Index ¶
- func GenerateMachineCode() string
- func GetOrCreateMachineCode(machineCodePath string) (string, error)
- func ValidateMachineCode(machineCode string) bool
- type ActivationCheckResponse
- type ActivationRequest
- type ActivationResult
- type Client
- func (c *Client) Activate(request ActivationRequest) (*ActivationResult, error)
- func (c *Client) Check() (*ActivationCheckResponse, error)
- func (c *Client) Enabled() bool
- func (c *Client) Feedback(payload FeedbackPayload) (*FeedbackResult, error)
- func (c *Client) MachineCode() string
- func (c *Client) StoreData(payload DataStorePayload) (*DataStoreResult, error)
- type DataStorePayload
- type DataStoreResult
- type FeedbackPayload
- type FeedbackResult
- type InitOptions
- type InitResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateMachineCode ¶
func GenerateMachineCode() string
GenerateMachineCode 生成机器码 规则:系统用户名的 MD5 前 16 位 + UUID 后 16 位 = 32 位
func GetOrCreateMachineCode ¶
GetOrCreateMachineCode 获取或创建机器码 在 machineCodePath 目录下查找以 machineCode 为文件名的文件(文件名即为机器码) 如果文件存在,则返回文件名(机器码) 如果文件不存在,则生成新的机器码并保存到文件(文件名为机器码)
func ValidateMachineCode ¶
ValidateMachineCode 验证机器码是否合法(通过系统用户名的 MD5 前 16 位)
Types ¶
type ActivationCheckResponse ¶
type ActivationCheckResponse struct {
// Expired 是否过期
Expired bool
// Activated 是否已激活
Activated *bool
// ExpireAt 过期时间
ExpireAt string
// Reason 错误原因
Reason string
}
ActivationCheckResponse 激活检查响应
type ActivationRequest ¶
type ActivationRequest struct {
// Code 激活码
Code string
}
ActivationRequest 激活请求
type ActivationResult ¶
type ActivationResult struct {
// Success 是否成功
Success bool
// ExpireAt 过期时间
ExpireAt string
// Error 错误信息
Error string
}
ActivationResult 激活响应
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client Feedback 客户端
func NewClient ¶
func NewClient(options InitOptions) (*Client, error)
NewClient 创建新的 Feedback 客户端 如果初始化失败,会返回 enabled=false 的客户端,而不是返回错误
func (*Client) Activate ¶
func (c *Client) Activate(request ActivationRequest) (*ActivationResult, error)
Activate 激活软件
func (*Client) Check ¶
func (c *Client) Check() (*ActivationCheckResponse, error)
Check 检查激活状态(机器码在内部自动使用)
func (*Client) Feedback ¶
func (c *Client) Feedback(payload FeedbackPayload) (*FeedbackResult, error)
Feedback 提交反馈
func (*Client) StoreData ¶ added in v0.1.1
func (c *Client) StoreData(payload DataStorePayload) (*DataStoreResult, error)
StoreData 存储数据
type DataStorePayload ¶ added in v0.1.1
type DataStorePayload struct {
// Data 数据内容
Data string
}
DataStorePayload 数据存储请求
type DataStoreResult ¶ added in v0.1.1
type DataStoreResult struct {
// Success 是否成功
Success bool
// ID 数据存储 ID
ID *uint
// Error 错误信息
Error string
}
DataStoreResult 数据存储响应
type FeedbackPayload ¶
FeedbackPayload 反馈提交请求
type FeedbackResult ¶
type FeedbackResult struct {
// Success 是否成功
Success bool
// ID 反馈 ID
ID *uint
// Error 错误信息
Error string
}
FeedbackResult 反馈提交响应
type InitOptions ¶
type InitOptions struct {
// BaseURL 服务器基础 URL
BaseURL string
// SoftwareID 软件 ID
SoftwareID uint
// Version 软件版本号
Version string
// MachineCodePath 机器码存放目录路径
MachineCodePath string
// TimeoutMs 请求超时时间(毫秒),可选,默认 30000
TimeoutMs int
}
InitOptions 初始化选项
type InitResult ¶
type InitResult struct {
// Enabled 是否启用
Enabled bool
// MachineCode 生成的机器码
MachineCode string
// Error 错误信息(如果初始化失败)
Error string
}
InitResult 初始化结果
Click to show internal directories.
Click to hide internal directories.