Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix typos. #640

Merged
merged 2 commits into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/proxypanel/proxypanel.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func (c *APIClient) GetNodeInfo() (nodeInfo *api.NodeInfo, err error) {

if err != nil {
res, _ := json.Marshal(response.Data)
return nil, fmt.Errorf("Parse node info failed: %s, \nError: %s", string(res), err)
return nil, fmt.Errorf("parse node info failed: %s, \nError: %s", string(res), err)
}

return nodeInfo, nil
Expand Down
4 changes: 2 additions & 2 deletions api/proxypanel/proypanel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ func TestReportIllegal(t *testing.T) {
client := CreateClient()

detectResult := []api.DetectResult{
{1, 1},
{1, 2},
{UID: 1, RuleID: 1},
{UID: 1, RuleID: 2},
}
client.Debug()
err := client.ReportIllegal(&detectResult)
Expand Down
21 changes: 11 additions & 10 deletions api/sspanel/sspanel.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,13 @@ func readLocalRuleList(path string) (LocalRuleList []api.DetectRule) {
if path != "" {
// open the file
file, err := os.Open(path)
defer file.Close()

defer func(file *os.File) {
err := file.Close()
if err != nil {
log.Printf("Error when closing file: %s", err)
}
}(file)
// handle errors while opening
if err != nil {
log.Printf("Error when opening file: %s", err)
Expand Down Expand Up @@ -210,13 +215,13 @@ func (c *APIClient) GetNodeInfo() (nodeInfo *api.NodeInfo, err error) {
nodeInfo, err = c.ParseSSPanelNodeInfo(nodeInfoResponse)
if err != nil {
res, _ := json.Marshal(nodeInfoResponse)
return nil, fmt.Errorf("Parse node info failed: %s, \nError: %s, \nPlease check the doc of custom_config for help: https://xrayr-project.github.io/XrayR-doc/dui-jie-sspanel/sspanel/sspanel_custom_config", string(res), err)
return nil, fmt.Errorf("parse node info failed: %s, \nError: %s, \nPlease check the doc of custom_config for help: https://xrayr-project.github.io/XrayR-doc/dui-jie-sspanel/sspanel/sspanel_custom_config", string(res), err)
}
}

if err != nil {
res, _ := json.Marshal(nodeInfoResponse)
return nil, fmt.Errorf("Parse node info failed: %s, \nError: %s", string(res), err)
return nil, fmt.Errorf("parse node info failed: %s, \nError: %s", string(res), err)
}

return nodeInfo, nil
Expand Down Expand Up @@ -291,16 +296,12 @@ func (c *APIClient) ReportNodeOnlineUsers(onlineUserList *[]api.OnlineUser) erro
data := make([]OnlineUser, len(*onlineUserList))
for i, user := range *onlineUserList {
data[i] = OnlineUser{UID: user.UID, IP: user.IP}
if _, ok := reportOnline[user.UID]; ok {
reportOnline[user.UID]++
} else {
reportOnline[user.UID] = 1
}
reportOnline[user.UID]++ // will start from 1 if key doesn’t exist
}
c.LastReportOnline = reportOnline // Update LastReportOnline

postData := &PostData{Data: data}
path := fmt.Sprintf("/mod_mu/users/aliveip")
path := "/mod_mu/users/aliveip"
res, err := c.client.R().
SetQueryParam("node_id", strconv.Itoa(c.NodeID)).
SetBody(postData).
Expand Down Expand Up @@ -474,7 +475,7 @@ func (c *APIClient) ParseV2rayNodeResponse(nodeInfoResponse *NodeInfoResponse) (
}

if err != nil {
return nil, fmt.Errorf("marshal Header Type %s into config fialed: %s", header, err)
return nil, fmt.Errorf("marshal Header Type %s into config failed: %s", header, err)
}

// Create GeneralNodeInfo
Expand Down
4 changes: 2 additions & 2 deletions api/sspanel/sspanel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ func TestReportIllegal(t *testing.T) {
client := CreateClient()

detectResult := []api.DetectResult{
{1, 2},
{1, 3},
{UID: 1, RuleID: 2},
{UID: 1, RuleID: 3},
}
client.Debug()
err := client.ReportIllegal(&detectResult)
Expand Down
4 changes: 2 additions & 2 deletions panel/panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func (p *Panel) Start() {
for _, s := range p.Service {
err := s.Start()
if err != nil {
log.Panicf("Panel Start fialed: %s", err)
log.Panicf("Panel Start failed: %s", err)
}
}
p.Running = true
Expand All @@ -222,7 +222,7 @@ func (p *Panel) Close() {
for _, s := range p.Service {
err := s.Close()
if err != nil {
log.Panicf("Panel Close fialed: %s", err)
log.Panicf("Panel Close failed: %s", err)
}
}
p.Service = nil
Expand Down
10 changes: 5 additions & 5 deletions service/controller/inboundbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func InboundBuilder(config *Config, nodeInfo *api.NodeInfo, tag string) (*core.I

setting, err := json.Marshal(proxySetting)
if err != nil {
return nil, fmt.Errorf("marshal proxy %s config fialed: %s", nodeInfo.NodeType, err)
return nil, fmt.Errorf("marshal proxy %s config failed: %s", nodeInfo.NodeType, err)
}
inboundDetourConfig.Protocol = protocol
inboundDetourConfig.Settings = &setting
Expand Down Expand Up @@ -287,13 +287,13 @@ func buildVlessFallbacks(fallbackConfigs []*FallBackConfig) ([]*conf.VLessInboun
for i, c := range fallbackConfigs {

if c.Dest == "" {
return nil, fmt.Errorf("dest is required for fallback fialed")
return nil, fmt.Errorf("dest is required for fallback failed")
}

var dest json.RawMessage
dest, err := json.Marshal(c.Dest)
if err != nil {
return nil, fmt.Errorf("marshal dest %s config fialed: %s", dest, err)
return nil, fmt.Errorf("marshal dest %s config failed: %s", dest, err)
}
vlessFallBacks[i] = &conf.VLessInboundFallback{
Name: c.SNI,
Expand All @@ -315,13 +315,13 @@ func buildTrojanFallbacks(fallbackConfigs []*FallBackConfig) ([]*conf.TrojanInbo
for i, c := range fallbackConfigs {

if c.Dest == "" {
return nil, fmt.Errorf("dest is required for fallback fialed")
return nil, fmt.Errorf("dest is required for fallback failed")
}

var dest json.RawMessage
dest, err := json.Marshal(c.Dest)
if err != nil {
return nil, fmt.Errorf("marshal dest %s config fialed: %s", dest, err)
return nil, fmt.Errorf("marshal dest %s config failed: %s", dest, err)
}
trojanFallBacks[i] = &conf.TrojanInboundFallback{
Name: c.SNI,
Expand Down
2 changes: 1 addition & 1 deletion service/controller/outboundbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func OutboundBuilder(config *Config, nodeInfo *api.NodeInfo, tag string) (*core.
var setting json.RawMessage
setting, err := json.Marshal(proxySetting)
if err != nil {
return nil, fmt.Errorf("marshal proxy %s config fialed: %s", nodeInfo.NodeType, err)
return nil, fmt.Errorf("marshal proxy %s config failed: %s", nodeInfo.NodeType, err)
}
outboundDetourConfig.Settings = &setting
return outboundDetourConfig.Build()
Expand Down
Loading