mirror of
https://github.com/XrayR-project/XrayR.git
synced 2025-06-07 21:09:53 +00:00
chore: fix typos. (#640)
* chore: fix typos. * chore: makes go-staticcheck happy.
This commit is contained in:
parent
5ee2679924
commit
9261a6063d
@ -178,7 +178,7 @@ func (c *APIClient) GetNodeInfo() (nodeInfo *api.NodeInfo, err error) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res, _ := json.Marshal(response.Data)
|
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
|
return nodeInfo, nil
|
||||||
|
@ -154,8 +154,8 @@ func TestReportIllegal(t *testing.T) {
|
|||||||
client := CreateClient()
|
client := CreateClient()
|
||||||
|
|
||||||
detectResult := []api.DetectResult{
|
detectResult := []api.DetectResult{
|
||||||
{1, 1},
|
{UID: 1, RuleID: 1},
|
||||||
{1, 2},
|
{UID: 1, RuleID: 2},
|
||||||
}
|
}
|
||||||
client.Debug()
|
client.Debug()
|
||||||
err := client.ReportIllegal(&detectResult)
|
err := client.ReportIllegal(&detectResult)
|
||||||
|
@ -95,8 +95,13 @@ func readLocalRuleList(path string) (LocalRuleList []api.DetectRule) {
|
|||||||
if path != "" {
|
if path != "" {
|
||||||
// open the file
|
// open the file
|
||||||
file, err := os.Open(path)
|
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
|
// handle errors while opening
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error when opening file: %s", err)
|
log.Printf("Error when opening file: %s", err)
|
||||||
@ -210,13 +215,13 @@ func (c *APIClient) GetNodeInfo() (nodeInfo *api.NodeInfo, err error) {
|
|||||||
nodeInfo, err = c.ParseSSPanelNodeInfo(nodeInfoResponse)
|
nodeInfo, err = c.ParseSSPanelNodeInfo(nodeInfoResponse)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res, _ := json.Marshal(nodeInfoResponse)
|
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 {
|
if err != nil {
|
||||||
res, _ := json.Marshal(nodeInfoResponse)
|
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
|
return nodeInfo, nil
|
||||||
@ -291,16 +296,12 @@ func (c *APIClient) ReportNodeOnlineUsers(onlineUserList *[]api.OnlineUser) erro
|
|||||||
data := make([]OnlineUser, len(*onlineUserList))
|
data := make([]OnlineUser, len(*onlineUserList))
|
||||||
for i, user := range *onlineUserList {
|
for i, user := range *onlineUserList {
|
||||||
data[i] = OnlineUser{UID: user.UID, IP: user.IP}
|
data[i] = OnlineUser{UID: user.UID, IP: user.IP}
|
||||||
if _, ok := reportOnline[user.UID]; ok {
|
reportOnline[user.UID]++ // will start from 1 if key doesn’t exist
|
||||||
reportOnline[user.UID]++
|
|
||||||
} else {
|
|
||||||
reportOnline[user.UID] = 1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
c.LastReportOnline = reportOnline // Update LastReportOnline
|
c.LastReportOnline = reportOnline // Update LastReportOnline
|
||||||
|
|
||||||
postData := &PostData{Data: data}
|
postData := &PostData{Data: data}
|
||||||
path := fmt.Sprintf("/mod_mu/users/aliveip")
|
path := "/mod_mu/users/aliveip"
|
||||||
res, err := c.client.R().
|
res, err := c.client.R().
|
||||||
SetQueryParam("node_id", strconv.Itoa(c.NodeID)).
|
SetQueryParam("node_id", strconv.Itoa(c.NodeID)).
|
||||||
SetBody(postData).
|
SetBody(postData).
|
||||||
@ -474,7 +475,7 @@ func (c *APIClient) ParseV2rayNodeResponse(nodeInfoResponse *NodeInfoResponse) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
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
|
// Create GeneralNodeInfo
|
||||||
|
@ -148,8 +148,8 @@ func TestReportIllegal(t *testing.T) {
|
|||||||
client := CreateClient()
|
client := CreateClient()
|
||||||
|
|
||||||
detectResult := []api.DetectResult{
|
detectResult := []api.DetectResult{
|
||||||
{1, 2},
|
{UID: 1, RuleID: 2},
|
||||||
{1, 3},
|
{UID: 1, RuleID: 3},
|
||||||
}
|
}
|
||||||
client.Debug()
|
client.Debug()
|
||||||
err := client.ReportIllegal(&detectResult)
|
err := client.ReportIllegal(&detectResult)
|
||||||
|
@ -208,7 +208,7 @@ func (p *Panel) Start() {
|
|||||||
for _, s := range p.Service {
|
for _, s := range p.Service {
|
||||||
err := s.Start()
|
err := s.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panicf("Panel Start fialed: %s", err)
|
log.Panicf("Panel Start failed: %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p.Running = true
|
p.Running = true
|
||||||
@ -222,7 +222,7 @@ func (p *Panel) Close() {
|
|||||||
for _, s := range p.Service {
|
for _, s := range p.Service {
|
||||||
err := s.Close()
|
err := s.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panicf("Panel Close fialed: %s", err)
|
log.Panicf("Panel Close failed: %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p.Service = nil
|
p.Service = nil
|
||||||
|
@ -139,7 +139,7 @@ func InboundBuilder(config *Config, nodeInfo *api.NodeInfo, tag string) (*core.I
|
|||||||
|
|
||||||
setting, err := json.Marshal(proxySetting)
|
setting, err := json.Marshal(proxySetting)
|
||||||
if err != nil {
|
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.Protocol = protocol
|
||||||
inboundDetourConfig.Settings = &setting
|
inboundDetourConfig.Settings = &setting
|
||||||
@ -287,13 +287,13 @@ func buildVlessFallbacks(fallbackConfigs []*FallBackConfig) ([]*conf.VLessInboun
|
|||||||
for i, c := range fallbackConfigs {
|
for i, c := range fallbackConfigs {
|
||||||
|
|
||||||
if c.Dest == "" {
|
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
|
var dest json.RawMessage
|
||||||
dest, err := json.Marshal(c.Dest)
|
dest, err := json.Marshal(c.Dest)
|
||||||
if err != nil {
|
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{
|
vlessFallBacks[i] = &conf.VLessInboundFallback{
|
||||||
Name: c.SNI,
|
Name: c.SNI,
|
||||||
@ -315,13 +315,13 @@ func buildTrojanFallbacks(fallbackConfigs []*FallBackConfig) ([]*conf.TrojanInbo
|
|||||||
for i, c := range fallbackConfigs {
|
for i, c := range fallbackConfigs {
|
||||||
|
|
||||||
if c.Dest == "" {
|
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
|
var dest json.RawMessage
|
||||||
dest, err := json.Marshal(c.Dest)
|
dest, err := json.Marshal(c.Dest)
|
||||||
if err != nil {
|
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{
|
trojanFallBacks[i] = &conf.TrojanInboundFallback{
|
||||||
Name: c.SNI,
|
Name: c.SNI,
|
||||||
|
@ -38,7 +38,7 @@ func OutboundBuilder(config *Config, nodeInfo *api.NodeInfo, tag string) (*core.
|
|||||||
var setting json.RawMessage
|
var setting json.RawMessage
|
||||||
setting, err := json.Marshal(proxySetting)
|
setting, err := json.Marshal(proxySetting)
|
||||||
if err != nil {
|
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
|
outboundDetourConfig.Settings = &setting
|
||||||
return outboundDetourConfig.Build()
|
return outboundDetourConfig.Build()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user