Подготовить HY2XS к production-сборке
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package bo
|
||||
|
||||
import "time"
|
||||
|
||||
type AccountBo struct {
|
||||
Id int64 `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Roles []string `json:"roles"`
|
||||
Deleted int64 `json:"deleted"`
|
||||
}
|
||||
|
||||
type AccountExport struct {
|
||||
Id int64 `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Pass string `json:"pass"`
|
||||
ConPass string `json:"conPass"`
|
||||
Quota int64 `json:"quota"`
|
||||
Download int64 `json:"download"`
|
||||
Upload int64 `json:"upload"`
|
||||
ExpireTime int64 `json:"expireTime"`
|
||||
DeviceNo int64 `json:"deviceNo"`
|
||||
KickUtilTime int64 `json:"kickUtilTime"`
|
||||
Role string `json:"role"`
|
||||
Deleted int64 `json:"deleted"`
|
||||
CreateTime time.Time `json:"createTime"`
|
||||
UpdateTime time.Time `json:"updateTime"`
|
||||
LoginAt int64 `json:"loginAt"`
|
||||
ConAt int64 `json:"conAt"`
|
||||
Remark string `json:"remark"`
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
package bo
|
||||
|
||||
type Hysteria2ServerConfig struct {
|
||||
Listen *string `yaml:"listen,omitempty" json:"listen" validate:"required"`
|
||||
Obfs *serverConfigObfs `yaml:"obfs,omitempty" json:"obfs" validate:"omitempty"`
|
||||
TLS *serverConfigTLS `yaml:"tls,omitempty" json:"tls" validate:"omitempty"`
|
||||
ACME *serverConfigACME `yaml:"acme,omitempty" json:"acme" validate:"omitempty"`
|
||||
QUIC *serverConfigQUIC `yaml:"quic,omitempty" json:"quic" validate:"omitempty"`
|
||||
Bandwidth *serverConfigBandwidth `yaml:"bandwidth,omitempty" json:"bandwidth" validate:"omitempty"`
|
||||
IgnoreClientBandwidth *bool `yaml:"ignoreClientBandwidth,omitempty" json:"ignoreClientBandwidth" validate:"omitempty"`
|
||||
SpeedTest *bool `yaml:"speedTest,omitempty" json:"speedTest" validate:"omitempty"`
|
||||
DisableUDP *bool `yaml:"disableUDP,omitempty" json:"disableUDP" validate:"omitempty"`
|
||||
UDPIdleTimeout *string `yaml:"udpIdleTimeout,omitempty" json:"udpIdleTimeout" validate:"omitempty"`
|
||||
Auth *ServerConfigAuth `yaml:"auth,omitempty" json:"-" validate:"omitempty"`
|
||||
Resolver *serverConfigResolver `yaml:"resolver,omitempty" json:"resolver" validate:"omitempty"`
|
||||
Sniff *serverConfigSniff `yaml:"sniff,omitempty" json:"sniff" validate:"omitempty"`
|
||||
ACL *serverConfigACL `yaml:"acl,omitempty" json:"acl" validate:"omitempty"`
|
||||
Outbounds []serverConfigOutboundEntry `yaml:"outbounds,omitempty" json:"outbounds" validate:"omitempty"`
|
||||
TrafficStats *ServerConfigTrafficStats `yaml:"trafficStats,omitempty" json:"trafficStats" validate:"required"`
|
||||
Masquerade *serverConfigMasquerade `yaml:"masquerade,omitempty" json:"masquerade" validate:"omitempty"`
|
||||
}
|
||||
|
||||
type serverConfigObfsSalamander struct {
|
||||
Password *string `yaml:"password,omitempty" json:"password" validate:"required"`
|
||||
}
|
||||
|
||||
type serverConfigObfs struct {
|
||||
Type *string `yaml:"type,omitempty" json:"type" validate:"required"`
|
||||
Salamander *serverConfigObfsSalamander `yaml:"salamander,omitempty" json:"salamander" validate:"required"`
|
||||
}
|
||||
|
||||
type serverConfigTLS struct {
|
||||
Cert *string `yaml:"cert,omitempty" json:"cert" validate:"required"`
|
||||
Key *string `yaml:"key,omitempty" json:"key" validate:"required"`
|
||||
SNIGuard *string `yaml:"sniGuard,omitempty" json:"sniGuard" validate:"omitempty"`
|
||||
}
|
||||
|
||||
type serverConfigACME struct {
|
||||
// Common fields
|
||||
Domains []string `yaml:"domains,omitempty" json:"domains" validate:"required"`
|
||||
Email *string `yaml:"email,omitempty" json:"email" validate:"required"`
|
||||
CA *string `yaml:"ca,omitempty" json:"ca" validate:"required"`
|
||||
ListenHost *string `yaml:"listenHost,omitempty" json:"listenHost" validate:"required"`
|
||||
Dir *string `yaml:"dir,omitempty" json:"dir" validate:"required"`
|
||||
|
||||
// Type selection
|
||||
Type *string `yaml:"type,omitempty" json:"type" validate:"omitempty"`
|
||||
HTTP *serverConfigACMEHTTP `yaml:"http,omitempty" json:"http" validate:"omitempty"`
|
||||
TLS *serverConfigACMETLS `yaml:"tls,omitempty" json:"tls" validate:"omitempty"`
|
||||
DNS *serverConfigACMEDNS `yaml:"dns,omitempty" json:"dns" validate:"omitempty"`
|
||||
|
||||
// Legacy fields for backwards compatibility
|
||||
// Only applicable when Type is empty
|
||||
DisableHTTP *bool `yaml:"disableHTTP,omitempty" json:"disableHTTP" validate:"required"`
|
||||
DisableTLSALPN *bool `yaml:"disableTLSALPN,omitempty" json:"disableTLSALPN" validate:"required"`
|
||||
AltHTTPPort *int `yaml:"altHTTPPort,omitempty" json:"altHTTPPort" validate:"required"`
|
||||
AltTLSALPNPort *int `yaml:"altTLSALPNPort,omitempty" json:"altTLSALPNPort" validate:"required"`
|
||||
}
|
||||
|
||||
type serverConfigACMEHTTP struct {
|
||||
AltPort *int `yaml:"altPort,omitempty" json:"altPort" validate:"required"`
|
||||
}
|
||||
|
||||
type serverConfigACMETLS struct {
|
||||
AltPort *int `yaml:"altPort,omitempty" json:"altPort" validate:"required"`
|
||||
}
|
||||
|
||||
type serverConfigACMEDNS struct {
|
||||
Name *string `yaml:"name,omitempty" json:"name" validate:"required"`
|
||||
Config map[string]string `yaml:"config,omitempty" json:"config" validate:"required"`
|
||||
}
|
||||
|
||||
type serverConfigQUIC struct {
|
||||
InitStreamReceiveWindow *uint64 `yaml:"initStreamReceiveWindow,omitempty" json:"initStreamReceiveWindow" validate:"omitempty"`
|
||||
MaxStreamReceiveWindow *uint64 `yaml:"maxStreamReceiveWindow,omitempty" json:"maxStreamReceiveWindow" validate:"omitempty"`
|
||||
InitConnectionReceiveWindow *uint64 `yaml:"initConnReceiveWindow,omitempty" json:"initConnReceiveWindow" validate:"omitempty"`
|
||||
MaxConnectionReceiveWindow *uint64 `yaml:"maxConnReceiveWindow,omitempty" json:"maxConnReceiveWindow" validate:"omitempty"`
|
||||
MaxIdleTimeout *string `yaml:"maxIdleTimeout,omitempty" json:"maxIdleTimeout" validate:"omitempty"`
|
||||
MaxIncomingStreams *int64 `yaml:"maxIncomingStreams,omitempty" json:"maxIncomingStreams" validate:"omitempty"`
|
||||
DisablePathMTUDiscovery *bool `yaml:"disablePathMTUDiscovery,omitempty" json:"disablePathMTUDiscovery" validate:"omitempty"`
|
||||
}
|
||||
|
||||
type serverConfigBandwidth struct {
|
||||
Up *string `yaml:"up,omitempty" json:"up" validate:"required"`
|
||||
Down *string `yaml:"down,omitempty" json:"down" validate:"required"`
|
||||
}
|
||||
|
||||
type ServerConfigAuthHTTP struct {
|
||||
URL *string `yaml:"url,omitempty" json:"url" validate:"required"`
|
||||
Insecure *bool `yaml:"insecure,omitempty" json:"insecure" validate:"required"`
|
||||
}
|
||||
|
||||
type ServerConfigAuth struct {
|
||||
Type *string `yaml:"type,omitempty" json:"type" validate:"omitempty"`
|
||||
Password *string `yaml:"password,omitempty" json:"password" validate:"omitempty"`
|
||||
UserPass map[string]string `yaml:"userpass,omitempty" json:"userpass" validate:"omitempty"`
|
||||
HTTP *ServerConfigAuthHTTP `yaml:"http,omitempty" json:"http" validate:"omitempty"`
|
||||
Command *string `yaml:"command,omitempty" json:"command" validate:"omitempty"`
|
||||
}
|
||||
|
||||
type serverConfigResolverTCP struct {
|
||||
Addr *string `yaml:"addr,omitempty" json:"addr" validate:"required"`
|
||||
Timeout *string `yaml:"timeout,omitempty" json:"timeout" validate:"required"`
|
||||
}
|
||||
|
||||
type serverConfigResolverUDP struct {
|
||||
Addr *string `yaml:"addr,omitempty" json:"addr" validate:"required"`
|
||||
Timeout *string `yaml:"timeout,omitempty" json:"timeout" validate:"required"`
|
||||
}
|
||||
|
||||
type serverConfigResolverTLS struct {
|
||||
Addr *string `yaml:"addr,omitempty" json:"addr" validate:"required"`
|
||||
Timeout *string `yaml:"timeout,omitempty" json:"timeout" validate:"required"`
|
||||
SNI *string `yaml:"sni,omitempty" json:"sni" validate:"required"`
|
||||
Insecure *bool `yaml:"insecure,omitempty" json:"insecure" validate:"required"`
|
||||
}
|
||||
|
||||
type serverConfigResolverHTTPS struct {
|
||||
Addr *string `yaml:"addr,omitempty" json:"addr" validate:"required"`
|
||||
Timeout *string `yaml:"timeout,omitempty" json:"timeout" validate:"required"`
|
||||
SNI *string `yaml:"sni,omitempty" json:"sni" validate:"required"`
|
||||
Insecure *bool `yaml:"insecure,omitempty" json:"insecure" validate:"required"`
|
||||
}
|
||||
|
||||
type serverConfigResolver struct {
|
||||
Type *string `yaml:"type,omitempty" json:"type" validate:"omitempty"`
|
||||
TCP *serverConfigResolverTCP `yaml:"tcp,omitempty" json:"tcp" validate:"omitempty"`
|
||||
UDP *serverConfigResolverUDP `yaml:"udp,omitempty" json:"udp" validate:"omitempty"`
|
||||
TLS *serverConfigResolverTLS `yaml:"tls,omitempty" json:"tls" validate:"omitempty"`
|
||||
HTTPS *serverConfigResolverHTTPS `yaml:"https,omitempty" json:"https" validate:"omitempty"`
|
||||
}
|
||||
|
||||
type serverConfigSniff struct {
|
||||
Enable *bool `yaml:"enable,omitempty" json:"enable" validate:"required"`
|
||||
Timeout *string `yaml:"timeout,omitempty" json:"timeout" validate:"required"`
|
||||
RewriteDomain *bool `yaml:"rewriteDomain,omitempty" json:"rewriteDomain" validate:"required"`
|
||||
TCPPorts *string `yaml:"tcpPorts,omitempty" json:"tcpPorts" validate:"omitempty"`
|
||||
UDPPorts *string `yaml:"udpPorts,omitempty" json:"udpPorts" validate:"omitempty"`
|
||||
}
|
||||
|
||||
type serverConfigACL struct {
|
||||
File *string `yaml:"file,omitempty" json:"file" validate:"omitempty"`
|
||||
Inline []string `yaml:"inline,omitempty" json:"inline" validate:"omitempty"`
|
||||
GeoIP *string `yaml:"geoip,omitempty" json:"geoip" validate:"omitempty"`
|
||||
GeoSite *string `yaml:"geosite,omitempty" json:"geosite" validate:"omitempty"`
|
||||
GeoUpdateInterval *string `yaml:"geoUpdateInterval,omitempty" json:"geoUpdateInterval" validate:"omitempty"`
|
||||
}
|
||||
|
||||
type serverConfigOutboundDirect struct {
|
||||
Mode *string `yaml:"mode,omitempty" json:"mode" validate:"required"`
|
||||
BindIPv4 *string `yaml:"bindIPv4,omitempty" json:"bindIPv4" validate:"required"`
|
||||
BindIPv6 *string `yaml:"bindIPv6,omitempty" json:"bindIPv6" validate:"required"`
|
||||
BindDevice *string `yaml:"bindDevice,omitempty" json:"bindDevice" validate:"required"`
|
||||
FastOpen *bool `yaml:"fastOpen,omitempty" json:"fastOpen" validate:"required"`
|
||||
}
|
||||
|
||||
type serverConfigOutboundSOCKS5 struct {
|
||||
Addr *string `yaml:"addr,omitempty" json:"addr" validate:"required"`
|
||||
Username *string `yaml:"username,omitempty" json:"username" validate:"omitempty"`
|
||||
Password *string `yaml:"password,omitempty" json:"password" validate:"omitempty"`
|
||||
}
|
||||
|
||||
type serverConfigOutboundHTTP struct {
|
||||
URL *string `yaml:"url,omitempty" json:"url" validate:"required"`
|
||||
Insecure *bool `yaml:"insecure,omitempty" json:"insecure" validate:"required"`
|
||||
}
|
||||
|
||||
type serverConfigOutboundEntry struct {
|
||||
Name *string `yaml:"name,omitempty" json:"name" validate:"required"`
|
||||
Type *string `yaml:"type,omitempty" json:"type" validate:"omitempty"`
|
||||
Direct *serverConfigOutboundDirect `yaml:"direct,omitempty" json:"direct" validate:"omitempty"`
|
||||
SOCKS5 *serverConfigOutboundSOCKS5 `yaml:"socks5,omitempty" json:"socks5" validate:"omitempty"`
|
||||
HTTP *serverConfigOutboundHTTP `yaml:"http,omitempty" json:"http" validate:"omitempty"`
|
||||
}
|
||||
|
||||
type ServerConfigTrafficStats struct {
|
||||
Listen *string `yaml:"listen,omitempty" json:"listen" validate:"required"`
|
||||
Secret *string `yaml:"secret,omitempty" json:"-" validate:"omitempty"`
|
||||
}
|
||||
|
||||
type serverConfigMasqueradeFile struct {
|
||||
Dir *string `yaml:"dir,omitempty" json:"dir" validate:"required"`
|
||||
}
|
||||
|
||||
type serverConfigMasqueradeProxy struct {
|
||||
URL *string `yaml:"url,omitempty" json:"url" validate:"required"`
|
||||
RewriteHost *bool `yaml:"rewriteHost,omitempty" json:"rewriteHost" validate:"required"`
|
||||
Insecure *bool `yaml:"insecure,omitempty" json:"insecure" validate:"required"`
|
||||
}
|
||||
|
||||
type serverConfigMasqueradeString struct {
|
||||
Content *string `yaml:"content,omitempty" json:"content" validate:"required"`
|
||||
Headers map[string]string `yaml:"headers,omitempty" json:"headers" validate:"omitempty"`
|
||||
StatusCode *int `yaml:"statusCode,omitempty" json:"statusCode" validate:"omitempty"`
|
||||
}
|
||||
|
||||
type serverConfigMasquerade struct {
|
||||
Type *string `yaml:"type,omitempty" json:"type" validate:"omitempty"`
|
||||
File *serverConfigMasqueradeFile `yaml:"file,omitempty" json:"file" validate:"omitempty"`
|
||||
Proxy *serverConfigMasqueradeProxy `yaml:"proxy,omitempty" json:"proxy" validate:"omitempty"`
|
||||
String *serverConfigMasqueradeString `yaml:"string,omitempty" json:"string" validate:"omitempty"`
|
||||
ListenHTTP *string `yaml:"listenHTTP,omitempty" json:"listenHTTP" validate:"omitempty"`
|
||||
ListenHTTPS *string `yaml:"listenHTTPS,omitempty" json:"listenHTTPS" validate:"omitempty"`
|
||||
ForceHTTPS *bool `yaml:"forceHTTPS,omitempty" json:"forceHTTPS" validate:"omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package bo
|
||||
|
||||
type Hysteria2UserTraffic struct {
|
||||
Tx int64 `json:"tx"` // upload
|
||||
Rx int64 `json:"rx"` // download
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package bo
|
||||
|
||||
type Hysteria2 struct {
|
||||
Name string `yaml:"name"`
|
||||
Type string `yaml:"type"`
|
||||
Server string `yaml:"server"`
|
||||
Port string `yaml:"port"`
|
||||
Ports string `yaml:"ports,omitempty"`
|
||||
Password string `yaml:"password"`
|
||||
Up string `yaml:"up,omitempty"`
|
||||
Down string `yaml:"down,omitempty"`
|
||||
Obfs string `yaml:"obfs,omitempty"`
|
||||
ObfsPassword string `yaml:"obfs-password,omitempty"`
|
||||
Sni string `yaml:"sni,omitempty"`
|
||||
SkipCertVerify bool `yaml:"skip-cert-verify,omitempty"`
|
||||
}
|
||||
|
||||
type ProxyGroup struct {
|
||||
Name string `yaml:"name"`
|
||||
Type string `yaml:"type"`
|
||||
Proxies []string `yaml:"proxies"`
|
||||
}
|
||||
|
||||
type ClashConfig struct {
|
||||
Proxies []interface{} `yaml:"proxies"`
|
||||
ProxyGroups []ProxyGroup `yaml:"proxy-groups"`
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package constant
|
||||
|
||||
const (
|
||||
Shadowrocket = "shadowrocket"
|
||||
Clash = "clash"
|
||||
V2rayN = "v2rayn"
|
||||
NekoBox = "nekobox"
|
||||
)
|
||||
@@ -0,0 +1,9 @@
|
||||
package constant
|
||||
|
||||
const (
|
||||
CodeSuccess int = 20000
|
||||
CodeSysError int = 50000
|
||||
CodeUnauthorizedError int = 50401
|
||||
CodeForbiddenError int = 50403
|
||||
CodeInvalidError int = 50001
|
||||
)
|
||||
@@ -0,0 +1,16 @@
|
||||
package constant
|
||||
|
||||
const (
|
||||
HUIWebPort = "H_UI_WEB_PORT"
|
||||
HUIWebContext = "H_UI_WEB_CONTEXT"
|
||||
HUICrtPath = "H_UI_CRT_PATH"
|
||||
HUIKeyPath = "H_UI_KEY_PATH"
|
||||
JwtSecret = "JWT_SECRET"
|
||||
Hysteria2Enable = "HYSTERIA2_ENABLE"
|
||||
Hysteria2Config = "HYSTERIA2_CONFIG"
|
||||
Hysteria2TrafficTime = "HYSTERIA2_TRAFFIC_TIME"
|
||||
Hysteria2ConfigRemark = "HYSTERIA2_CONFIG_REMARK"
|
||||
Hysteria2ConfigPortHopping = "HYSTERIA2_CONFIG_PORT_HOPPING"
|
||||
ResetTrafficCron = "RESET_TRAFFIC_CRON"
|
||||
ClashExtension = "CLASH_EXTENSION"
|
||||
)
|
||||
@@ -0,0 +1,14 @@
|
||||
package constant
|
||||
|
||||
const (
|
||||
SysError string = "system error"
|
||||
UnauthorizedError string = "unauthorized"
|
||||
ForbiddenError string = "permission denied"
|
||||
InvalidError string = "invalid"
|
||||
|
||||
IllegalTokenError string = "authentication failed"
|
||||
TokenExpiredError string = "token expired"
|
||||
|
||||
WrongPassword string = "wrong password"
|
||||
ConfigNotExist string = "config not exist"
|
||||
)
|
||||
@@ -0,0 +1,20 @@
|
||||
package constant
|
||||
|
||||
const (
|
||||
LogDir = "logs/"
|
||||
SqliteDBDir = "data/"
|
||||
BinDir = "bin/"
|
||||
ExportPathDir = "export/"
|
||||
|
||||
SqliteDBPath = "data/h_ui.db"
|
||||
|
||||
Hysteria2ConfigPath = "/etc/hysteria/config.yaml"
|
||||
Hysteria2BinPath = "/usr/local/bin/hysteria"
|
||||
|
||||
SystemLogPath = "logs/hy2xs-admin.log"
|
||||
Hysteria2LogPath = "logs/hysteria2.log"
|
||||
|
||||
TokenType = "Bearer"
|
||||
|
||||
Version = "v0.0.22"
|
||||
)
|
||||
@@ -0,0 +1,36 @@
|
||||
package dto
|
||||
|
||||
type AccountPageDto struct {
|
||||
BaseDto
|
||||
Username *string `json:"username" form:"username" validate:"omitempty,min=1,max=32"`
|
||||
Deleted *int64 `json:"deleted" form:"deleted" validate:"omitempty,oneof=0 1"`
|
||||
Remark *string `json:"remark" form:"remark" validate:"omitempty,min=0,max=32"`
|
||||
}
|
||||
|
||||
type LoginDto struct {
|
||||
Username *string `json:"username" form:"username" validate:"required,min=6,max=32,validateStr"`
|
||||
Pass *string `json:"pass" form:"pass" validate:"required,min=6,max=32,validateStr"`
|
||||
}
|
||||
|
||||
type AccountSaveDto struct {
|
||||
Username *string `json:"username" form:"username" validate:"required,min=6,max=32,validateStr"`
|
||||
Pass *string `json:"pass" form:"pass" validate:"required,min=6,max=32,validateStr"`
|
||||
ConPass *string `json:"conPass" form:"conPass" validate:"required,min=6,max=32,validateStr"`
|
||||
Quota *int64 `json:"quota" form:"quota" validate:"required,min=-1"`
|
||||
ExpireTime *int64 `json:"expireTime" form:"expireTime" validate:"required,min=0"`
|
||||
DeviceNo *int64 `json:"deviceNo" form:"deviceNo" validate:"required,min=1"`
|
||||
Deleted *int64 `json:"deleted" form:"deleted" validate:"required,oneof=0 1"`
|
||||
Remark *string `json:"remark" form:"remark" validate:"omitempty,min=0,max=32"`
|
||||
}
|
||||
|
||||
type AccountUpdateDto struct {
|
||||
IdDto
|
||||
Username *string `json:"username" form:"username" validate:"omitempty,min=6,max=32,validateStr"`
|
||||
Pass *string `json:"pass" form:"pass" validate:"omitempty,min=6,max=32,validateStr"`
|
||||
ConPass *string `json:"conPass" form:"conPass" validate:"omitempty,min=6,max=32,validateStr"`
|
||||
Quota *int64 `json:"quota" form:"quota" validate:"omitempty,min=-1"`
|
||||
ExpireTime *int64 `json:"expireTime" form:"expireTime" validate:"omitempty,min=0"`
|
||||
DeviceNo *int64 `json:"deviceNo" form:"deviceNo" validate:"omitempty,min=1"`
|
||||
Deleted *int64 `json:"deleted" form:"deleted" validate:"omitempty,oneof=0 1"`
|
||||
Remark *string `json:"remark" form:"remark" validate:"omitempty,min=0,max=32"`
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package dto
|
||||
|
||||
type ConfigDto struct {
|
||||
Key *string `json:"key" form:"key" validate:"required,min=1,max=128"`
|
||||
}
|
||||
|
||||
type ConfigsDto struct {
|
||||
Keys []string `json:"keys" form:"keys" validate:"required"`
|
||||
}
|
||||
|
||||
type ConfigUpdateDto struct {
|
||||
Key *string `json:"key" form:"key" validate:"required,min=1,max=128"`
|
||||
Value *string `json:"value" form:"value" validate:"required,min=0,max=128"`
|
||||
}
|
||||
|
||||
type ConfigsUpdateDto struct {
|
||||
ConfigUpdateDtos []ConfigUpdateDto `json:"configUpdateDtos" form:"configUpdateDtos" validate:"required"`
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package dto
|
||||
|
||||
type BaseDto struct {
|
||||
PageNum *int64 `json:"pageNum" form:"pageNum" validate:"required,gt=0"` // 页号
|
||||
PageSize *int64 `json:"pageSize" form:"pageSize" validate:"required,gt=0"` // 页大小
|
||||
StartTime *int64 `json:"startTime" form:"startTime" validate:"omitempty,gt=0"` // 开始时间
|
||||
EndTime *int64 `json:"endTime" form:"endTime" validate:"omitempty,gt=0"` // 结束时间
|
||||
}
|
||||
|
||||
type IdDto struct {
|
||||
Id *int64 `json:"id" form:"id" validate:"required,gt=0"` // 主键
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package dto
|
||||
|
||||
type Hysteria2AuthDto struct {
|
||||
Addr *string `json:"addr" form:"addr" validate:"required"`
|
||||
Auth *string `json:"auth" form:"auth" validate:"required"`
|
||||
Tx *string `json:"tx" form:"tx" validate:"required"`
|
||||
}
|
||||
|
||||
type Hysteria2KickDto struct {
|
||||
Ids []int64 `json:"ids" form:"ids" validate:"required"`
|
||||
KickUtilTime *int64 `json:"kickUtilTime" form:"kickUtilTime" validate:"required"` // 解禁时间
|
||||
}
|
||||
|
||||
type Hysteria2VersionDto struct {
|
||||
Version *string `json:"version" form:"version" validate:"required,min=1,max=10"`
|
||||
}
|
||||
|
||||
type Hysteria2SubscribeUrlDto struct {
|
||||
AccountId *int64 `json:"accountId" form:"accountId" validate:"required,gt=0"`
|
||||
Protocol *string `json:"protocol" form:"protocol" validate:"required,min=1,max=8"`
|
||||
Host *string `json:"host" form:"host" validate:"required,min=1,max=301"`
|
||||
}
|
||||
|
||||
type Hysteria2UrlDto struct {
|
||||
AccountId *int64 `json:"accountId" form:"accountId" validate:"required,gt=0"`
|
||||
Hostname *string `json:"hostname" form:"hostname" validate:"required,min=1,max=255"`
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package dto
|
||||
|
||||
type LogDto struct {
|
||||
NumLine *int `json:"numLine" form:"numLine" validate:"omitempty,min=1,max=300"`
|
||||
}
|
||||
|
||||
type LogExportDto struct {
|
||||
Option *int `json:"option" form:"option" validate:"required,oneof=0 1"`
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package dto
|
||||
|
||||
type ServerDto struct {
|
||||
Port *int64 `json:"port" form:"port" validate:"required,min=1,max=65535"`
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package entity
|
||||
|
||||
type Account struct {
|
||||
Username *string `gorm:"column:username;default:''" json:"username"`
|
||||
Pass *string `gorm:"column:pass;default:''" json:"pass"`
|
||||
ConPass *string `gorm:"column:con_pass;default:''" json:"conPass"`
|
||||
Quota *int64 `gorm:"column:quota;default:0" json:"quota"`
|
||||
Download *int64 `gorm:"column:download;default:0" json:"download"`
|
||||
Upload *int64 `gorm:"column:upload;default:0" json:"upload"`
|
||||
ExpireTime *int64 `gorm:"column:expire_time;default:0" json:"expireTime"`
|
||||
KickUtilTime *int64 `gorm:"column:kick_util_time;default:0" json:"kickUtilTime"`
|
||||
DeviceNo *int64 `gorm:"column:device_no;default:3" json:"deviceNo"`
|
||||
Role *string `gorm:"column:role;default:'user'" json:"role"`
|
||||
Deleted *int64 `gorm:"column:deleted;default:0" json:"deleted"`
|
||||
BaseEntity `gorm:"embedded"`
|
||||
|
||||
LoginAt *int64 `gorm:"column:login_at;default:0" json:"loginAt"`
|
||||
ConAt *int64 `gorm:"column:con_at;default:0" json:"conAt"`
|
||||
Remark *string `gorm:"column:remark;default:''" json:"remark"`
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package entity
|
||||
|
||||
type Config struct {
|
||||
Key *string `gorm:"column:key;default:''" json:"key"`
|
||||
Value *string `gorm:"column:value;default:''" json:"value"`
|
||||
Remark *string `gorm:"column:remark;default:''" json:"remark"`
|
||||
BaseEntity `gorm:"embedded"`
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package entity
|
||||
|
||||
import "time"
|
||||
|
||||
type BaseEntity struct {
|
||||
Id *int64 `gorm:"column:id;primaryKey" json:"id"`
|
||||
CreateTime *time.Time `gorm:"column:create_time;default:null" json:"createTime"`
|
||||
UpdateTime *time.Time `gorm:"column:update_time;default:null" json:"updateTime"`
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package vo
|
||||
|
||||
type AccountVo struct {
|
||||
BaseVo
|
||||
Username string `json:"username"`
|
||||
Quota int64 `json:"quota"`
|
||||
Download int64 `json:"download"`
|
||||
Upload int64 `json:"upload"`
|
||||
ExpireTime int64 `json:"expireTime"`
|
||||
KickUtilTime int64 `json:"kickUtilTime"` // Offline remaining time
|
||||
DeviceNo int64 `json:"deviceNo"` // Limit the number of devices
|
||||
Role string `json:"role"`
|
||||
Deleted int64 `json:"deleted"`
|
||||
|
||||
Online bool `json:"online"` // online status
|
||||
Device int64 `json:"device"` // Number of online devices
|
||||
|
||||
LoginAt int64 `json:"loginAt"`
|
||||
ConAt int64 `json:"conAt"`
|
||||
Remark string `json:"remark"`
|
||||
}
|
||||
type AccountPageVo struct {
|
||||
AccountVos []AccountVo `json:"records"`
|
||||
Total int64 `json:"total"`
|
||||
}
|
||||
|
||||
type AccountInfoVo struct {
|
||||
Id int64 `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Roles []string `json:"roles"`
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package vo
|
||||
|
||||
type ConfigVo struct {
|
||||
Key string `json:"key"`
|
||||
Value string `json:"value"`
|
||||
Remark string `json:"remark"`
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package vo
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type hysteria2Result struct {
|
||||
Ok bool `json:"ok"`
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
func Hysteria2AuthSuccess(id string, c *gin.Context) {
|
||||
c.JSON(http.StatusOK, hysteria2Result{
|
||||
Ok: true,
|
||||
Id: id,
|
||||
})
|
||||
}
|
||||
|
||||
func Hysteria2AuthFail(id string, c *gin.Context) {
|
||||
c.JSON(http.StatusOK, hysteria2Result{
|
||||
Ok: false,
|
||||
Id: id,
|
||||
})
|
||||
}
|
||||
|
||||
type Hysteria2SubscribeVo struct {
|
||||
Url string `json:"url"`
|
||||
QrCode []byte `json:"qrCode"`
|
||||
}
|
||||
|
||||
type Hysteria2UrlVo struct {
|
||||
Url string `json:"url"`
|
||||
QrCode []byte `json:"qrCode"`
|
||||
}
|
||||
|
||||
type Hysteria2AcmePathVo struct {
|
||||
CrtPath string `json:"crtPath"`
|
||||
KeyPath string `json:"keyPath"`
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package vo
|
||||
|
||||
type JwtVo struct {
|
||||
TokenType string `json:"tokenType"`
|
||||
AccessToken string `json:"accessToken"`
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package vo
|
||||
|
||||
type LogSystemPage[T LogSystemVo | LogHysteria2Vo] struct {
|
||||
LogSystemVos []T `json:"records"`
|
||||
Total int64 `json:"total"`
|
||||
}
|
||||
|
||||
type LogSystemVo struct {
|
||||
ClientIP string `json:"clientIp"`
|
||||
LatencyTime int64 `json:"latencyTime"`
|
||||
Level string `json:"level"`
|
||||
Msg string `json:"msg"`
|
||||
ReqMethod string `json:"reqMethod"`
|
||||
ReqUri string `json:"reqUri"`
|
||||
StatusCode int64 `json:"statusCode"`
|
||||
Time string `json:"time"`
|
||||
}
|
||||
|
||||
type LogHysteria2Vo struct {
|
||||
Level string `json:"level"`
|
||||
Msg string `json:"msg"`
|
||||
Time string `json:"time"`
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package vo
|
||||
|
||||
type SystemMonitorVo struct {
|
||||
HUIVersion string `json:"huiVersion"`
|
||||
CpuPercent float64 `json:"cpuPercent"`
|
||||
MemPercent float64 `json:"memPercent"`
|
||||
DiskPercent float64 `json:"diskPercent"`
|
||||
}
|
||||
|
||||
type Hysteria2MonitorVo struct {
|
||||
UserTotal int64 `json:"userTotal"` // 在线用户数
|
||||
DeviceTotal int64 `json:"deviceTotal"` // 在线设备数
|
||||
Version string `json:"version"` // 版本
|
||||
Running bool `json:"running"` // 运行状态
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package vo
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"hy2xs-admin/model/constant"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type result struct {
|
||||
Code int `json:"code"`
|
||||
Type string `json:"type"`
|
||||
Message string `json:"message"`
|
||||
Data interface{} `json:"data"`
|
||||
}
|
||||
|
||||
const (
|
||||
TypeSuccess = "ok"
|
||||
TypeError = "no"
|
||||
)
|
||||
|
||||
func Success(data interface{}, c *gin.Context) {
|
||||
c.JSON(http.StatusOK, result{
|
||||
Code: constant.CodeSuccess,
|
||||
Type: TypeSuccess,
|
||||
Data: data,
|
||||
})
|
||||
}
|
||||
|
||||
func Fail(message string, c *gin.Context) {
|
||||
var code int
|
||||
if constant.UnauthorizedError == message {
|
||||
code = constant.CodeUnauthorizedError
|
||||
} else if constant.ForbiddenError == message {
|
||||
code = constant.CodeForbiddenError
|
||||
} else if constant.InvalidError == message {
|
||||
code = constant.CodeInvalidError
|
||||
} else {
|
||||
code = constant.CodeSysError
|
||||
}
|
||||
c.JSON(http.StatusOK, result{
|
||||
Code: code,
|
||||
Type: TypeError,
|
||||
Message: message,
|
||||
Data: nil,
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package vo
|
||||
|
||||
import "time"
|
||||
|
||||
type BaseVo struct {
|
||||
Id int64 `json:"id"`
|
||||
CreateTime time.Time `json:"createTime"`
|
||||
}
|
||||
Reference in New Issue
Block a user