From 40c65a86fc57fe1841fc95a6e851deb69b177ae3 Mon Sep 17 00:00:00 2001 From: Senis John Date: Wed, 28 Dec 2022 10:36:29 +0800 Subject: [PATCH] update: reformat newV2board serverConfig structure --- api/newV2board/model.go | 13 ++++++++++--- service/controller/userbuilder.go | 4 ++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/api/newV2board/model.go b/api/newV2board/model.go index e110c5b..ae41400 100644 --- a/api/newV2board/model.go +++ b/api/newV2board/model.go @@ -5,14 +5,19 @@ import ( ) type serverConfig struct { + shadowsocks + v2ray + trojan + ServerPort int `json:"server_port"` BaseConfig struct { PushInterval int `json:"push_interval"` PullInterval int `json:"pull_interval"` } `json:"base_config"` Routes []route `json:"routes"` +} - // shadowsocks +type shadowsocks struct { Cipher string `json:"cipher"` Obfs string `json:"obfs"` ObfsSettings struct { @@ -20,8 +25,9 @@ type serverConfig struct { Host string `json:"host"` } `json:"obfs_settings"` ServerKey string `json:"server_key"` +} - // v2ray +type v2ray struct { Network string `json:"network"` NetworkSettings struct { Path string `json:"path"` @@ -29,8 +35,9 @@ type serverConfig struct { ServiceName string `json:"serviceName"` } `json:"networkSettings"` Tls int `json:"tls"` +} - // trojan +type trojan struct { Host string `json:"host"` ServerName string `json:"server_name"` } diff --git a/service/controller/userbuilder.go b/service/controller/userbuilder.go index 5e987f2..f6c25b9 100644 --- a/service/controller/userbuilder.go +++ b/service/controller/userbuilder.go @@ -171,13 +171,13 @@ func (c *Controller) checkShadowsocksPassword(password string, method string) (s if strings.Contains(c.panelType, "V2board") { var userKey string if len(password) < 16 { - return "", fmt.Errorf("shadowsocks2022 key's length must be greater than 16") + return "", newError("shadowsocks2022 key's length must be greater than 16").AtWarning() } if method == "2022-blake3-aes-128-gcm" { userKey = password[:16] } else { if len(password) < 32 { - return "", fmt.Errorf("shadowsocks2022 key's length must be greater than 32") + return "", newError("shadowsocks2022 key's length must be greater than 32").AtWarning() } userKey = password[:32] }