diff --git a/cmd/lattice-agent/main.go b/cmd/lattice-agent/main.go index 6a93601..1fc06cc 100644 --- a/cmd/lattice-agent/main.go +++ b/cmd/lattice-agent/main.go @@ -33,7 +33,7 @@ import ( "github.com/LatticeNet/lattice-sdk/model" ) -var version = "0.3.3-alpha.1" +var version = "0.3.3-alpha.2" var compatServerMin = "v0.2.2-alpha.2" var compatDashboardMin = "v0.2.2-alpha.7" var compatChannel = "alpha" diff --git a/cmd/lattice-agent/main_test.go b/cmd/lattice-agent/main_test.go index f7cfddc..ae46379 100644 --- a/cmd/lattice-agent/main_test.go +++ b/cmd/lattice-agent/main_test.go @@ -24,8 +24,8 @@ func (f roundTripFunc) RoundTrip(r *http.Request) (*http.Response, error) { } func TestVersionMatchesCurrentRelease(t *testing.T) { - if version != "0.3.3-alpha.1" { - t.Fatalf("version = %q, want 0.3.3-alpha.1", version) + if version != "0.3.3-alpha.2" { + t.Fatalf("version = %q, want 0.3.3-alpha.2", version) } } diff --git a/internal/proxyusage/singbox.go b/internal/proxyusage/singbox.go index 2a42f9c..2bde32a 100644 --- a/internal/proxyusage/singbox.go +++ b/internal/proxyusage/singbox.go @@ -15,6 +15,10 @@ import ( const ( defaultSingBoxStatsPattern = "user>>>" defaultSingBoxStatsTimeout = 5 * time.Second + // sing-box rewrites its generated StatsService descriptor at runtime to + // the V2Ray-compatible service name. The protobuf messages keep the local + // experimental.v2rayapi package, but clients must invoke this aliased path. + singBoxStatsQueryMethod = "/v2ray.core.app.stats.command.StatsService/QueryStats" ) // SingBoxStatsSource collects per-user usage from sing-box's experimental @@ -125,9 +129,11 @@ func grpcQueryStats(ctx context.Context, addr, pattern string) ([]nameValue, err return nil, err } defer func() { _ = conn.Close() }() - resp, err := singboxstats.NewStatsServiceClient(conn).QueryStats(ctx, &singboxstats.QueryStatsRequest{ + request := &singboxstats.QueryStatsRequest{ Patterns: []string{pattern}, - }) + } + resp := new(singboxstats.QueryStatsResponse) + err = conn.Invoke(ctx, singBoxStatsQueryMethod, request, resp) if err != nil { return nil, err } diff --git a/internal/proxyusage/singbox_test.go b/internal/proxyusage/singbox_test.go index 3f45207..1a3677a 100644 --- a/internal/proxyusage/singbox_test.go +++ b/internal/proxyusage/singbox_test.go @@ -107,7 +107,12 @@ func TestGRPCQueryStatsEndToEnd(t *testing.T) { }} listener := bufconn.Listen(1 << 20) server := grpc.NewServer() - singboxstats.RegisterStatsServiceServer(server, fake) + // sing-box aliases the generated service name for V2Ray client + // compatibility. Register the fake under that runtime name so this test + // catches clients that only work against the unaliased generated package. + desc := singboxstats.StatsService_ServiceDesc + desc.ServiceName = "v2ray.core.app.stats.command.StatsService" + server.RegisterService(&desc, fake) go func() { _ = server.Serve(listener) }() t.Cleanup(func() { server.Stop()