Documentation ¶
Index ¶
- Constants
- func MustInitDBManager(dbs map[string]*gorm.DB, defaultDBType string)
- func NewDBManager(dbs map[string]*gorm.DB, defaultDBType string) *dbManagerImpl
- type Cert
- type Client
- type ClientEntity
- type DBManager
- type HistoryProxyStats
- type Proxy
- type ProxyEntity
- type Server
- type ServerEntity
- type User
- type UserEntity
- func (u *UserEntity) GetEmail() string
- func (u *UserEntity) GetHashedPassword() string
- func (u *UserEntity) GetRole() string
- func (u *UserEntity) GetSafeUserInfo() UserEntity
- func (u *UserEntity) GetStatus() int
- func (u *UserEntity) GetTenantID() int
- func (u *UserEntity) GetToken() string
- func (u *UserEntity) GetUserID() int
- func (u *UserEntity) GetUserIDStr() string
- func (u *UserEntity) GetUserName() string
- func (u *UserEntity) IsAdmin() bool
- func (u *UserEntity) Valid() bool
- type UserInfo
Constants ¶
View Source
const ( ROLE_ADMIN = "admin" ROLE_NORMAL = "normal" )
View Source
const ( STATUS_UNKNOWN = iota STATUS_NORMAL STATUS_BANED )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cert ¶
type Client ¶
type Client struct {
*ClientEntity
}
type ClientEntity ¶
type ClientEntity struct { ClientID string `json:"client_id" gorm:"uniqueIndex;not null;primaryKey"` ServerID string `json:"server_id"` TenantID int `json:"tenant_id" gorm:"not null"` UserID int `json:"user_id" gorm:"not null"` ConfigContent []byte `json:"config_content"` ConnectSecret string `json:"connect_secret" gorm:"not null"` Stopped bool `json:"stopped"` Comment string `json:"comment"` CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt `gorm:"index"` }
func (*ClientEntity) GetConfigContent ¶
func (c *ClientEntity) GetConfigContent() (*v1.ClientConfig, error)
func (*ClientEntity) SetConfigContent ¶
func (c *ClientEntity) SetConfigContent(cfg v1.ClientConfig) error
type DBManager ¶
type DBManager interface { GetDB(dbType string) *gorm.DB GetDefaultDB() *gorm.DB SetDB(dbType string, db *gorm.DB) RemoveDB(dbType string) Init() }
func GetDBManager ¶
func GetDBManager() DBManager
type HistoryProxyStats ¶ added in v0.0.31
type HistoryProxyStats struct { gorm.Model ProxyID int `json:"proxy_id" gorm:"index"` ServerID string `json:"server_id" gorm:"index"` ClientID string `json:"client_id" gorm:"index"` Name string `json:"name"` Type string `json:"type"` UserID int `json:"user_id" gorm:"index"` TenantID int `json:"tenant_id" gorm:"index"` TrafficIn int64 `json:"traffic_in"` TrafficOut int64 `json:"traffic_out"` }
HistoryProxyStats 历史流量统计,不保证精准,只是为了展示。精准请使用 proxies 表中的 history_traffic_in/history_traffic_out 后续看看是否要改成时序类数据 https://github.com/nakabonne/tstorage
func (*HistoryProxyStats) TableName ¶ added in v0.0.31
func (*HistoryProxyStats) TableName() string
type Proxy ¶ added in v0.0.31
type Proxy struct {
*ProxyEntity
}
type ProxyEntity ¶ added in v0.0.31
type ProxyEntity struct { ProxyID int `json:"proxy_id" gorm:"primary_key;auto_increment"` ServerID string `json:"server_id" gorm:"index"` ClientID string `json:"client_id" gorm:"index"` Name string `json:"name"` Type string `json:"type"` UserID int `json:"user_id" gorm:"index"` TenantID int `json:"tenant_id" gorm:"index"` TodayTrafficIn int64 `json:"today_traffic_in"` TodayTrafficOut int64 `json:"today_traffic_out"` HistoryTrafficIn int64 `json:"history_traffic_in"` HistoryTrafficOut int64 `json:"history_traffic_out"` CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt `gorm:"index"` }
type Server ¶
type Server struct {
*ServerEntity
}
type ServerEntity ¶
type ServerEntity struct { ServerID string `json:"client_id" gorm:"uniqueIndex;not null;primaryKey"` TenantID int `json:"tenant_id" gorm:"not null"` UserID int `json:"user_id" gorm:"not null"` ServerIP string `json:"server_ip"` ConfigContent []byte `json:"config_content"` ConnectSecret string `json:"connect_secret" gorm:"not null"` Comment string `json:"comment"` CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt `gorm:"index"` }
func (*ServerEntity) ConfigEqual ¶ added in v0.0.41
func (s *ServerEntity) ConfigEqual(cfg *v1.ServerConfig) bool
func (*ServerEntity) GetConfigContent ¶
func (s *ServerEntity) GetConfigContent() (*v1.ServerConfig, error)
func (*ServerEntity) SetConfigContent ¶
func (s *ServerEntity) SetConfigContent(cfg *v1.ServerConfig) error
type User ¶
type User struct {
*UserEntity
}
type UserEntity ¶
type UserEntity struct { UserID int `json:"user_id" gorm:"primaryKey"` UserName string `json:"user_name" gorm:"uniqueIndex;not null"` Password string `json:"password"` Email string `json:"email" gorm:"uniqueIndex;not null"` Status int `json:"status"` Role string `json:"role"` TenantID int `json:"tenant_id"` Token string `json:"token"` CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt `gorm:"index"` }
func (*UserEntity) GetEmail ¶
func (u *UserEntity) GetEmail() string
func (*UserEntity) GetHashedPassword ¶
func (u *UserEntity) GetHashedPassword() string
func (*UserEntity) GetRole ¶
func (u *UserEntity) GetRole() string
func (*UserEntity) GetSafeUserInfo ¶
func (u *UserEntity) GetSafeUserInfo() UserEntity
func (*UserEntity) GetStatus ¶
func (u *UserEntity) GetStatus() int
func (*UserEntity) GetTenantID ¶
func (u *UserEntity) GetTenantID() int
func (*UserEntity) GetToken ¶
func (u *UserEntity) GetToken() string
func (*UserEntity) GetUserID ¶
func (u *UserEntity) GetUserID() int
func (*UserEntity) GetUserIDStr ¶
func (u *UserEntity) GetUserIDStr() string
func (*UserEntity) GetUserName ¶
func (u *UserEntity) GetUserName() string
func (*UserEntity) IsAdmin ¶
func (u *UserEntity) IsAdmin() bool
func (*UserEntity) Valid ¶
func (u *UserEntity) Valid() bool
Click to show internal directories.
Click to hide internal directories.