From 63a8ccc13ad2abc3f2f1119a4fa1ddfc2b606130 Mon Sep 17 00:00:00 2001 From: Hakan Sariman Date: Sun, 22 Jun 2025 09:35:10 +0300 Subject: [PATCH] remove unnecessary RPC methods --- .../internal/profilemanager/profilemanager.go | 11 ++ client/proto/daemon.pb.go | 82 ++++------ client/proto/daemon.proto | 10 -- client/proto/daemon_grpc.pb.go | 146 ------------------ client/server/profile.go | 77 --------- client/server/profile_darwin.go | 14 -- client/server/profile_unix.go | 15 -- client/server/profile_windows.go | 17 -- 8 files changed, 39 insertions(+), 333 deletions(-) delete mode 100644 client/server/profile.go delete mode 100644 client/server/profile_darwin.go delete mode 100644 client/server/profile_unix.go delete mode 100644 client/server/profile_windows.go diff --git a/client/internal/profilemanager/profilemanager.go b/client/internal/profilemanager/profilemanager.go index fb532cd76..1ad69c4ec 100644 --- a/client/internal/profilemanager/profilemanager.go +++ b/client/internal/profilemanager/profilemanager.go @@ -125,3 +125,14 @@ func (pm *ProfileManager) ListProfiles() ([]Profile, error) { return profiles, nil } + +// sanitazeUsername sanitizes the username by removing any invalid characters +func sanitazeUsername(username string) string { + // Remove invalid characters for a username in a file path + return strings.Map(func(r rune) rune { + if r == '/' || r == '\\' || r == ':' || r == '*' || r == '?' || r == '"' || r == '<' || r == '>' || r == '|' { + return -1 // remove this character + } + return r + }, username) +} diff --git a/client/proto/daemon.pb.go b/client/proto/daemon.pb.go index 1c8388701..968399165 100644 --- a/client/proto/daemon.pb.go +++ b/client/proto/daemon.pb.go @@ -7,13 +7,14 @@ package proto import ( + reflect "reflect" + sync "sync" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" _ "google.golang.org/protobuf/types/descriptorpb" durationpb "google.golang.org/protobuf/types/known/durationpb" timestamppb "google.golang.org/protobuf/types/known/timestamppb" - reflect "reflect" - sync "sync" ) const ( @@ -4719,7 +4720,7 @@ var file_daemon_proto_rawDesc = []byte{ 0x05, 0x46, 0x41, 0x54, 0x41, 0x4c, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x57, 0x41, 0x52, 0x4e, 0x10, 0x04, 0x12, 0x08, 0x0a, 0x04, 0x49, 0x4e, 0x46, 0x4f, 0x10, 0x05, 0x12, 0x09, 0x0a, 0x05, 0x44, 0x45, 0x42, 0x55, 0x47, - 0x10, 0x06, 0x12, 0x09, 0x0a, 0x05, 0x54, 0x52, 0x41, 0x43, 0x45, 0x10, 0x07, 0x32, 0xed, 0x0d, + 0x10, 0x06, 0x12, 0x09, 0x0a, 0x05, 0x54, 0x52, 0x41, 0x43, 0x45, 0x10, 0x07, 0x32, 0xb3, 0x0b, 0x0a, 0x0d, 0x44, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x36, 0x0a, 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x14, 0x2e, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, @@ -4811,27 +4812,8 @@ var file_daemon_proto_rawDesc = []byte{ 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x47, 0x65, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x47, 0x65, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x00, 0x12, 0x48, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, - 0x65, 0x73, 0x12, 0x1a, 0x2e, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x47, 0x65, 0x74, 0x50, - 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, - 0x2e, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x66, 0x69, - 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4e, 0x0a, - 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x1c, - 0x2e, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, - 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x64, - 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x66, - 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4e, 0x0a, - 0x0d, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x1c, - 0x2e, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68, 0x50, 0x72, - 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x64, - 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68, 0x50, 0x72, 0x6f, 0x66, - 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4e, 0x0a, - 0x0d, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x1c, - 0x2e, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x50, 0x72, - 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x64, - 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x50, 0x72, 0x6f, 0x66, - 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x08, 0x5a, - 0x06, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x22, 0x00, 0x42, 0x08, 0x5a, 0x06, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -4970,36 +4952,28 @@ var file_daemon_proto_depIdxs = []int32{ 48, // 47: daemon.DaemonService.TracePacket:input_type -> daemon.TracePacketRequest 51, // 48: daemon.DaemonService.SubscribeEvents:input_type -> daemon.SubscribeRequest 53, // 49: daemon.DaemonService.GetEvents:input_type -> daemon.GetEventsRequest - 56, // 50: daemon.DaemonService.GetProfiles:input_type -> daemon.GetProfilesRequest - 58, // 51: daemon.DaemonService.CreateProfile:input_type -> daemon.CreateProfileRequest - 60, // 52: daemon.DaemonService.SwitchProfile:input_type -> daemon.SwitchProfileRequest - 62, // 53: daemon.DaemonService.RemoveProfile:input_type -> daemon.RemoveProfileRequest - 5, // 54: daemon.DaemonService.Login:output_type -> daemon.LoginResponse - 7, // 55: daemon.DaemonService.WaitSSOLogin:output_type -> daemon.WaitSSOLoginResponse - 9, // 56: daemon.DaemonService.Up:output_type -> daemon.UpResponse - 11, // 57: daemon.DaemonService.Status:output_type -> daemon.StatusResponse - 13, // 58: daemon.DaemonService.Down:output_type -> daemon.DownResponse - 15, // 59: daemon.DaemonService.GetConfig:output_type -> daemon.GetConfigResponse - 24, // 60: daemon.DaemonService.ListNetworks:output_type -> daemon.ListNetworksResponse - 26, // 61: daemon.DaemonService.SelectNetworks:output_type -> daemon.SelectNetworksResponse - 26, // 62: daemon.DaemonService.DeselectNetworks:output_type -> daemon.SelectNetworksResponse - 31, // 63: daemon.DaemonService.ForwardingRules:output_type -> daemon.ForwardingRulesResponse - 33, // 64: daemon.DaemonService.DebugBundle:output_type -> daemon.DebugBundleResponse - 35, // 65: daemon.DaemonService.GetLogLevel:output_type -> daemon.GetLogLevelResponse - 37, // 66: daemon.DaemonService.SetLogLevel:output_type -> daemon.SetLogLevelResponse - 40, // 67: daemon.DaemonService.ListStates:output_type -> daemon.ListStatesResponse - 42, // 68: daemon.DaemonService.CleanState:output_type -> daemon.CleanStateResponse - 44, // 69: daemon.DaemonService.DeleteState:output_type -> daemon.DeleteStateResponse - 46, // 70: daemon.DaemonService.SetNetworkMapPersistence:output_type -> daemon.SetNetworkMapPersistenceResponse - 50, // 71: daemon.DaemonService.TracePacket:output_type -> daemon.TracePacketResponse - 52, // 72: daemon.DaemonService.SubscribeEvents:output_type -> daemon.SystemEvent - 54, // 73: daemon.DaemonService.GetEvents:output_type -> daemon.GetEventsResponse - 57, // 74: daemon.DaemonService.GetProfiles:output_type -> daemon.GetProfilesResponse - 59, // 75: daemon.DaemonService.CreateProfile:output_type -> daemon.CreateProfileResponse - 61, // 76: daemon.DaemonService.SwitchProfile:output_type -> daemon.SwitchProfileResponse - 63, // 77: daemon.DaemonService.RemoveProfile:output_type -> daemon.RemoveProfileResponse - 54, // [54:78] is the sub-list for method output_type - 30, // [30:54] is the sub-list for method input_type + 5, // 50: daemon.DaemonService.Login:output_type -> daemon.LoginResponse + 7, // 51: daemon.DaemonService.WaitSSOLogin:output_type -> daemon.WaitSSOLoginResponse + 9, // 52: daemon.DaemonService.Up:output_type -> daemon.UpResponse + 11, // 53: daemon.DaemonService.Status:output_type -> daemon.StatusResponse + 13, // 54: daemon.DaemonService.Down:output_type -> daemon.DownResponse + 15, // 55: daemon.DaemonService.GetConfig:output_type -> daemon.GetConfigResponse + 24, // 56: daemon.DaemonService.ListNetworks:output_type -> daemon.ListNetworksResponse + 26, // 57: daemon.DaemonService.SelectNetworks:output_type -> daemon.SelectNetworksResponse + 26, // 58: daemon.DaemonService.DeselectNetworks:output_type -> daemon.SelectNetworksResponse + 31, // 59: daemon.DaemonService.ForwardingRules:output_type -> daemon.ForwardingRulesResponse + 33, // 60: daemon.DaemonService.DebugBundle:output_type -> daemon.DebugBundleResponse + 35, // 61: daemon.DaemonService.GetLogLevel:output_type -> daemon.GetLogLevelResponse + 37, // 62: daemon.DaemonService.SetLogLevel:output_type -> daemon.SetLogLevelResponse + 40, // 63: daemon.DaemonService.ListStates:output_type -> daemon.ListStatesResponse + 42, // 64: daemon.DaemonService.CleanState:output_type -> daemon.CleanStateResponse + 44, // 65: daemon.DaemonService.DeleteState:output_type -> daemon.DeleteStateResponse + 46, // 66: daemon.DaemonService.SetNetworkMapPersistence:output_type -> daemon.SetNetworkMapPersistenceResponse + 50, // 67: daemon.DaemonService.TracePacket:output_type -> daemon.TracePacketResponse + 52, // 68: daemon.DaemonService.SubscribeEvents:output_type -> daemon.SystemEvent + 54, // 69: daemon.DaemonService.GetEvents:output_type -> daemon.GetEventsResponse + 50, // [50:70] is the sub-list for method output_type + 30, // [30:50] is the sub-list for method input_type 30, // [30:30] is the sub-list for extension type_name 30, // [30:30] is the sub-list for extension extendee 0, // [0:30] is the sub-list for field type_name diff --git a/client/proto/daemon.proto b/client/proto/daemon.proto index 44d5abc3e..fa37d4ebc 100644 --- a/client/proto/daemon.proto +++ b/client/proto/daemon.proto @@ -67,16 +67,6 @@ service DaemonService { rpc SubscribeEvents(SubscribeRequest) returns (stream SystemEvent) {} rpc GetEvents(GetEventsRequest) returns (GetEventsResponse) {} - - // Profiles - rpc GetProfiles(GetProfilesRequest) returns (GetProfilesResponse) {} - - rpc CreateProfile(CreateProfileRequest) returns (CreateProfileResponse) {} - - rpc SwitchProfile(SwitchProfileRequest) returns (SwitchProfileResponse) {} - - rpc RemoveProfile(RemoveProfileRequest) returns (RemoveProfileResponse) {} - } diff --git a/client/proto/daemon_grpc.pb.go b/client/proto/daemon_grpc.pb.go index b6c3e41b9..6251f7c52 100644 --- a/client/proto/daemon_grpc.pb.go +++ b/client/proto/daemon_grpc.pb.go @@ -55,11 +55,6 @@ type DaemonServiceClient interface { TracePacket(ctx context.Context, in *TracePacketRequest, opts ...grpc.CallOption) (*TracePacketResponse, error) SubscribeEvents(ctx context.Context, in *SubscribeRequest, opts ...grpc.CallOption) (DaemonService_SubscribeEventsClient, error) GetEvents(ctx context.Context, in *GetEventsRequest, opts ...grpc.CallOption) (*GetEventsResponse, error) - // Profiles - GetProfiles(ctx context.Context, in *GetProfilesRequest, opts ...grpc.CallOption) (*GetProfilesResponse, error) - CreateProfile(ctx context.Context, in *CreateProfileRequest, opts ...grpc.CallOption) (*CreateProfileResponse, error) - SwitchProfile(ctx context.Context, in *SwitchProfileRequest, opts ...grpc.CallOption) (*SwitchProfileResponse, error) - RemoveProfile(ctx context.Context, in *RemoveProfileRequest, opts ...grpc.CallOption) (*RemoveProfileResponse, error) } type daemonServiceClient struct { @@ -273,42 +268,6 @@ func (c *daemonServiceClient) GetEvents(ctx context.Context, in *GetEventsReques return out, nil } -func (c *daemonServiceClient) GetProfiles(ctx context.Context, in *GetProfilesRequest, opts ...grpc.CallOption) (*GetProfilesResponse, error) { - out := new(GetProfilesResponse) - err := c.cc.Invoke(ctx, "/daemon.DaemonService/GetProfiles", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *daemonServiceClient) CreateProfile(ctx context.Context, in *CreateProfileRequest, opts ...grpc.CallOption) (*CreateProfileResponse, error) { - out := new(CreateProfileResponse) - err := c.cc.Invoke(ctx, "/daemon.DaemonService/CreateProfile", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *daemonServiceClient) SwitchProfile(ctx context.Context, in *SwitchProfileRequest, opts ...grpc.CallOption) (*SwitchProfileResponse, error) { - out := new(SwitchProfileResponse) - err := c.cc.Invoke(ctx, "/daemon.DaemonService/SwitchProfile", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *daemonServiceClient) RemoveProfile(ctx context.Context, in *RemoveProfileRequest, opts ...grpc.CallOption) (*RemoveProfileResponse, error) { - out := new(RemoveProfileResponse) - err := c.cc.Invoke(ctx, "/daemon.DaemonService/RemoveProfile", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - // DaemonServiceServer is the server API for DaemonService service. // All implementations must embed UnimplementedDaemonServiceServer // for forward compatibility @@ -350,11 +309,6 @@ type DaemonServiceServer interface { TracePacket(context.Context, *TracePacketRequest) (*TracePacketResponse, error) SubscribeEvents(*SubscribeRequest, DaemonService_SubscribeEventsServer) error GetEvents(context.Context, *GetEventsRequest) (*GetEventsResponse, error) - // Profiles - GetProfiles(context.Context, *GetProfilesRequest) (*GetProfilesResponse, error) - CreateProfile(context.Context, *CreateProfileRequest) (*CreateProfileResponse, error) - SwitchProfile(context.Context, *SwitchProfileRequest) (*SwitchProfileResponse, error) - RemoveProfile(context.Context, *RemoveProfileRequest) (*RemoveProfileResponse, error) mustEmbedUnimplementedDaemonServiceServer() } @@ -422,18 +376,6 @@ func (UnimplementedDaemonServiceServer) SubscribeEvents(*SubscribeRequest, Daemo func (UnimplementedDaemonServiceServer) GetEvents(context.Context, *GetEventsRequest) (*GetEventsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetEvents not implemented") } -func (UnimplementedDaemonServiceServer) GetProfiles(context.Context, *GetProfilesRequest) (*GetProfilesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetProfiles not implemented") -} -func (UnimplementedDaemonServiceServer) CreateProfile(context.Context, *CreateProfileRequest) (*CreateProfileResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateProfile not implemented") -} -func (UnimplementedDaemonServiceServer) SwitchProfile(context.Context, *SwitchProfileRequest) (*SwitchProfileResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method SwitchProfile not implemented") -} -func (UnimplementedDaemonServiceServer) RemoveProfile(context.Context, *RemoveProfileRequest) (*RemoveProfileResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method RemoveProfile not implemented") -} func (UnimplementedDaemonServiceServer) mustEmbedUnimplementedDaemonServiceServer() {} // UnsafeDaemonServiceServer may be embedded to opt out of forward compatibility for this service. @@ -810,78 +752,6 @@ func _DaemonService_GetEvents_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } -func _DaemonService_GetProfiles_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetProfilesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(DaemonServiceServer).GetProfiles(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/daemon.DaemonService/GetProfiles", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(DaemonServiceServer).GetProfiles(ctx, req.(*GetProfilesRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _DaemonService_CreateProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateProfileRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(DaemonServiceServer).CreateProfile(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/daemon.DaemonService/CreateProfile", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(DaemonServiceServer).CreateProfile(ctx, req.(*CreateProfileRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _DaemonService_SwitchProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(SwitchProfileRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(DaemonServiceServer).SwitchProfile(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/daemon.DaemonService/SwitchProfile", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(DaemonServiceServer).SwitchProfile(ctx, req.(*SwitchProfileRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _DaemonService_RemoveProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(RemoveProfileRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(DaemonServiceServer).RemoveProfile(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/daemon.DaemonService/RemoveProfile", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(DaemonServiceServer).RemoveProfile(ctx, req.(*RemoveProfileRequest)) - } - return interceptor(ctx, in, info, handler) -} - // DaemonService_ServiceDesc is the grpc.ServiceDesc for DaemonService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -965,22 +835,6 @@ var DaemonService_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetEvents", Handler: _DaemonService_GetEvents_Handler, }, - { - MethodName: "GetProfiles", - Handler: _DaemonService_GetProfiles_Handler, - }, - { - MethodName: "CreateProfile", - Handler: _DaemonService_CreateProfile_Handler, - }, - { - MethodName: "SwitchProfile", - Handler: _DaemonService_SwitchProfile_Handler, - }, - { - MethodName: "RemoveProfile", - Handler: _DaemonService_RemoveProfile_Handler, - }, }, Streams: []grpc.StreamDesc{ { diff --git a/client/server/profile.go b/client/server/profile.go deleted file mode 100644 index 9a48ffbb7..000000000 --- a/client/server/profile.go +++ /dev/null @@ -1,77 +0,0 @@ -package server - -import ( - "context" - "strings" - - "github.com/netbirdio/netbird/client/proto" -) - -// GetProfiles returns a list of all available profiles. -func (s *Server) GetProfiles(context.Context, *proto.GetProfilesRequest) (*proto.GetProfilesResponse, error) { - s.mutex.Lock() - defer s.mutex.Unlock() - - mockProfiles := []*proto.Profile{ - { - Name: "default", - Selected: true, - }, - { - Name: "work", - Selected: false, - }, - { - Name: "home", - Selected: false, - }, - } - - return &proto.GetProfilesResponse{ - Profiles: mockProfiles, - }, nil -} - -// CreateProfile creates a new profile with the specified name. -func (s *Server) CreateProfile(ctx context.Context, req *proto.CreateProfileRequest) (*proto.CreateProfileResponse, error) { - s.mutex.Lock() - defer s.mutex.Unlock() - - return &proto.CreateProfileResponse{ - Success: true, - Error: "", - }, nil -} - -// SwitchProfile switches the current profile to the one specified in the request. -func (s *Server) SwitchProfile(ctx context.Context, req *proto.SwitchProfileRequest) (*proto.SwitchProfileResponse, error) { - s.mutex.Lock() - defer s.mutex.Unlock() - - return &proto.SwitchProfileResponse{ - Success: true, - Error: "", - }, nil -} - -// RemoveProfile removes the specified profile from the server. -func (s *Server) RemoveProfile(ctx context.Context, req *proto.RemoveProfileRequest) (*proto.RemoveProfileResponse, error) { - s.mutex.Lock() - defer s.mutex.Unlock() - - return &proto.RemoveProfileResponse{ - Success: true, - Error: "", - }, nil -} - -// sanitazeUsername sanitizes the username by removing any invalid characters -func sanitazeUsername(username string) string { - // Remove invalid characters for a username in a file path - return strings.Map(func(r rune) rune { - if r == '/' || r == '\\' || r == ':' || r == '*' || r == '?' || r == '"' || r == '<' || r == '>' || r == '|' { - return -1 // remove this character - } - return r - }, username) -} diff --git a/client/server/profile_darwin.go b/client/server/profile_darwin.go deleted file mode 100644 index 6d5c66a91..000000000 --- a/client/server/profile_darwin.go +++ /dev/null @@ -1,14 +0,0 @@ -//go:build darwin -// +build darwin - -package server - -import "path/filepath" - -func getSystemProfilesDir() string { - return "/Library/Application Support/Netbird/Profiles" -} - -func getUserProfilesDir(username string) string { - return filepath.Join("/Users", sanitazeUsername(username), "Library", "Application Support", "Netbird", "Profiles") -} diff --git a/client/server/profile_unix.go b/client/server/profile_unix.go deleted file mode 100644 index b0f4eb403..000000000 --- a/client/server/profile_unix.go +++ /dev/null @@ -1,15 +0,0 @@ -//go:build linux || dragonfly || freebsd || netbsd || openbsd -// +build linux dragonfly freebsd netbsd openbsd - -package server - -import "path/filepath" - -func getSystemProfilesDir() string { - return "/var/lib/netbird/profiles" -} - -func getUserProfilesDir(username string) string { - // ~/.config/netbird/profiles - return filepath.Join("/home", sanitazeUsername(username), ".config", "netbird", "profiles") -} diff --git a/client/server/profile_windows.go b/client/server/profile_windows.go deleted file mode 100644 index 9698e1396..000000000 --- a/client/server/profile_windows.go +++ /dev/null @@ -1,17 +0,0 @@ -//go:build windows -// +build windows - -package server - -import ( - "os" - "path/filepath" -) - -func getSystemProfilesDir() string { - return filepath.Join(os.Getenv("PROGRAMDATA"), "Netbird", "Profiles") -} - -func getUserProfilesDir(username string) string { - return filepath.Join(os.Getenv("LOCALAPPDATA"), "Netbird", "Profiles") -}