格式化

This commit is contained in:
iluobei
2026-04-10 15:25:21 +08:00
parent e13c81ce7a
commit b3202edb49
17 changed files with 633 additions and 407 deletions
+4 -3
View File
@@ -2,13 +2,14 @@ package stats
import (
"context"
"time"
"mmw-agent/internal/constants"
statspb "github.com/xtls/xray-core/app/stats/command"
)
func QueryTraffic(ctx context.Context, client statspb.StatsServiceClient, pattern string, reset bool) (int64, error) {
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
ctx, cancel := context.WithTimeout(ctx, constants.DefaultRPCShortTimeout)
defer cancel()
resp, err := client.QueryStats(ctx, &statspb.QueryStatsRequest{
Pattern: pattern,
@@ -24,7 +25,7 @@ func QueryTraffic(ctx context.Context, client statspb.StatsServiceClient, patter
}
func GetSystemStats(ctx context.Context, client statspb.StatsServiceClient) (*statspb.SysStatsResponse, error) {
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
ctx, cancel := context.WithTimeout(ctx, constants.DefaultRPCShortTimeout)
defer cancel()
return client.GetSysStats(ctx, &statspb.SysStatsRequest{})
}