Some fixes and improvements (#1077)

* [refactor] api controller

* [update] use status code for jsonMsg and 401 to unauthorize

* [update] handle response status code via axios

* [lint] all .go files
This commit is contained in:
Hamidreza
2024-03-10 20:30:44 +03:30
committed by GitHub
parent e3c2b42048
commit b6ccb2e076
40 changed files with 135 additions and 142 deletions

View File

@@ -6,6 +6,7 @@ import (
"fmt"
"regexp"
"time"
"x-ui/logger"
"x-ui/util/common"
@@ -159,8 +160,8 @@ func (x *XrayAPI) GetTraffic(reset bool) ([]*Traffic, []*ClientTraffic, error) {
if x.grpcClient == nil {
return nil, nil, common.NewError("xray api is not initialized")
}
var trafficRegex = regexp.MustCompile("(inbound|outbound)>>>([^>]+)>>>traffic>>>(downlink|uplink)")
var ClientTrafficRegex = regexp.MustCompile("(user)>>>([^>]+)>>>traffic>>>(downlink|uplink)")
trafficRegex := regexp.MustCompile("(inbound|outbound)>>>([^>]+)>>>traffic>>>(downlink|uplink)")
ClientTrafficRegex := regexp.MustCompile("(user)>>>([^>]+)>>>traffic>>>(downlink|uplink)")
client := *x.StatsServiceClient
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)

View File

@@ -2,6 +2,7 @@ package xray
import (
"bytes"
"x-ui/util/json_util"
)

View File

@@ -2,6 +2,7 @@ package xray
import (
"bytes"
"x-ui/util/json_util"
)

View File

@@ -3,6 +3,7 @@ package xray
import (
"regexp"
"strings"
"x-ui/logger"
)

View File

@@ -11,6 +11,7 @@ import (
"runtime"
"syscall"
"time"
"x-ui/config"
"x-ui/util/common"
)