Skip to content

Commit

Permalink
fix SyncTask
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehco1996 committed Aug 28, 2019
1 parent 5220dcb commit 175b040
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/Ehco1996/v2scar"
)

var SYNC_TIME = 60
var SYNC_TIME int

func main() {

Expand Down
9 changes: 5 additions & 4 deletions tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
v2stats "v2ray.com/core/app/stats/command"
)

var API_ENDPOINT = "127.0.0.1:8080"
var GRPC_ENDPOINT = "http://fun.com/api"
var API_ENDPOINT string
var GRPC_ENDPOINT string

type UserConfig struct {
UserId int `json:"user_id"`
Expand Down Expand Up @@ -43,10 +43,12 @@ func SyncTask(up *UserPool) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
conn, err := grpc.DialContext(ctx, GRPC_ENDPOINT, grpc.WithInsecure(), grpc.WithBlock())
defer conn.Close()

if err != nil {
log.Printf("[WARNING]: GRPC连接失败,请检查V2ray是否运行并开放对应grpc端口 当前GRPC地址: %v", GRPC_ENDPOINT)
return
} else {
defer conn.Close()
}

// Init Client
Expand All @@ -66,7 +68,6 @@ func SyncTask(up *UserPool) {

// sync user traffic
syncUserTrafficToServer(up, statClient, httpClient)

}

func initOrUpdateUser(up *UserPool, c v2proxyman.HandlerServiceClient, sr *syncResp) {
Expand Down

0 comments on commit 175b040

Please # to comment.