diff options
| author | MHSanaei <ho3ein.sanaei@gmail.com> | 2023-04-27 23:18:22 +0300 |
|---|---|---|
| committer | MHSanaei <ho3ein.sanaei@gmail.com> | 2023-04-27 23:18:22 +0300 |
| commit | 0b896d9c31a38e6498992aeb61b19f6d93219f0a (patch) | |
| tree | 1deefe45592197c2bf52fc6eadc6d19ef3f5eb55 /xray | |
| parent | 6f4a2809e22a5244b9f20b0fbb4325eb5a8dc853 (diff) | |
grpc.WithInsecure is deprecated
Diffstat (limited to 'xray')
| -rw-r--r-- | xray/process.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/xray/process.go b/xray/process.go index e7774ea4..27b0721b 100644 --- a/xray/process.go +++ b/xray/process.go @@ -4,6 +4,7 @@ import ( "bufio" "bytes" "context" + "crypto/tls" "encoding/json" "errors" "fmt" @@ -20,6 +21,7 @@ import ( "github.com/Workiva/go-datastructures/queue" statsservice "github.com/xtls/xray-core/app/stats/command" "google.golang.org/grpc" + "google.golang.org/grpc/credentials" ) var trafficRegex = regexp.MustCompile("(inbound|outbound)>>>([^>]+)>>>traffic>>>(downlink|uplink)") @@ -243,7 +245,9 @@ func (p *process) GetTraffic(reset bool) ([]*Traffic, []*ClientTraffic, error) { if p.apiPort == 0 { return nil, nil, common.NewError("xray api port wrong:", p.apiPort) } - conn, err := grpc.Dial(fmt.Sprintf("127.0.0.1:%v", p.apiPort), grpc.WithInsecure()) + creds := credentials.NewTLS(&tls.Config{InsecureSkipVerify: true}) + conn, err := grpc.Dial(fmt.Sprintf("127.0.0.1:%v", p.apiPort), grpc.WithTransportCredentials(creds)) + if err != nil { return nil, nil, err } |
