From 71aba0601e6d847d21970ee44041a5d12fd53679 Mon Sep 17 00:00:00 2001 From: M1Screw <14369594+M1Screw@users.noreply.github.com> Date: Wed, 4 Oct 2023 10:44:45 +0800 Subject: [PATCH] feat: unify trojan transport & add ss2022 related config (#465) --- api/sspanel/model.go | 7 +------ api/sspanel/sspanel.go | 9 +++++---- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/api/sspanel/model.go b/api/sspanel/model.go index 1773fee..998ec30 100644 --- a/api/sspanel/model.go +++ b/api/sspanel/model.go @@ -21,11 +21,7 @@ type CustomConfig struct { OffsetPortNode string `json:"offset_port_node"` ServerSub string `json:"server_sub"` Host string `json:"host"` - MuPort string `json:"mu_port"` - MuEncryption string `json:"mu_encryption"` - MuProtocol string `json:"mu_protocol"` - MuObfs string `json:"mu_obfs"` - MuSuffix string `json:"mu_suffix"` + Method string `json:"method"` V2Port string `json:"v2_port"` TLS string `json:"tls"` EnableVless string `json:"enable_vless"` @@ -38,7 +34,6 @@ type CustomConfig struct { Header json.RawMessage `json:"header"` TrojanPort string `json:"trojan_port"` AllowInsecure string `json:"allow_insecure"` - Grpc string `json:"grpc"` Servicename string `json:"servicename"` EnableXtls string `json:"enable_xtls"` Flow string `json:"flow"` diff --git a/api/sspanel/sspanel.go b/api/sspanel/sspanel.go index bd7fe3d..637adb5 100644 --- a/api/sspanel/sspanel.go +++ b/api/sspanel/sspanel.go @@ -768,6 +768,7 @@ func (c *APIClient) ParseSSPanelNodeInfo(nodeInfoResponse *NodeInfoResponse) (*a } parsedPort, err := strconv.ParseInt(nodeConfig.OffsetPortNode, 10, 32) + if err != nil { return nil, err } @@ -780,6 +781,7 @@ func (c *APIClient) ParseSSPanelNodeInfo(nodeInfoResponse *NodeInfoResponse) (*a if c.NodeType == "V2ray" { transportProtocol = nodeConfig.Network TLSType = nodeConfig.Security + if parsedAlterID, err := strconv.ParseInt(nodeConfig.AlterID, 10, 16); err != nil { return nil, err } else { @@ -789,6 +791,7 @@ func (c *APIClient) ParseSSPanelNodeInfo(nodeInfoResponse *NodeInfoResponse) (*a if TLSType == "tls" || TLSType == "xtls" { EnableTLS = true } + if nodeConfig.EnableVless == "1" { EnableVless = true } @@ -807,9 +810,7 @@ func (c *APIClient) ParseSSPanelNodeInfo(nodeInfoResponse *NodeInfoResponse) (*a } // Select transport protocol - if nodeConfig.Grpc == "1" { - transportProtocol = "grpc" - } else if nodeConfig.Network != "" { + if nodeConfig.Network != "" { transportProtocol = nodeConfig.Network // try to read transport protocol from config } } @@ -827,7 +828,7 @@ func (c *APIClient) ParseSSPanelNodeInfo(nodeInfoResponse *NodeInfoResponse) (*a EnableTLS: EnableTLS, EnableVless: EnableVless, VlessFlow: nodeConfig.Flow, - CypherMethod: nodeConfig.MuEncryption, + CypherMethod: nodeConfig.Method, ServiceName: nodeConfig.Servicename, Header: nodeConfig.Header, }