Documentation
¶
Index ¶
- Variables
- type Auth
- type AuthApi
- type ClashConfig
- type ClashDNS
- type ClashFallbackFilter
- type ClashProxies
- type ClashProxyGroups
- type CloudAuth
- type Config
- type ConfigApi
- type ConfigList
- type Provider
- type ProviderApi
- type ProviderCreateApi
- type ProviderInfo
- type ProviderList
- type Proxy
- type ProxyApi
- type ProxyCreateApi
- type ProxyList
- type Regions
- type Tunnel
- type TunnelApi
- type TunnelConfig
- type TunnelCreateApi
- type TunnelCreateApiList
- type TunnelList
Constants ¶
This section is empty.
Variables ¶
View Source
var BindingRules = []string{}/* 662 elements not displayed */
View Source
var DefaultAuth = []Auth{ { Type: enum.AuthAdmin, Username: "seamoon", Password: "2575a6f37310dd27e884a0305a2dd210", }, }
View Source
var DefaultConfig = []Config{
{
Key: "control_addr",
Value: "0.0.0.0",
},
{
Key: "control_port",
Value: "7777",
},
{
Key: "control_log",
Value: "seamoon.log",
},
{
Key: "auto_start",
Value: "true",
},
{
Key: "auto_sync",
Value: "true",
},
}
View Source
var ModelList = make([]interface{}, 0)
Functions ¶
This section is empty.
Types ¶
type ClashConfig ¶
type ClashConfig struct {
MixedPort int `yaml:"mixed-port,omitempty"`
AllowLan bool `yaml:"allow-lan,omitempty"`
Mode string `yaml:"mode,omitempty"`
LogLevel string `yaml:"log-level,omitempty"`
ExternalController string `yaml:"external-controller,omitempty"`
Secret string `yaml:"secret,omitempty"`
DNS ClashDNS `yaml:"dns,omitempty"`
Proxies []ClashProxies `yaml:"proxies,omitempty"`
ProxyGroups []ClashProxyGroups `yaml:"proxy-groups,omitempty"`
Rules []string `yaml:"rules,omitempty"`
}
type ClashDNS ¶
type ClashDNS struct {
Enable bool `yaml:"enable,omitempty"`
Ipv6 bool `yaml:"ipv6,omitempty"`
Listen string `yaml:"listen,omitempty"`
EnhancedMode string `yaml:"enhanced-mode,omitempty"`
FakeIPFilter []string `yaml:"fake-ip-filter,omitempty"`
Nameserver []string `yaml:"nameserver,omitempty"`
Fallback []string `yaml:"fallback,omitempty"`
FallbackFilter ClashFallbackFilter `yaml:"fallback-filter,omitempty"`
}
type ClashFallbackFilter ¶
type ClashProxies ¶
type ClashProxies struct {
Name string `yaml:"name"`
Type string `yaml:"type"`
Server string `yaml:"server"`
Port int `yaml:"port"`
UUID string `yaml:"uuid"`
AlterId int `yaml:"alterId"`
TLS bool `yaml:"tls"`
SkipCertVerify bool `yaml:"skip-cert-verify,omitempty"`
NetWork string `yaml:"network,omitempty"`
WsOpts struct {
Path string `yaml:"path,omitempty"`
} `yaml:"ws-opts"`
Cipher string `yaml:"cipher,omitempty"`
Password string `yaml:"password,omitempty"`
Protocol string `yaml:"protocol,omitempty"`
ProtocolParam string `yaml:"protocol-param,omitempty"`
Obfs string `yaml:"obfs,omitempty"`
ObfsParam string `yaml:"obfs-param,omitempty"`
UDP bool `yaml:"udp,omitempty"`
}
type ClashProxyGroups ¶
type ConfigApi ¶
type ConfigApi struct {
// 为了 web 方便, 直接转化成对应的 key 了
ControlAddr string `json:"control_addr"`
ControlPort string `json:"control_port"`
ControlLog string `json:"control_log"`
AutoStart string `json:"auto_start"`
AutoSync string `json:"auto_sync"`
Version string `json:"version"`
}
ConfigApi 对外暴露接口
func (*ConfigApi) ToModel ¶
func (c *ConfigApi) ToModel() ConfigList
type ConfigList ¶
type ConfigList []*Config
func (ConfigList) ToApi ¶
func (cl ConfigList) ToApi() *ConfigApi
type Provider ¶
type Provider struct {
gorm.Model
// 元信息
Name *string `gorm:"not null"`
Desc *string `gorm:"not null"`
Regions Regions `gorm:"not null"`
Type *enum.ProviderType `gorm:"not null"`
Status *enum.ProviderStatus `gorm:"not null"`
StatusMessage *string `gorm:"not null"`
MaxLimit *int `gorm:"not null"`
Info *ProviderInfo `gorm:"embedded"`
CloudAuth *CloudAuth `gorm:"embedded"`
// 连表
Tunnels []Tunnel `gorm:"foreignKey:ProviderId;references:ID"`
}
func (Provider) ToApi ¶
func (p Provider) ToApi() *ProviderApi
type ProviderApi ¶
type ProviderApi struct {
ID uint `json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Name *string `json:"name"`
Desc *string `json:"desc"`
Type *enum.ProviderType `json:"type"`
Regions Regions `json:"regions"`
// 账户信息
Info *ProviderInfo `json:"info"`
Status *enum.ProviderStatus `json:"status"`
StatusMessage *string `json:"status_message"`
Count *int `json:"count"`
MaxLimit *int `json:"max_limit"`
}
ProviderApi api 不展示敏感的账户数据
type ProviderCreateApi ¶
type ProviderCreateApi struct {
ID uint `json:"id"`
Name *string `json:"name"`
Regions Regions `json:"regions"`
Desc *string `json:"desc"`
Status *enum.ProviderStatus `json:"status"`
Type *enum.ProviderType `json:"type"`
// 认证信息
CloudAuth *CloudAuth `json:"cloud_auth"`
}
ProviderCreateApi api 用于创建时接受数据的模型
func (ProviderCreateApi) ToModel ¶
func (pa ProviderCreateApi) ToModel(full bool) *Provider
type ProviderInfo ¶
type ProviderList ¶
type ProviderList []*Provider
func (ProviderList) ToApi ¶
func (pl ProviderList) ToApi() []*ProviderApi
type Proxy ¶
type ProxyApi ¶
type ProxyApi struct {
ID uint `json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Name *string `json:"name"`
Type *enum.ProxyType `json:"type"`
Status *enum.ProxyStatus `json:"status"`
StatusMessage *string `json:"status_message"`
Conn *int `json:"conn"`
SpeedUp *float64 `json:"speed_up"`
SpeedDown *float64 `json:"speed_down"`
Lag *int64 `json:"lag"`
InBound *int64 `json:"in_bound"`
OutBound *int64 `json:"out_bound"`
ListenAddr *string `json:"listen_address"`
ListenPort *string `json:"listen_port"`
AllowUDP *bool `json:"allow_udp"`
}
type ProxyCreateApi ¶
type ProxyCreateApi struct {
ID uint `json:"id"`
Name *string `json:"name"`
Type *enum.ProxyType `json:"type"`
ListenAddr *string `json:"listen_address"`
ListenPort *string `json:"listen_port"`
AllowUDP *bool `json:"allow_udp"`
Status *enum.ProxyStatus `json:"status"`
StatusMessage *string `json:"status_message"`
TunnelID uint `json:"tunnel_id"`
TunnelCreateApi *TunnelCreateApi `json:"tunnel_create_api"`
}
func (ProxyCreateApi) ToModel ¶
func (pa ProxyCreateApi) ToModel(full bool) *Proxy
type Regions ¶
type Regions []string
Regions gorm 不支持 []string 这种类型,因此需要自定义一个字段类型实现 text <-> jsonString 的转换 这里两个方法一个指针一个非指针是不能动的。。。不知道为什么,动了就炸。
type Tunnel ¶
type Tunnel struct {
gorm.Model
ProviderId uint
UniqID *string // 唯一性ID,用于 sync 同步时识别出唯一函数与隧道关系
Name *string // 隧道名称,建议英文
Addr *string // 服务地址
Port *int32 // 服务端口
Type *enum.TunnelType // 隧道协议类型
Status *enum.TunnelStatus // 隧道状态
StatusMessage *string // 隧道状态原因,用于展示具体的异常详情
Config *TunnelConfig `gorm:"embedded"`
// 连表查询
Proxies []Proxy `gorm:"foreignKey:TunnelID;references:ID"`
}
Tunnel 表示着实际部署的一个函数节点
type TunnelApi ¶
type TunnelApi struct {
ProviderId uint `json:"provider_id"`
ProviderType *enum.ProviderType `json:"provider_type"`
ID uint `json:"id"`
UniqID *string `json:"uniq_id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Name *string `json:"name"`
Addr *string `json:"address"`
Port *int32 `json:"port"`
Type *enum.TunnelType `json:"type"`
Status *enum.TunnelStatus `json:"status"`
StatusMessage *string `json:"status_message"`
Config *TunnelConfig `json:"tunnel_config"`
}
type TunnelConfig ¶
type TunnelConfig struct {
// 函数配置
Region string `json:"region"` // 一个隧道只能是一个区域
CPU float32 `json:"cpu"` // CPU 资源
Memory int32 `json:"memory"` // 内存资源
Instance int32 `json:"instance"` // 最大实例处理数
FcAuthType enum.AuthType `json:"fc_auth_type"` // 函数认证方式
SSRCrypt string `json:"ssr_crypt"` // ssr 加密方式
SSRPass string `json:"ssr_pass"` // ssr 密码
V2rayUid string `json:"v2ray_uid"` // v2ray_uid
TLS bool `json:"tls"` // 是否开启 TLS 传输, 开启后自动使用 wss 协议
Tor bool `json:"tor"` // 是否开启 Tor 转发
}
type TunnelCreateApi ¶
type TunnelCreateApi struct {
ID uint `json:"id"`
ProviderId uint `json:"provider_id"`
UniqID *string `json:"uniq_id"`
Name *string `json:"name"`
Port *int32 `json:"port"`
Type *enum.TunnelType `json:"type"`
Status *enum.TunnelStatus `json:"status"`
StatusMessage *string `json:"status_message"`
Addr *string `json:"address"`
Config *TunnelConfig `json:"tunnel_config"`
}
func NewTunnelCreateApi ¶
func NewTunnelCreateApi() *TunnelCreateApi
func (TunnelCreateApi) ToModel ¶
func (ta TunnelCreateApi) ToModel(full bool) *Tunnel
type TunnelCreateApiList ¶
type TunnelCreateApiList []*TunnelCreateApi
type TunnelList ¶
type TunnelList []*Tunnel
func (TunnelList) ToApi ¶
func (tl TunnelList) ToApi(extra ...func(api interface{})) []*TunnelApi
func (TunnelList) ToConfig ¶
func (tl TunnelList) ToConfig(p string) []byte
Click to show internal directories.
Click to hide internal directories.