This commit is contained in:
coward
2024-07-05 14:41:35 +08:00
commit 1f7f57ec9f
70 changed files with 4923 additions and 0 deletions

17
global/client/client.go Normal file
View File

@@ -0,0 +1,17 @@
package client
import (
"github.com/cowardmrx/go_aliyun_oss"
"github.com/go-resty/resty/v2"
"github.com/redis/go-redis/v9"
"golang.zx2c4.com/wireguard/wgctrl"
"gorm.io/gorm"
)
var (
WireguardClient *wgctrl.Client // wireguard客户端
DB *gorm.DB // 数据库客户端
Redis *redis.Client // redis客户端
HttpClient *resty.Client // http客户端
OSS *go_aliyun_oss.AliOssClient // oss客户端
)

View File

@@ -0,0 +1,22 @@
package constant
// Status 启用禁用
type Status int
const (
Disabled Status = iota
Enabled
)
var StatusMap = map[Status]string{
Disabled: "禁用",
Enabled: "启用",
}
func (u Status) String() string {
if v, ok := StatusMap[u]; ok {
return v
}
return "未知类型"
}

View File

@@ -0,0 +1,6 @@
package constant
const (
Captcha = "captcha:"
UserToken = "token:"
)

View File

@@ -0,0 +1,22 @@
package constant
// UserType 用户类型
type UserType int
const (
NormalAdmin UserType = iota
SuperAdmin
)
var UserTypeMap = map[UserType]string{
NormalAdmin: "普通管理员",
SuperAdmin: "超级管理员",
}
func (u UserType) String() string {
if v, ok := UserTypeMap[u]; ok {
return v
}
return "未知类型"
}

View File

@@ -0,0 +1,7 @@
package constant
const (
DefaultPostUpScript = "iptables -A FORWARD -i wg0 -j ACCEPT; iptables -A FORWARD -o wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE"
DefaultPostDownScript = "iptables -D FORWARD -i wg0 -j ACCEPT; iptables -D FORWARD -o wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE"
DefaultPreDownScript = ""
)