Documentation ¶
Index ¶
Constants ¶
View Source
const ( ServerStatusActive = "active" ServerStatusProcessing = "processing" )
View Source
const KeyPath = "storage/database/keys.json"
View Source
const ServerPath = "storage/database/servers.json"
View Source
const SettingPath = "storage/database/settings.json"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database struct { SettingTable *SettingTable KeyTable *KeyTable ServerTable *ServerTable }
type Key ¶
type Key struct { Id string `json:"id" validate:"required,hostname"` Cipher string `json:"cipher" validate:"required,oneof=chacha20-ietf-poly1305 aes-128-gcm aes-256-gcm"` Secret string `json:"secret" validate:"required,min=6,max=64"` Name string `json:"name" validate:"required,min=1,max=64"` Quota int64 `json:"quota" validate:"min=0"` Enabled bool `json:"enabled"` }
type KeyTable ¶
type Server ¶
type Server struct { Id string `json:"id" validate:"required"` HttpHost string `json:"http_host" validate:"required"` HttpPort int `json:"http_port" validate:"required,min=1,max=65536"` ShadowsocksEnabled bool `json:"shadowsocks_enabled"` ShadowsocksHost string `json:"shadowsocks_host"` ShadowsocksPort int `json:"shadowsocks_port" validate:"min=1,max=65536"` ApiToken string `json:"api_token"` Status string `json:"status"` SyncedAt int64 `json:"synced_at" validate:"min=0"` }
type ServerTable ¶
type ServerTable struct { Servers []*Server `json:"keys" validate:"required"` NextId int64 `json:"next_id" validate:"required,min=1"` UpdatedAt int64 `json:"updated_at" validate:"min=0"` }
func (*ServerTable) Delete ¶
func (st *ServerTable) Delete(id string) error
func (*ServerTable) Find ¶
func (st *ServerTable) Find(Id string) *Server
func (*ServerTable) Load ¶
func (st *ServerTable) Load() error
func (*ServerTable) Save ¶
func (st *ServerTable) Save() (err error)
type SettingTable ¶
type SettingTable struct { AdminPassword string `json:"admin_password" validate:"required,min=8,max=32"` ApiToken string `json:"api_token" validate:"required,min=16,max=128"` ShadowsocksEnabled bool `json:"shadowsocks_enabled"` ShadowsocksHost string `json:"shadowsocks_host" validate:"required,max=128"` ShadowsocksPort int `json:"shadowsocks_port" validate:"required,min=1,max=65536"` ExternalHttps string `json:"external_https"` ExternalHttp string `json:"external_http" validate:"required"` TrafficRatio float64 `json:"traffic_ratio" validate:"required,min=1"` }
func (*SettingTable) Load ¶
func (st *SettingTable) Load() error
func (*SettingTable) Save ¶
func (st *SettingTable) Save() error
Click to show internal directories.
Click to hide internal directories.