mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-19 05:30:06 +08:00
fix fetch remote routes &&
fix core exit
This commit is contained in:
parent
72c7d6c9ea
commit
3bc047c866
1762
core/server/gen/libcore.pb.go
Normal file
1762
core/server/gen/libcore.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
691
core/server/gen/libcore_grpc.pb.go
Normal file
691
core/server/gen/libcore_grpc.pb.go
Normal file
@ -0,0 +1,691 @@
|
|||||||
|
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// - protoc-gen-go-grpc v1.5.1
|
||||||
|
// - protoc v5.29.3
|
||||||
|
// source: libcore.proto
|
||||||
|
|
||||||
|
package gen
|
||||||
|
|
||||||
|
import (
|
||||||
|
context "context"
|
||||||
|
grpc "google.golang.org/grpc"
|
||||||
|
codes "google.golang.org/grpc/codes"
|
||||||
|
status "google.golang.org/grpc/status"
|
||||||
|
)
|
||||||
|
|
||||||
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
|
// is compatible with the grpc package it is being compiled against.
|
||||||
|
// Requires gRPC-Go v1.64.0 or later.
|
||||||
|
const _ = grpc.SupportPackageIsVersion9
|
||||||
|
|
||||||
|
const (
|
||||||
|
LibcoreService_Start_FullMethodName = "/libcore.LibcoreService/Start"
|
||||||
|
LibcoreService_Stop_FullMethodName = "/libcore.LibcoreService/Stop"
|
||||||
|
LibcoreService_CheckConfig_FullMethodName = "/libcore.LibcoreService/CheckConfig"
|
||||||
|
LibcoreService_Test_FullMethodName = "/libcore.LibcoreService/Test"
|
||||||
|
LibcoreService_StopTest_FullMethodName = "/libcore.LibcoreService/StopTest"
|
||||||
|
LibcoreService_QueryURLTest_FullMethodName = "/libcore.LibcoreService/QueryURLTest"
|
||||||
|
LibcoreService_QueryStats_FullMethodName = "/libcore.LibcoreService/QueryStats"
|
||||||
|
LibcoreService_ListConnections_FullMethodName = "/libcore.LibcoreService/ListConnections"
|
||||||
|
LibcoreService_GetGeoIPList_FullMethodName = "/libcore.LibcoreService/GetGeoIPList"
|
||||||
|
LibcoreService_GetGeoSiteList_FullMethodName = "/libcore.LibcoreService/GetGeoSiteList"
|
||||||
|
LibcoreService_CompileGeoIPToSrs_FullMethodName = "/libcore.LibcoreService/CompileGeoIPToSrs"
|
||||||
|
LibcoreService_CompileGeoSiteToSrs_FullMethodName = "/libcore.LibcoreService/CompileGeoSiteToSrs"
|
||||||
|
LibcoreService_SetSystemDNS_FullMethodName = "/libcore.LibcoreService/SetSystemDNS"
|
||||||
|
LibcoreService_IsPrivileged_FullMethodName = "/libcore.LibcoreService/IsPrivileged"
|
||||||
|
LibcoreService_SpeedTest_FullMethodName = "/libcore.LibcoreService/SpeedTest"
|
||||||
|
LibcoreService_QuerySpeedTest_FullMethodName = "/libcore.LibcoreService/QuerySpeedTest"
|
||||||
|
)
|
||||||
|
|
||||||
|
// LibcoreServiceClient is the client API for LibcoreService service.
|
||||||
|
//
|
||||||
|
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||||
|
type LibcoreServiceClient interface {
|
||||||
|
Start(ctx context.Context, in *LoadConfigReq, opts ...grpc.CallOption) (*ErrorResp, error)
|
||||||
|
Stop(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*ErrorResp, error)
|
||||||
|
CheckConfig(ctx context.Context, in *LoadConfigReq, opts ...grpc.CallOption) (*ErrorResp, error)
|
||||||
|
Test(ctx context.Context, in *TestReq, opts ...grpc.CallOption) (*TestResp, error)
|
||||||
|
StopTest(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*EmptyResp, error)
|
||||||
|
QueryURLTest(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*QueryURLTestResponse, error)
|
||||||
|
QueryStats(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*QueryStatsResp, error)
|
||||||
|
ListConnections(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*ListConnectionsResp, error)
|
||||||
|
GetGeoIPList(ctx context.Context, in *GeoListRequest, opts ...grpc.CallOption) (*GetGeoIPListResponse, error)
|
||||||
|
GetGeoSiteList(ctx context.Context, in *GeoListRequest, opts ...grpc.CallOption) (*GetGeoSiteListResponse, error)
|
||||||
|
CompileGeoIPToSrs(ctx context.Context, in *CompileGeoIPToSrsRequest, opts ...grpc.CallOption) (*EmptyResp, error)
|
||||||
|
CompileGeoSiteToSrs(ctx context.Context, in *CompileGeoSiteToSrsRequest, opts ...grpc.CallOption) (*EmptyResp, error)
|
||||||
|
SetSystemDNS(ctx context.Context, in *SetSystemDNSRequest, opts ...grpc.CallOption) (*EmptyResp, error)
|
||||||
|
IsPrivileged(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*IsPrivilegedResponse, error)
|
||||||
|
SpeedTest(ctx context.Context, in *SpeedTestRequest, opts ...grpc.CallOption) (*SpeedTestResponse, error)
|
||||||
|
QuerySpeedTest(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*QuerySpeedTestResponse, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type libcoreServiceClient struct {
|
||||||
|
cc grpc.ClientConnInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewLibcoreServiceClient(cc grpc.ClientConnInterface) LibcoreServiceClient {
|
||||||
|
return &libcoreServiceClient{cc}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *libcoreServiceClient) Start(ctx context.Context, in *LoadConfigReq, opts ...grpc.CallOption) (*ErrorResp, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(ErrorResp)
|
||||||
|
err := c.cc.Invoke(ctx, LibcoreService_Start_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *libcoreServiceClient) Stop(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*ErrorResp, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(ErrorResp)
|
||||||
|
err := c.cc.Invoke(ctx, LibcoreService_Stop_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *libcoreServiceClient) CheckConfig(ctx context.Context, in *LoadConfigReq, opts ...grpc.CallOption) (*ErrorResp, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(ErrorResp)
|
||||||
|
err := c.cc.Invoke(ctx, LibcoreService_CheckConfig_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *libcoreServiceClient) Test(ctx context.Context, in *TestReq, opts ...grpc.CallOption) (*TestResp, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(TestResp)
|
||||||
|
err := c.cc.Invoke(ctx, LibcoreService_Test_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *libcoreServiceClient) StopTest(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*EmptyResp, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(EmptyResp)
|
||||||
|
err := c.cc.Invoke(ctx, LibcoreService_StopTest_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *libcoreServiceClient) QueryURLTest(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*QueryURLTestResponse, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(QueryURLTestResponse)
|
||||||
|
err := c.cc.Invoke(ctx, LibcoreService_QueryURLTest_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *libcoreServiceClient) QueryStats(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*QueryStatsResp, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(QueryStatsResp)
|
||||||
|
err := c.cc.Invoke(ctx, LibcoreService_QueryStats_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *libcoreServiceClient) ListConnections(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*ListConnectionsResp, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(ListConnectionsResp)
|
||||||
|
err := c.cc.Invoke(ctx, LibcoreService_ListConnections_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *libcoreServiceClient) GetGeoIPList(ctx context.Context, in *GeoListRequest, opts ...grpc.CallOption) (*GetGeoIPListResponse, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(GetGeoIPListResponse)
|
||||||
|
err := c.cc.Invoke(ctx, LibcoreService_GetGeoIPList_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *libcoreServiceClient) GetGeoSiteList(ctx context.Context, in *GeoListRequest, opts ...grpc.CallOption) (*GetGeoSiteListResponse, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(GetGeoSiteListResponse)
|
||||||
|
err := c.cc.Invoke(ctx, LibcoreService_GetGeoSiteList_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *libcoreServiceClient) CompileGeoIPToSrs(ctx context.Context, in *CompileGeoIPToSrsRequest, opts ...grpc.CallOption) (*EmptyResp, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(EmptyResp)
|
||||||
|
err := c.cc.Invoke(ctx, LibcoreService_CompileGeoIPToSrs_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *libcoreServiceClient) CompileGeoSiteToSrs(ctx context.Context, in *CompileGeoSiteToSrsRequest, opts ...grpc.CallOption) (*EmptyResp, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(EmptyResp)
|
||||||
|
err := c.cc.Invoke(ctx, LibcoreService_CompileGeoSiteToSrs_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *libcoreServiceClient) SetSystemDNS(ctx context.Context, in *SetSystemDNSRequest, opts ...grpc.CallOption) (*EmptyResp, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(EmptyResp)
|
||||||
|
err := c.cc.Invoke(ctx, LibcoreService_SetSystemDNS_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *libcoreServiceClient) IsPrivileged(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*IsPrivilegedResponse, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(IsPrivilegedResponse)
|
||||||
|
err := c.cc.Invoke(ctx, LibcoreService_IsPrivileged_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *libcoreServiceClient) SpeedTest(ctx context.Context, in *SpeedTestRequest, opts ...grpc.CallOption) (*SpeedTestResponse, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(SpeedTestResponse)
|
||||||
|
err := c.cc.Invoke(ctx, LibcoreService_SpeedTest_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *libcoreServiceClient) QuerySpeedTest(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*QuerySpeedTestResponse, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(QuerySpeedTestResponse)
|
||||||
|
err := c.cc.Invoke(ctx, LibcoreService_QuerySpeedTest_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// LibcoreServiceServer is the server API for LibcoreService service.
|
||||||
|
// All implementations must embed UnimplementedLibcoreServiceServer
|
||||||
|
// for forward compatibility.
|
||||||
|
type LibcoreServiceServer interface {
|
||||||
|
Start(context.Context, *LoadConfigReq) (*ErrorResp, error)
|
||||||
|
Stop(context.Context, *EmptyReq) (*ErrorResp, error)
|
||||||
|
CheckConfig(context.Context, *LoadConfigReq) (*ErrorResp, error)
|
||||||
|
Test(context.Context, *TestReq) (*TestResp, error)
|
||||||
|
StopTest(context.Context, *EmptyReq) (*EmptyResp, error)
|
||||||
|
QueryURLTest(context.Context, *EmptyReq) (*QueryURLTestResponse, error)
|
||||||
|
QueryStats(context.Context, *EmptyReq) (*QueryStatsResp, error)
|
||||||
|
ListConnections(context.Context, *EmptyReq) (*ListConnectionsResp, error)
|
||||||
|
GetGeoIPList(context.Context, *GeoListRequest) (*GetGeoIPListResponse, error)
|
||||||
|
GetGeoSiteList(context.Context, *GeoListRequest) (*GetGeoSiteListResponse, error)
|
||||||
|
CompileGeoIPToSrs(context.Context, *CompileGeoIPToSrsRequest) (*EmptyResp, error)
|
||||||
|
CompileGeoSiteToSrs(context.Context, *CompileGeoSiteToSrsRequest) (*EmptyResp, error)
|
||||||
|
SetSystemDNS(context.Context, *SetSystemDNSRequest) (*EmptyResp, error)
|
||||||
|
IsPrivileged(context.Context, *EmptyReq) (*IsPrivilegedResponse, error)
|
||||||
|
SpeedTest(context.Context, *SpeedTestRequest) (*SpeedTestResponse, error)
|
||||||
|
QuerySpeedTest(context.Context, *EmptyReq) (*QuerySpeedTestResponse, error)
|
||||||
|
mustEmbedUnimplementedLibcoreServiceServer()
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnimplementedLibcoreServiceServer must be embedded to have
|
||||||
|
// forward compatible implementations.
|
||||||
|
//
|
||||||
|
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||||
|
// pointer dereference when methods are called.
|
||||||
|
type UnimplementedLibcoreServiceServer struct{}
|
||||||
|
|
||||||
|
func (UnimplementedLibcoreServiceServer) Start(context.Context, *LoadConfigReq) (*ErrorResp, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method Start not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedLibcoreServiceServer) Stop(context.Context, *EmptyReq) (*ErrorResp, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method Stop not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedLibcoreServiceServer) CheckConfig(context.Context, *LoadConfigReq) (*ErrorResp, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method CheckConfig not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedLibcoreServiceServer) Test(context.Context, *TestReq) (*TestResp, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method Test not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedLibcoreServiceServer) StopTest(context.Context, *EmptyReq) (*EmptyResp, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method StopTest not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedLibcoreServiceServer) QueryURLTest(context.Context, *EmptyReq) (*QueryURLTestResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method QueryURLTest not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedLibcoreServiceServer) QueryStats(context.Context, *EmptyReq) (*QueryStatsResp, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method QueryStats not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedLibcoreServiceServer) ListConnections(context.Context, *EmptyReq) (*ListConnectionsResp, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method ListConnections not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedLibcoreServiceServer) GetGeoIPList(context.Context, *GeoListRequest) (*GetGeoIPListResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method GetGeoIPList not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedLibcoreServiceServer) GetGeoSiteList(context.Context, *GeoListRequest) (*GetGeoSiteListResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method GetGeoSiteList not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedLibcoreServiceServer) CompileGeoIPToSrs(context.Context, *CompileGeoIPToSrsRequest) (*EmptyResp, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method CompileGeoIPToSrs not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedLibcoreServiceServer) CompileGeoSiteToSrs(context.Context, *CompileGeoSiteToSrsRequest) (*EmptyResp, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method CompileGeoSiteToSrs not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedLibcoreServiceServer) SetSystemDNS(context.Context, *SetSystemDNSRequest) (*EmptyResp, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method SetSystemDNS not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedLibcoreServiceServer) IsPrivileged(context.Context, *EmptyReq) (*IsPrivilegedResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method IsPrivileged not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedLibcoreServiceServer) SpeedTest(context.Context, *SpeedTestRequest) (*SpeedTestResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method SpeedTest not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedLibcoreServiceServer) QuerySpeedTest(context.Context, *EmptyReq) (*QuerySpeedTestResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method QuerySpeedTest not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedLibcoreServiceServer) mustEmbedUnimplementedLibcoreServiceServer() {}
|
||||||
|
func (UnimplementedLibcoreServiceServer) testEmbeddedByValue() {}
|
||||||
|
|
||||||
|
// UnsafeLibcoreServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||||
|
// Use of this interface is not recommended, as added methods to LibcoreServiceServer will
|
||||||
|
// result in compilation errors.
|
||||||
|
type UnsafeLibcoreServiceServer interface {
|
||||||
|
mustEmbedUnimplementedLibcoreServiceServer()
|
||||||
|
}
|
||||||
|
|
||||||
|
func RegisterLibcoreServiceServer(s grpc.ServiceRegistrar, srv LibcoreServiceServer) {
|
||||||
|
// If the following call pancis, it indicates UnimplementedLibcoreServiceServer was
|
||||||
|
// embedded by pointer and is nil. This will cause panics if an
|
||||||
|
// unimplemented method is ever invoked, so we test this at initialization
|
||||||
|
// time to prevent it from happening at runtime later due to I/O.
|
||||||
|
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||||
|
t.testEmbeddedByValue()
|
||||||
|
}
|
||||||
|
s.RegisterService(&LibcoreService_ServiceDesc, srv)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _LibcoreService_Start_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(LoadConfigReq)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(LibcoreServiceServer).Start(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: LibcoreService_Start_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(LibcoreServiceServer).Start(ctx, req.(*LoadConfigReq))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _LibcoreService_Stop_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(EmptyReq)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(LibcoreServiceServer).Stop(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: LibcoreService_Stop_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(LibcoreServiceServer).Stop(ctx, req.(*EmptyReq))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _LibcoreService_CheckConfig_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(LoadConfigReq)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(LibcoreServiceServer).CheckConfig(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: LibcoreService_CheckConfig_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(LibcoreServiceServer).CheckConfig(ctx, req.(*LoadConfigReq))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _LibcoreService_Test_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(TestReq)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(LibcoreServiceServer).Test(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: LibcoreService_Test_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(LibcoreServiceServer).Test(ctx, req.(*TestReq))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _LibcoreService_StopTest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(EmptyReq)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(LibcoreServiceServer).StopTest(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: LibcoreService_StopTest_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(LibcoreServiceServer).StopTest(ctx, req.(*EmptyReq))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _LibcoreService_QueryURLTest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(EmptyReq)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(LibcoreServiceServer).QueryURLTest(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: LibcoreService_QueryURLTest_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(LibcoreServiceServer).QueryURLTest(ctx, req.(*EmptyReq))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _LibcoreService_QueryStats_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(EmptyReq)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(LibcoreServiceServer).QueryStats(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: LibcoreService_QueryStats_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(LibcoreServiceServer).QueryStats(ctx, req.(*EmptyReq))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _LibcoreService_ListConnections_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(EmptyReq)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(LibcoreServiceServer).ListConnections(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: LibcoreService_ListConnections_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(LibcoreServiceServer).ListConnections(ctx, req.(*EmptyReq))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _LibcoreService_GetGeoIPList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(GeoListRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(LibcoreServiceServer).GetGeoIPList(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: LibcoreService_GetGeoIPList_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(LibcoreServiceServer).GetGeoIPList(ctx, req.(*GeoListRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _LibcoreService_GetGeoSiteList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(GeoListRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(LibcoreServiceServer).GetGeoSiteList(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: LibcoreService_GetGeoSiteList_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(LibcoreServiceServer).GetGeoSiteList(ctx, req.(*GeoListRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _LibcoreService_CompileGeoIPToSrs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(CompileGeoIPToSrsRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(LibcoreServiceServer).CompileGeoIPToSrs(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: LibcoreService_CompileGeoIPToSrs_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(LibcoreServiceServer).CompileGeoIPToSrs(ctx, req.(*CompileGeoIPToSrsRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _LibcoreService_CompileGeoSiteToSrs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(CompileGeoSiteToSrsRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(LibcoreServiceServer).CompileGeoSiteToSrs(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: LibcoreService_CompileGeoSiteToSrs_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(LibcoreServiceServer).CompileGeoSiteToSrs(ctx, req.(*CompileGeoSiteToSrsRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _LibcoreService_SetSystemDNS_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(SetSystemDNSRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(LibcoreServiceServer).SetSystemDNS(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: LibcoreService_SetSystemDNS_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(LibcoreServiceServer).SetSystemDNS(ctx, req.(*SetSystemDNSRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _LibcoreService_IsPrivileged_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(EmptyReq)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(LibcoreServiceServer).IsPrivileged(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: LibcoreService_IsPrivileged_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(LibcoreServiceServer).IsPrivileged(ctx, req.(*EmptyReq))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _LibcoreService_SpeedTest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(SpeedTestRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(LibcoreServiceServer).SpeedTest(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: LibcoreService_SpeedTest_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(LibcoreServiceServer).SpeedTest(ctx, req.(*SpeedTestRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _LibcoreService_QuerySpeedTest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(EmptyReq)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(LibcoreServiceServer).QuerySpeedTest(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: LibcoreService_QuerySpeedTest_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(LibcoreServiceServer).QuerySpeedTest(ctx, req.(*EmptyReq))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
// LibcoreService_ServiceDesc is the grpc.ServiceDesc for LibcoreService service.
|
||||||
|
// It's only intended for direct use with grpc.RegisterService,
|
||||||
|
// and not to be introspected or modified (even as a copy)
|
||||||
|
var LibcoreService_ServiceDesc = grpc.ServiceDesc{
|
||||||
|
ServiceName: "libcore.LibcoreService",
|
||||||
|
HandlerType: (*LibcoreServiceServer)(nil),
|
||||||
|
Methods: []grpc.MethodDesc{
|
||||||
|
{
|
||||||
|
MethodName: "Start",
|
||||||
|
Handler: _LibcoreService_Start_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "Stop",
|
||||||
|
Handler: _LibcoreService_Stop_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "CheckConfig",
|
||||||
|
Handler: _LibcoreService_CheckConfig_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "Test",
|
||||||
|
Handler: _LibcoreService_Test_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "StopTest",
|
||||||
|
Handler: _LibcoreService_StopTest_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "QueryURLTest",
|
||||||
|
Handler: _LibcoreService_QueryURLTest_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "QueryStats",
|
||||||
|
Handler: _LibcoreService_QueryStats_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "ListConnections",
|
||||||
|
Handler: _LibcoreService_ListConnections_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "GetGeoIPList",
|
||||||
|
Handler: _LibcoreService_GetGeoIPList_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "GetGeoSiteList",
|
||||||
|
Handler: _LibcoreService_GetGeoSiteList_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "CompileGeoIPToSrs",
|
||||||
|
Handler: _LibcoreService_CompileGeoIPToSrs_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "CompileGeoSiteToSrs",
|
||||||
|
Handler: _LibcoreService_CompileGeoSiteToSrs_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "SetSystemDNS",
|
||||||
|
Handler: _LibcoreService_SetSystemDNS_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "IsPrivileged",
|
||||||
|
Handler: _LibcoreService_IsPrivileged_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "SpeedTest",
|
||||||
|
Handler: _LibcoreService_SpeedTest_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "QuerySpeedTest",
|
||||||
|
Handler: _LibcoreService_QuerySpeedTest_Handler,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Streams: []grpc.StreamDesc{},
|
||||||
|
Metadata: "libcore.proto",
|
||||||
|
}
|
||||||
@ -167,11 +167,11 @@ void ActivateWindow(QWidget *w);
|
|||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
void runOnUiThread(const std::function<void()> &callback, QObject *parent = nullptr);
|
void runOnUiThread(const std::function<void()> &callback);
|
||||||
|
|
||||||
void runOnNewThread(const std::function<void()> &callback);
|
void runOnNewThread(const std::function<void()> &callback);
|
||||||
|
|
||||||
void runOnThread(const std::function<void()> &callback, QThread *thread);
|
void runOnThread(const std::function<void()> &callback, QObject *parent);
|
||||||
|
|
||||||
template<typename EMITTER, typename SIGNAL, typename RECEIVER, typename ReceiverFunc>
|
template<typename EMITTER, typename SIGNAL, typename RECEIVER, typename ReceiverFunc>
|
||||||
inline void connectOnce(EMITTER *emitter, SIGNAL signal, RECEIVER *receiver, ReceiverFunc f,
|
inline void connectOnce(EMITTER *emitter, SIGNAL signal, RECEIVER *receiver, ReceiverFunc f,
|
||||||
|
|||||||
@ -35,7 +35,6 @@ namespace Configs_sys {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool started = false;
|
bool started = false;
|
||||||
bool killed = false;
|
|
||||||
bool crashed = false;
|
bool crashed = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -209,6 +209,9 @@ private:
|
|||||||
libcore::SpeedTestResult currentTestResult;
|
libcore::SpeedTestResult currentTestResult;
|
||||||
DownloadProgressReport currentDownloadReport; // could use a list, but don't think can show more than one anyways
|
DownloadProgressReport currentDownloadReport; // could use a list, but don't think can show more than one anyways
|
||||||
|
|
||||||
|
QStringList remoteRouteProfiles;
|
||||||
|
QMutex mu_remoteRouteProfiles;
|
||||||
|
|
||||||
QList<std::shared_ptr<Configs::ProxyEntity>> get_now_selected_list();
|
QList<std::shared_ptr<Configs::ProxyEntity>> get_now_selected_list();
|
||||||
|
|
||||||
QList<std::shared_ptr<Configs::ProxyEntity>> get_selected_or_group();
|
QList<std::shared_ptr<Configs::ProxyEntity>> get_selected_or_group();
|
||||||
|
|||||||
@ -155,7 +155,7 @@ namespace QtGrpc {
|
|||||||
QMutex lock;
|
QMutex lock;
|
||||||
lock.lock();
|
lock.lock();
|
||||||
|
|
||||||
runOnUiThread(
|
runOnThread(
|
||||||
[&] {
|
[&] {
|
||||||
err = call(methodName, serviceName, requestArray, responseArray, timeout_ms);
|
err = call(methodName, serviceName, requestArray, responseArray, timeout_ms);
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|||||||
@ -47,7 +47,7 @@ namespace Configs_network {
|
|||||||
// Wait for response
|
// Wait for response
|
||||||
auto abortTimer = new QTimer;
|
auto abortTimer = new QTimer;
|
||||||
abortTimer->setSingleShot(true);
|
abortTimer->setSingleShot(true);
|
||||||
abortTimer->setInterval(10000);
|
abortTimer->setInterval(3000);
|
||||||
connect(abortTimer, &QTimer::timeout, _reply, &QNetworkReply::abort);
|
connect(abortTimer, &QTimer::timeout, _reply, &QNetworkReply::abort);
|
||||||
abortTimer->start();
|
abortTimer->start();
|
||||||
{
|
{
|
||||||
|
|||||||
@ -249,15 +249,11 @@ void ActivateWindow(QWidget *w) {
|
|||||||
w->activateWindow();
|
w->activateWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void runOnUiThread(const std::function<void()> &callback, QObject *parent) {
|
void runOnUiThread(const std::function<void()> &callback) {
|
||||||
// any thread
|
// any thread
|
||||||
auto *timer = new QTimer();
|
auto *timer = new QTimer();
|
||||||
auto thread = dynamic_cast<QThread *>(parent);
|
auto thread = mainwindow->thread();
|
||||||
if (thread == nullptr) {
|
timer->moveToThread(thread);
|
||||||
timer->moveToThread(parent == nullptr ? mainwindow->thread() : parent->thread());
|
|
||||||
} else {
|
|
||||||
timer->moveToThread(thread);
|
|
||||||
}
|
|
||||||
timer->setSingleShot(true);
|
timer->setSingleShot(true);
|
||||||
QObject::connect(timer, &QTimer::timeout, [=]() {
|
QObject::connect(timer, &QTimer::timeout, [=]() {
|
||||||
// main thread
|
// main thread
|
||||||
@ -271,9 +267,14 @@ void runOnNewThread(const std::function<void()> &callback) {
|
|||||||
createQThread(callback)->start();
|
createQThread(callback)->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void runOnThread(const std::function<void()> &callback, QThread *thread) {
|
void runOnThread(const std::function<void()> &callback, QObject *parent) {
|
||||||
auto *timer = new QTimer();
|
auto *timer = new QTimer();
|
||||||
timer->moveToThread(thread);
|
auto thread = dynamic_cast<QThread *>(parent);
|
||||||
|
if (thread == nullptr) {
|
||||||
|
timer->moveToThread(parent->thread());
|
||||||
|
} else {
|
||||||
|
timer->moveToThread(thread);
|
||||||
|
}
|
||||||
timer->setSingleShot(true);
|
timer->setSingleShot(true);
|
||||||
QObject::connect(timer, &QTimer::timeout, [=]() {
|
QObject::connect(timer, &QTimer::timeout, [=]() {
|
||||||
callback();
|
callback();
|
||||||
|
|||||||
@ -10,13 +10,8 @@ namespace Configs_sys {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CoreProcess::Kill() {
|
void CoreProcess::Kill() {
|
||||||
if (killed) return;
|
kill();
|
||||||
killed = true;
|
waitForFinished();
|
||||||
|
|
||||||
if (!crashed) {
|
|
||||||
kill();
|
|
||||||
waitForFinished(500);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreProcess::CoreProcess(const QString &core_path, const QStringList &args) {
|
CoreProcess::CoreProcess(const QString &core_path, const QStringList &args) {
|
||||||
|
|||||||
@ -88,7 +88,7 @@ void GroupItem::refresh_data() {
|
|||||||
ui->subinfo->setText(info.join(" | "));
|
ui->subinfo->setText(info.join(" | "));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
runOnUiThread(
|
runOnThread(
|
||||||
[=] {
|
[=] {
|
||||||
adjustSize();
|
adjustSize();
|
||||||
item->setSizeHint(sizeHint());
|
item->setSizeHint(sizeHint());
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
#include <QStringListModel>
|
#include <QStringListModel>
|
||||||
#include <QCompleter>
|
#include <QCompleter>
|
||||||
|
|
||||||
#define ADJUST_SIZE runOnUiThread([=] { adjustSize(); adjustPosition(mainwindow); }, this);
|
#define ADJUST_SIZE runOnThread([=] { adjustSize(); adjustPosition(mainwindow); }, this);
|
||||||
|
|
||||||
DialogEditGroup::DialogEditGroup(const std::shared_ptr<Configs::Group> &ent, QWidget *parent) : QDialog(parent), ui(new Ui::DialogEditGroup) {
|
DialogEditGroup::DialogEditGroup(const std::shared_ptr<Configs::Group> &ent, QWidget *parent) : QDialog(parent), ui(new Ui::DialogEditGroup) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|||||||
@ -138,7 +138,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
if (Configs::dataStore->flag_debug) args.push_back("-debug");
|
if (Configs::dataStore->flag_debug) args.push_back("-debug");
|
||||||
|
|
||||||
// Start core
|
// Start core
|
||||||
runOnUiThread(
|
runOnThread(
|
||||||
[=] {
|
[=] {
|
||||||
core_process = new Configs_sys::CoreProcess(core_path, args);
|
core_process = new Configs_sys::CoreProcess(core_path, args);
|
||||||
// Remember last started
|
// Remember last started
|
||||||
@ -423,29 +423,36 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QStringList profileList;
|
auto getRemoteRouteProfiles = [=]
|
||||||
for(int retry = 0; retry < 3; retry++) {
|
{
|
||||||
auto resp = NetworkRequestHelper::HttpGet("https://api.github.com/repos/throneproj/routeprofiles/releases/latest");
|
auto resp = NetworkRequestHelper::HttpGet("https://api.github.com/repos/throneproj/routeprofiles/releases/latest");
|
||||||
if (resp.error.isEmpty()) {
|
if (resp.error.isEmpty()) {
|
||||||
|
QStringList newRemoteRouteProfiles;
|
||||||
QJsonObject release = QString2QJsonObject(resp.data);
|
QJsonObject release = QString2QJsonObject(resp.data);
|
||||||
for (const QJsonValue asset : release["assets"].toArray()) {
|
for (const QJsonValue asset : release["assets"].toArray()) {
|
||||||
auto profile = asset["name"].toString();
|
auto profile = asset["name"].toString();
|
||||||
if (profile.section('.', -1) == QString("json") && (profile.startsWith("bypass",Qt::CaseInsensitive) || profile.startsWith("proxy",Qt::CaseInsensitive))) {
|
if (profile.section('.', -1) == QString("json") && (profile.startsWith("bypass",Qt::CaseInsensitive) || profile.startsWith("proxy",Qt::CaseInsensitive))) {
|
||||||
profile.chop(5);
|
profile.chop(5);
|
||||||
profileList.push_back(profile);
|
newRemoteRouteProfiles.push_back(profile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
mu_remoteRouteProfiles.lock();
|
||||||
|
remoteRouteProfiles = newRemoteRouteProfiles;
|
||||||
|
mu_remoteRouteProfiles.unlock();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
runOnNewThread(getRemoteRouteProfiles);
|
||||||
|
|
||||||
connect(ui->menuRouting_Menu, &QMenu::aboutToShow, this, [=]()
|
connect(ui->menuRouting_Menu, &QMenu::aboutToShow, this, [=]()
|
||||||
{
|
{
|
||||||
|
// refresh it on every menu show
|
||||||
|
runOnNewThread(getRemoteRouteProfiles);
|
||||||
ui->menuRouting_Menu->clear();
|
ui->menuRouting_Menu->clear();
|
||||||
ui->menuRouting_Menu->addAction(ui->menu_routing_settings);
|
ui->menuRouting_Menu->addAction(ui->menu_routing_settings);
|
||||||
if(!profileList.isEmpty()) {
|
mu_remoteRouteProfiles.lock();
|
||||||
|
if(!remoteRouteProfiles.isEmpty()) {
|
||||||
QMenu* profilesMenu = ui->menuRouting_Menu->addMenu(QObject::tr("Download Profiles"));
|
QMenu* profilesMenu = ui->menuRouting_Menu->addMenu(QObject::tr("Download Profiles"));
|
||||||
for (const auto& profile : profileList)
|
for (const auto& profile : remoteRouteProfiles)
|
||||||
{
|
{
|
||||||
auto* action = new QAction(profilesMenu);
|
auto* action = new QAction(profilesMenu);
|
||||||
action->setText(profile);
|
action->setText(profile);
|
||||||
@ -461,7 +468,10 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
auto err = new QString;
|
auto err = new QString;
|
||||||
auto parsed = Configs::RoutingChain::parseJsonArray(QString2QJsonArray(resp.data), err);
|
auto parsed = Configs::RoutingChain::parseJsonArray(QString2QJsonArray(resp.data), err);
|
||||||
if (!err->isEmpty()) {
|
if (!err->isEmpty()) {
|
||||||
MessageBoxInfo(tr("Invalid JSON Array"), tr("The provided input cannot be parsed to a valid route rule array:\n") + *err);
|
runOnUiThread([=]
|
||||||
|
{
|
||||||
|
MessageBoxInfo(tr("Invalid JSON Array"), tr("The provided input cannot be parsed to a valid route rule array:\n") + *err);
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto chain = Configs::ProfileManager::NewRouteChain();
|
auto chain = Configs::ProfileManager::NewRouteChain();
|
||||||
@ -474,6 +484,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
profilesMenu->addAction(action);
|
profilesMenu->addAction(action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mu_remoteRouteProfiles.unlock();
|
||||||
|
|
||||||
ui->menuRouting_Menu->addSeparator();
|
ui->menuRouting_Menu->addSeparator();
|
||||||
for (const auto& route : Configs::profileManager->routes)
|
for (const auto& route : Configs::profileManager->routes)
|
||||||
@ -843,7 +854,17 @@ void MainWindow::prepare_exit()
|
|||||||
Configs::dataStore->save_control_no_save = true; // don't change datastore after this line
|
Configs::dataStore->save_control_no_save = true; // don't change datastore after this line
|
||||||
profile_stop(false, true);
|
profile_stop(false, true);
|
||||||
sem_stopped.acquire();
|
sem_stopped.acquire();
|
||||||
core_process->Kill();
|
|
||||||
|
QMutex coreKillMu;
|
||||||
|
coreKillMu.lock();
|
||||||
|
runOnThread([=, &coreKillMu]()
|
||||||
|
{
|
||||||
|
core_process->Kill();
|
||||||
|
coreKillMu.unlock();
|
||||||
|
}, DS_cores);
|
||||||
|
coreKillMu.lock();
|
||||||
|
coreKillMu.unlock();
|
||||||
|
|
||||||
mu_exit.unlock();
|
mu_exit.unlock();
|
||||||
qDebug() << "prepare exit done!";
|
qDebug() << "prepare exit done!";
|
||||||
}
|
}
|
||||||
@ -2236,27 +2257,16 @@ void MainWindow::HotkeyEvent(const QString &key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::StopVPNProcess() {
|
bool MainWindow::StopVPNProcess() {
|
||||||
vpn_pid = core_process->processId();
|
QMutex waitStop;
|
||||||
if (vpn_pid != 0) {
|
waitStop.lock();
|
||||||
bool ok;
|
runOnThread([=, &waitStop]
|
||||||
#ifdef Q_OS_WIN
|
{
|
||||||
auto ret = WinCommander::runProcessElevated("taskkill", {"/F", "/PID", Int2String(vpn_pid)});
|
core_process->Kill();
|
||||||
ok = ret == 0;
|
waitStop.unlock();
|
||||||
#endif
|
}, DS_cores);
|
||||||
|
waitStop.lock();
|
||||||
|
waitStop.unlock();
|
||||||
|
|
||||||
#ifdef Q_OS_MACOS
|
|
||||||
auto ret = system(QString("osascript -e 'do shell script \"kill -9 %1\"' with administrator privileges").arg(vpn_pid).toStdString().c_str());;
|
|
||||||
ok = ret == 0;
|
|
||||||
#endif
|
|
||||||
#ifdef Q_OS_LINUX
|
|
||||||
QProcess p;
|
|
||||||
p.start("pkexec", {"kill", "-9", Int2String(vpn_pid)});
|
|
||||||
p.waitForFinished();
|
|
||||||
ok = p.exitCode() == 0;
|
|
||||||
#endif
|
|
||||||
ok ? vpn_pid = 0 : MessageBoxWarning(tr("Error"), tr("Failed to stop Tun process"));
|
|
||||||
return ok;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -504,7 +504,7 @@ void MainWindow::profile_start(int _id) {
|
|||||||
|
|
||||||
// check core state
|
// check core state
|
||||||
if (!Configs::dataStore->core_running) {
|
if (!Configs::dataStore->core_running) {
|
||||||
runOnUiThread(
|
runOnThread(
|
||||||
[=] {
|
[=] {
|
||||||
MW_show_log(tr("Try to start the config, but the core has not listened to the grpc port, so restart it..."));
|
MW_show_log(tr("Try to start the config, but the core has not listened to the grpc port, so restart it..."));
|
||||||
core_process->start_profile_when_core_is_up = ent->id;
|
core_process->start_profile_when_core_is_up = ent->id;
|
||||||
|
|||||||
@ -25,7 +25,7 @@ void ProxyItem::refresh_data() {
|
|||||||
ui->traffic->setText(ent->traffic_data->DisplayTraffic());
|
ui->traffic->setText(ent->traffic_data->DisplayTraffic());
|
||||||
ui->test_result->setText(ent->DisplayTestResult());
|
ui->test_result->setText(ent->DisplayTestResult());
|
||||||
|
|
||||||
runOnUiThread(
|
runOnThread(
|
||||||
[=] {
|
[=] {
|
||||||
adjustSize();
|
adjustSize();
|
||||||
item->setSizeHint(sizeHint());
|
item->setSizeHint(sizeHint());
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QToolTip>
|
#include <QToolTip>
|
||||||
|
|
||||||
#define ADJUST_SIZE runOnUiThread([=] { adjustSize(); adjustPosition(mainwindow); }, this);
|
#define ADJUST_SIZE runOnThread([=] { adjustSize(); adjustPosition(mainwindow); }, this);
|
||||||
#define LOAD_TYPE(a) ui->type->addItem(Configs::ProfileManager::NewProxyEntity(a)->bean->DisplayType(), a);
|
#define LOAD_TYPE(a) ui->type->addItem(Configs::ProfileManager::NewProxyEntity(a)->bean->DisplayType(), a);
|
||||||
|
|
||||||
DialogEditProfile::DialogEditProfile(const QString &_type, int profileOrGroupId, QWidget *parent)
|
DialogEditProfile::DialogEditProfile(const QString &_type, int profileOrGroupId, QWidget *parent)
|
||||||
@ -397,7 +397,7 @@ void DialogEditProfile::typeSelected(const QString &newType) {
|
|||||||
|
|
||||||
// 第一次显示
|
// 第一次显示
|
||||||
if (isHidden()) {
|
if (isHidden()) {
|
||||||
runOnUiThread([=] { show(); }, this);
|
runOnThread([=] { show(); }, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
#include "include/ui/mainwindow_interface.h"
|
#include "include/ui/mainwindow_interface.h"
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#define ADJUST_SIZE runOnUiThread([=] { adjustSize(); adjustPosition(mainwindow); }, this);
|
#define ADJUST_SIZE runOnThread([=] { adjustSize(); adjustPosition(mainwindow); }, this);
|
||||||
DialogVPNSettings::DialogVPNSettings(QWidget *parent) : QDialog(parent), ui(new Ui::DialogVPNSettings) {
|
DialogVPNSettings::DialogVPNSettings(QWidget *parent) : QDialog(parent), ui(new Ui::DialogVPNSettings) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ADD_ASTERISK(this);
|
ADD_ASTERISK(this);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user