From 3f6f80b5e583b52c0882349e3743dd1777e74458 Mon Sep 17 00:00:00 2001 From: yuzuki999 Date: Fri, 19 May 2023 11:27:08 +0800 Subject: [PATCH] node type to lower --- api/panel/panel.go | 9 +++++---- node/inbound.go | 6 +++--- node/user.go | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/api/panel/panel.go b/api/panel/panel.go index 340e26e..3594052 100644 --- a/api/panel/panel.go +++ b/api/panel/panel.go @@ -49,14 +49,15 @@ func New(c *conf.ApiConfig) (*Client, error) { }) client.SetBaseURL(c.APIHost) // Check node type - if c.NodeType != "V2ray" && - c.NodeType != "Trojan" && - c.NodeType != "Shadowsocks" { + c.NodeType = strings.ToLower(c.NodeType) + if c.NodeType != "v2ray" && + c.NodeType != "trojan" && + c.NodeType != "shadowsocks" { return nil, fmt.Errorf("unsupported Node type: %s", c.NodeType) } // Create Key for each requests client.SetQueryParams(map[string]string{ - "node_type": strings.ToLower(c.NodeType), + "node_type": c.NodeType, "node_id": strconv.Itoa(c.NodeID), "token": c.Key, }) diff --git a/node/inbound.go b/node/inbound.go index 2b334eb..75d5943 100644 --- a/node/inbound.go +++ b/node/inbound.go @@ -23,11 +23,11 @@ func buildInbound(config *conf.ControllerConfig, nodeInfo *panel.NodeInfo, tag s inbound.StreamSetting = &coreConf.StreamConfig{Network: &t} var err error switch nodeInfo.NodeType { - case "V2ray": + case "v2ray": err = buildV2ray(config, nodeInfo, inbound) - case "Trojan": + case "trojan": err = buildTrojan(config, nodeInfo, inbound) - case "Shadowsocks": + case "shadowsocks": err = buildShadowsocks(config, nodeInfo, inbound) default: return nil, fmt.Errorf("unsupported node type: %s, Only support: V2ray, Trojan, Shadowsocks", nodeInfo.NodeType) diff --git a/node/user.go b/node/user.go index b1faccf..85abeb5 100644 --- a/node/user.go +++ b/node/user.go @@ -24,9 +24,9 @@ func (c *Controller) addNewUser(userInfo []panel.UserInfo, nodeInfo *panel.NodeI } else { users = c.buildVmessUsers(userInfo) } - case "Trojan": + case "trojan": users = c.buildTrojanUsers(userInfo) - case "Shadowsocks": + case "shadowsocks": users = c.buildSSUsers(userInfo, getCipherFromString(nodeInfo.Cipher)) default: return fmt.Errorf("unsupported node type: %s", nodeInfo.NodeType)