Skip to content

Commit 175b040

Browse files
committed
fix SyncTask
1 parent 5220dcb commit 175b040

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

cli/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/Ehco1996/v2scar"
1111
)
1212

13-
var SYNC_TIME = 60
13+
var SYNC_TIME int
1414

1515
func main() {
1616

tasks.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
v2stats "v2ray.com/core/app/stats/command"
1212
)
1313

14-
var API_ENDPOINT = "127.0.0.1:8080"
15-
var GRPC_ENDPOINT = "http://fun.com/api"
14+
var API_ENDPOINT string
15+
var GRPC_ENDPOINT string
1616

1717
type UserConfig struct {
1818
UserId int `json:"user_id"`
@@ -43,10 +43,12 @@ func SyncTask(up *UserPool) {
4343
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
4444
defer cancel()
4545
conn, err := grpc.DialContext(ctx, GRPC_ENDPOINT, grpc.WithInsecure(), grpc.WithBlock())
46-
defer conn.Close()
46+
4747
if err != nil {
4848
log.Printf("[WARNING]: GRPC连接失败,请检查V2ray是否运行并开放对应grpc端口 当前GRPC地址: %v", GRPC_ENDPOINT)
4949
return
50+
} else {
51+
defer conn.Close()
5052
}
5153

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

6769
// sync user traffic
6870
syncUserTrafficToServer(up, statClient, httpClient)
69-
7071
}
7172

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

0 commit comments

Comments
 (0)