Skip to content

Commit

Permalink
update: reformat newV2board serverConfig structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Septrum101 committed Dec 28, 2022
1 parent b5a8f44 commit 40c65a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 10 additions & 3 deletions api/newV2board/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,39 @@ 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 {
Path string `json:"path"`
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"`
Headers *json.RawMessage `json:"headers"`
ServiceName string `json:"serviceName"`
} `json:"networkSettings"`
Tls int `json:"tls"`
}

// trojan
type trojan struct {
Host string `json:"host"`
ServerName string `json:"server_name"`
}
Expand Down
4 changes: 2 additions & 2 deletions service/controller/userbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
Expand Down

0 comments on commit 40c65a8

Please sign in to comment.