mirror of
https://github.com/netbirdio/netbird.git
synced 2025-06-24 19:51:33 +02:00
remove unnecessary RPC methods
This commit is contained in:
parent
0777f86891
commit
63a8ccc13a
@ -125,3 +125,14 @@ func (pm *ProfileManager) ListProfiles() ([]Profile, error) {
|
|||||||
|
|
||||||
return profiles, nil
|
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)
|
||||||
|
}
|
||||||
|
@ -7,13 +7,14 @@
|
|||||||
package proto
|
package proto
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
reflect "reflect"
|
||||||
|
sync "sync"
|
||||||
|
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
_ "google.golang.org/protobuf/types/descriptorpb"
|
_ "google.golang.org/protobuf/types/descriptorpb"
|
||||||
durationpb "google.golang.org/protobuf/types/known/durationpb"
|
durationpb "google.golang.org/protobuf/types/known/durationpb"
|
||||||
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
|
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
|
||||||
reflect "reflect"
|
|
||||||
sync "sync"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
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, 0x22, 0x00, 0x42, 0x08, 0x5a, 0x06, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70,
|
||||||
0x65, 0x73, 0x12, 0x1a, 0x2e, 0x64, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x2e, 0x47, 0x65, 0x74, 0x50,
|
0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
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,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -4970,36 +4952,28 @@ var file_daemon_proto_depIdxs = []int32{
|
|||||||
48, // 47: daemon.DaemonService.TracePacket:input_type -> daemon.TracePacketRequest
|
48, // 47: daemon.DaemonService.TracePacket:input_type -> daemon.TracePacketRequest
|
||||||
51, // 48: daemon.DaemonService.SubscribeEvents:input_type -> daemon.SubscribeRequest
|
51, // 48: daemon.DaemonService.SubscribeEvents:input_type -> daemon.SubscribeRequest
|
||||||
53, // 49: daemon.DaemonService.GetEvents:input_type -> daemon.GetEventsRequest
|
53, // 49: daemon.DaemonService.GetEvents:input_type -> daemon.GetEventsRequest
|
||||||
56, // 50: daemon.DaemonService.GetProfiles:input_type -> daemon.GetProfilesRequest
|
5, // 50: daemon.DaemonService.Login:output_type -> daemon.LoginResponse
|
||||||
58, // 51: daemon.DaemonService.CreateProfile:input_type -> daemon.CreateProfileRequest
|
7, // 51: daemon.DaemonService.WaitSSOLogin:output_type -> daemon.WaitSSOLoginResponse
|
||||||
60, // 52: daemon.DaemonService.SwitchProfile:input_type -> daemon.SwitchProfileRequest
|
9, // 52: daemon.DaemonService.Up:output_type -> daemon.UpResponse
|
||||||
62, // 53: daemon.DaemonService.RemoveProfile:input_type -> daemon.RemoveProfileRequest
|
11, // 53: daemon.DaemonService.Status:output_type -> daemon.StatusResponse
|
||||||
5, // 54: daemon.DaemonService.Login:output_type -> daemon.LoginResponse
|
13, // 54: daemon.DaemonService.Down:output_type -> daemon.DownResponse
|
||||||
7, // 55: daemon.DaemonService.WaitSSOLogin:output_type -> daemon.WaitSSOLoginResponse
|
15, // 55: daemon.DaemonService.GetConfig:output_type -> daemon.GetConfigResponse
|
||||||
9, // 56: daemon.DaemonService.Up:output_type -> daemon.UpResponse
|
24, // 56: daemon.DaemonService.ListNetworks:output_type -> daemon.ListNetworksResponse
|
||||||
11, // 57: daemon.DaemonService.Status:output_type -> daemon.StatusResponse
|
26, // 57: daemon.DaemonService.SelectNetworks:output_type -> daemon.SelectNetworksResponse
|
||||||
13, // 58: daemon.DaemonService.Down:output_type -> daemon.DownResponse
|
26, // 58: daemon.DaemonService.DeselectNetworks:output_type -> daemon.SelectNetworksResponse
|
||||||
15, // 59: daemon.DaemonService.GetConfig:output_type -> daemon.GetConfigResponse
|
31, // 59: daemon.DaemonService.ForwardingRules:output_type -> daemon.ForwardingRulesResponse
|
||||||
24, // 60: daemon.DaemonService.ListNetworks:output_type -> daemon.ListNetworksResponse
|
33, // 60: daemon.DaemonService.DebugBundle:output_type -> daemon.DebugBundleResponse
|
||||||
26, // 61: daemon.DaemonService.SelectNetworks:output_type -> daemon.SelectNetworksResponse
|
35, // 61: daemon.DaemonService.GetLogLevel:output_type -> daemon.GetLogLevelResponse
|
||||||
26, // 62: daemon.DaemonService.DeselectNetworks:output_type -> daemon.SelectNetworksResponse
|
37, // 62: daemon.DaemonService.SetLogLevel:output_type -> daemon.SetLogLevelResponse
|
||||||
31, // 63: daemon.DaemonService.ForwardingRules:output_type -> daemon.ForwardingRulesResponse
|
40, // 63: daemon.DaemonService.ListStates:output_type -> daemon.ListStatesResponse
|
||||||
33, // 64: daemon.DaemonService.DebugBundle:output_type -> daemon.DebugBundleResponse
|
42, // 64: daemon.DaemonService.CleanState:output_type -> daemon.CleanStateResponse
|
||||||
35, // 65: daemon.DaemonService.GetLogLevel:output_type -> daemon.GetLogLevelResponse
|
44, // 65: daemon.DaemonService.DeleteState:output_type -> daemon.DeleteStateResponse
|
||||||
37, // 66: daemon.DaemonService.SetLogLevel:output_type -> daemon.SetLogLevelResponse
|
46, // 66: daemon.DaemonService.SetNetworkMapPersistence:output_type -> daemon.SetNetworkMapPersistenceResponse
|
||||||
40, // 67: daemon.DaemonService.ListStates:output_type -> daemon.ListStatesResponse
|
50, // 67: daemon.DaemonService.TracePacket:output_type -> daemon.TracePacketResponse
|
||||||
42, // 68: daemon.DaemonService.CleanState:output_type -> daemon.CleanStateResponse
|
52, // 68: daemon.DaemonService.SubscribeEvents:output_type -> daemon.SystemEvent
|
||||||
44, // 69: daemon.DaemonService.DeleteState:output_type -> daemon.DeleteStateResponse
|
54, // 69: daemon.DaemonService.GetEvents:output_type -> daemon.GetEventsResponse
|
||||||
46, // 70: daemon.DaemonService.SetNetworkMapPersistence:output_type -> daemon.SetNetworkMapPersistenceResponse
|
50, // [50:70] is the sub-list for method output_type
|
||||||
50, // 71: daemon.DaemonService.TracePacket:output_type -> daemon.TracePacketResponse
|
30, // [30:50] is the sub-list for method input_type
|
||||||
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
|
|
||||||
30, // [30:30] is the sub-list for extension type_name
|
30, // [30:30] is the sub-list for extension type_name
|
||||||
30, // [30:30] is the sub-list for extension extendee
|
30, // [30:30] is the sub-list for extension extendee
|
||||||
0, // [0:30] is the sub-list for field type_name
|
0, // [0:30] is the sub-list for field type_name
|
||||||
|
@ -67,16 +67,6 @@ service DaemonService {
|
|||||||
rpc SubscribeEvents(SubscribeRequest) returns (stream SystemEvent) {}
|
rpc SubscribeEvents(SubscribeRequest) returns (stream SystemEvent) {}
|
||||||
|
|
||||||
rpc GetEvents(GetEventsRequest) returns (GetEventsResponse) {}
|
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) {}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,11 +55,6 @@ type DaemonServiceClient interface {
|
|||||||
TracePacket(ctx context.Context, in *TracePacketRequest, opts ...grpc.CallOption) (*TracePacketResponse, error)
|
TracePacket(ctx context.Context, in *TracePacketRequest, opts ...grpc.CallOption) (*TracePacketResponse, error)
|
||||||
SubscribeEvents(ctx context.Context, in *SubscribeRequest, opts ...grpc.CallOption) (DaemonService_SubscribeEventsClient, error)
|
SubscribeEvents(ctx context.Context, in *SubscribeRequest, opts ...grpc.CallOption) (DaemonService_SubscribeEventsClient, error)
|
||||||
GetEvents(ctx context.Context, in *GetEventsRequest, opts ...grpc.CallOption) (*GetEventsResponse, 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 {
|
type daemonServiceClient struct {
|
||||||
@ -273,42 +268,6 @@ func (c *daemonServiceClient) GetEvents(ctx context.Context, in *GetEventsReques
|
|||||||
return out, nil
|
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.
|
// DaemonServiceServer is the server API for DaemonService service.
|
||||||
// All implementations must embed UnimplementedDaemonServiceServer
|
// All implementations must embed UnimplementedDaemonServiceServer
|
||||||
// for forward compatibility
|
// for forward compatibility
|
||||||
@ -350,11 +309,6 @@ type DaemonServiceServer interface {
|
|||||||
TracePacket(context.Context, *TracePacketRequest) (*TracePacketResponse, error)
|
TracePacket(context.Context, *TracePacketRequest) (*TracePacketResponse, error)
|
||||||
SubscribeEvents(*SubscribeRequest, DaemonService_SubscribeEventsServer) error
|
SubscribeEvents(*SubscribeRequest, DaemonService_SubscribeEventsServer) error
|
||||||
GetEvents(context.Context, *GetEventsRequest) (*GetEventsResponse, 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()
|
mustEmbedUnimplementedDaemonServiceServer()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -422,18 +376,6 @@ func (UnimplementedDaemonServiceServer) SubscribeEvents(*SubscribeRequest, Daemo
|
|||||||
func (UnimplementedDaemonServiceServer) GetEvents(context.Context, *GetEventsRequest) (*GetEventsResponse, error) {
|
func (UnimplementedDaemonServiceServer) GetEvents(context.Context, *GetEventsRequest) (*GetEventsResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method GetEvents not implemented")
|
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() {}
|
func (UnimplementedDaemonServiceServer) mustEmbedUnimplementedDaemonServiceServer() {}
|
||||||
|
|
||||||
// UnsafeDaemonServiceServer may be embedded to opt out of forward compatibility for this service.
|
// 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)
|
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.
|
// DaemonService_ServiceDesc is the grpc.ServiceDesc for DaemonService service.
|
||||||
// It's only intended for direct use with grpc.RegisterService,
|
// It's only intended for direct use with grpc.RegisterService,
|
||||||
// and not to be introspected or modified (even as a copy)
|
// and not to be introspected or modified (even as a copy)
|
||||||
@ -965,22 +835,6 @@ var DaemonService_ServiceDesc = grpc.ServiceDesc{
|
|||||||
MethodName: "GetEvents",
|
MethodName: "GetEvents",
|
||||||
Handler: _DaemonService_GetEvents_Handler,
|
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{
|
Streams: []grpc.StreamDesc{
|
||||||
{
|
{
|
||||||
|
@ -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)
|
|
||||||
}
|
|
@ -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")
|
|
||||||
}
|
|
@ -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")
|
|
||||||
}
|
|
@ -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")
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user