node type to lower

This commit is contained in:
yuzuki999 2023-05-19 11:27:08 +08:00
parent 69eec50f81
commit 3f6f80b5e5
3 changed files with 10 additions and 9 deletions

View File

@ -49,14 +49,15 @@ func New(c *conf.ApiConfig) (*Client, error) {
}) })
client.SetBaseURL(c.APIHost) client.SetBaseURL(c.APIHost)
// Check node type // Check node type
if c.NodeType != "V2ray" && c.NodeType = strings.ToLower(c.NodeType)
c.NodeType != "Trojan" && if c.NodeType != "v2ray" &&
c.NodeType != "Shadowsocks" { c.NodeType != "trojan" &&
c.NodeType != "shadowsocks" {
return nil, fmt.Errorf("unsupported Node type: %s", c.NodeType) return nil, fmt.Errorf("unsupported Node type: %s", c.NodeType)
} }
// Create Key for each requests // Create Key for each requests
client.SetQueryParams(map[string]string{ client.SetQueryParams(map[string]string{
"node_type": strings.ToLower(c.NodeType), "node_type": c.NodeType,
"node_id": strconv.Itoa(c.NodeID), "node_id": strconv.Itoa(c.NodeID),
"token": c.Key, "token": c.Key,
}) })

View File

@ -23,11 +23,11 @@ func buildInbound(config *conf.ControllerConfig, nodeInfo *panel.NodeInfo, tag s
inbound.StreamSetting = &coreConf.StreamConfig{Network: &t} inbound.StreamSetting = &coreConf.StreamConfig{Network: &t}
var err error var err error
switch nodeInfo.NodeType { switch nodeInfo.NodeType {
case "V2ray": case "v2ray":
err = buildV2ray(config, nodeInfo, inbound) err = buildV2ray(config, nodeInfo, inbound)
case "Trojan": case "trojan":
err = buildTrojan(config, nodeInfo, inbound) err = buildTrojan(config, nodeInfo, inbound)
case "Shadowsocks": case "shadowsocks":
err = buildShadowsocks(config, nodeInfo, inbound) err = buildShadowsocks(config, nodeInfo, inbound)
default: default:
return nil, fmt.Errorf("unsupported node type: %s, Only support: V2ray, Trojan, Shadowsocks", nodeInfo.NodeType) return nil, fmt.Errorf("unsupported node type: %s, Only support: V2ray, Trojan, Shadowsocks", nodeInfo.NodeType)

View File

@ -24,9 +24,9 @@ func (c *Controller) addNewUser(userInfo []panel.UserInfo, nodeInfo *panel.NodeI
} else { } else {
users = c.buildVmessUsers(userInfo) users = c.buildVmessUsers(userInfo)
} }
case "Trojan": case "trojan":
users = c.buildTrojanUsers(userInfo) users = c.buildTrojanUsers(userInfo)
case "Shadowsocks": case "shadowsocks":
users = c.buildSSUsers(userInfo, getCipherFromString(nodeInfo.Cipher)) users = c.buildSSUsers(userInfo, getCipherFromString(nodeInfo.Cipher))
default: default:
return fmt.Errorf("unsupported node type: %s", nodeInfo.NodeType) return fmt.Errorf("unsupported node type: %s", nodeInfo.NodeType)