All checks were successful
Build Multi-Platform Binaries / build (push) Successful in 11m54s
54 lines
1.5 KiB
Go
54 lines
1.5 KiB
Go
package db
|
|
|
|
import "github.com/gotunnel/pkg/protocol"
|
|
|
|
// Client 客户端数据
|
|
type Client struct {
|
|
ID string `json:"id"`
|
|
Nickname string `json:"nickname,omitempty"`
|
|
Rules []protocol.ProxyRule `json:"rules"`
|
|
}
|
|
|
|
// PluginData 插件数据
|
|
type PluginData struct {
|
|
Name string `json:"name"`
|
|
Version string `json:"version"`
|
|
Type string `json:"type"`
|
|
Source string `json:"source"`
|
|
Description string `json:"description"`
|
|
Author string `json:"author"`
|
|
Checksum string `json:"checksum"`
|
|
Size int64 `json:"size"`
|
|
Enabled bool `json:"enabled"`
|
|
WASMData []byte `json:"-"`
|
|
}
|
|
|
|
// ClientStore 客户端存储接口
|
|
type ClientStore interface {
|
|
GetAllClients() ([]Client, error)
|
|
GetClient(id string) (*Client, error)
|
|
CreateClient(c *Client) error
|
|
UpdateClient(c *Client) error
|
|
DeleteClient(id string) error
|
|
ClientExists(id string) (bool, error)
|
|
GetClientRules(id string) ([]protocol.ProxyRule, error)
|
|
Close() error
|
|
}
|
|
|
|
// PluginStore 插件存储接口
|
|
type PluginStore interface {
|
|
GetAllPlugins() ([]PluginData, error)
|
|
GetPlugin(name string) (*PluginData, error)
|
|
SavePlugin(p *PluginData) error
|
|
DeletePlugin(name string) error
|
|
SetPluginEnabled(name string, enabled bool) error
|
|
GetPluginWASM(name string) ([]byte, error)
|
|
}
|
|
|
|
// Store 统一存储接口
|
|
type Store interface {
|
|
ClientStore
|
|
PluginStore
|
|
Close() error
|
|
}
|