lower response time

This commit is contained in:
Hiddify
2024-03-16 03:19:25 +01:00
parent 6039baa313
commit 7bc75b890f
2 changed files with 6 additions and 3 deletions

View File

@@ -66,7 +66,7 @@ func startTunnelRequest(opt ConfigOptions, installService bool) (bool, error) {
}
defer conn.Close()
c := pb.NewTunnelServiceClient(conn)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*1)
defer cancel()
_, err = c.Start(ctx, &pb.TunnelStartRequest{
Ipv6: opt.IPv6Mode == option.DomainStrategy(dns.DomainStrategyUseIPv4),
@@ -94,7 +94,7 @@ func stopTunnelRequest() (bool, error) {
}
defer conn.Close()
c := pb.NewTunnelServiceClient(conn)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*1)
defer cancel()
_, err = c.Stop(ctx, &pb.Empty{})

View File

@@ -3,6 +3,7 @@ package v2
import (
"context"
"fmt"
"log"
"os"
pb "github.com/hiddify/libcore/hiddifyrpc"
@@ -67,12 +68,14 @@ func makeTunnelConfig(Ipv6 bool, ServerPort int32, StrictRoute bool, EndpointInd
}
func (s *TunnelService) Stop(ctx context.Context, _ *pb.Empty) (*pb.TunnelResponse, error) {
_, err := Stop()
res, err := Stop()
log.Printf("Stop Result: %+v\n", res)
if err != nil {
return &pb.TunnelResponse{
Message: err.Error(),
}, err
}
return &pb.TunnelResponse{
Message: "OK",
}, err