From a4b067006ae20b1996badf7b64f67586533c688f Mon Sep 17 00:00:00 2001 From: Hiddify Date: Sun, 3 Mar 2024 04:15:19 +0100 Subject: [PATCH] new: add hiddifyrpc --- Makefile | 3 + admin_service/service.go | 2 +- config/config.go | 2 + config/outbound.go | 3 + config/parser.go | 4 + custom/command_server.go | 11 +- custom/custom.go | 33 +- custom/status.go | 37 +- hiddifyrpc/hiddify.pb.go | 1662 +++++++++++++++++++++++++++++++++ hiddifyrpc/hiddify.proto | 214 +++++ hiddifyrpc/hiddify_grpc.pb.go | 935 +++++++++++++++++++ v2/command_client.go | 77 ++ v2/commands.go | 163 ++++ v2/coreinfo.go | 44 + v2/custom.go | 232 +++++ v2/example_client/main.go | 62 ++ v2/example_server/main.go | 16 + v2/grpc_server.go | 34 + v2/hello.go | 36 + v2/logproto.go | 41 + v2/service.go | 68 ++ v2/warp.go | 65 ++ 22 files changed, 3715 insertions(+), 29 deletions(-) create mode 100644 hiddifyrpc/hiddify.pb.go create mode 100644 hiddifyrpc/hiddify.proto create mode 100644 hiddifyrpc/hiddify_grpc.pb.go create mode 100644 v2/command_client.go create mode 100644 v2/commands.go create mode 100644 v2/coreinfo.go create mode 100644 v2/custom.go create mode 100644 v2/example_client/main.go create mode 100644 v2/example_server/main.go create mode 100644 v2/grpc_server.go create mode 100644 v2/hello.go create mode 100644 v2/logproto.go create mode 100644 v2/service.go create mode 100644 v2/warp.go diff --git a/Makefile b/Makefile index 12de668..1a30e53 100644 --- a/Makefile +++ b/Makefile @@ -69,6 +69,9 @@ macos-universal: macos-amd64 macos-arm64 clean: rm $(BINDIR)/* +build_protobuf: + protoc --go_out=. --go-grpc_out=. hiddifyrpc/hiddify.proto + release: # Create a new tag for release. @echo "previous version was $$(git describe --tags $$(git rev-list --tags --max-count=1))" diff --git a/admin_service/service.go b/admin_service/service.go index f24712f..a33d25c 100644 --- a/admin_service/service.go +++ b/admin_service/service.go @@ -46,7 +46,7 @@ func getCurrentExecutableDirectory() string { } func StartService(goArg string) (int, string) { svcConfig := &service.Config{ - Name: "Hiddify Tunnel Service", + Name: "HiddifyTunnelService", DisplayName: "Hiddify Tunnel Service", Description: "This is a bridge for tunnel", Option: map[string]interface{}{ diff --git a/config/config.go b/config/config.go index 44b912c..fce5ea3 100644 --- a/config/config.go +++ b/config/config.go @@ -2,6 +2,7 @@ package config import ( "bytes" + "runtime" "encoding/json" "fmt" @@ -149,6 +150,7 @@ func BuildConfig(opt ConfigOptions, input option.Options) (*option.Options, erro AutoRoute: true, StrictRoute: opt.StrictRoute, EndpointIndependentNat: true, + GSO: runtime.GOOS != "windows", InboundOptions: option.InboundOptions{ SniffEnabled: true, SniffOverrideDestination: true, diff --git a/config/outbound.go b/config/outbound.go index 3f9b082..258d528 100644 --- a/config/outbound.go +++ b/config/outbound.go @@ -175,6 +175,9 @@ func patchWarp(base *option.Outbound) error { if base.WireGuardOptions.ServerPort == 0 { base.WireGuardOptions.ServerPort = generateRandomPort() } + // if base.WireGuardOptions.Detour == "" { + // base.WireGuardOptions.GSO = runtime.GOOS != "windows" + // } } if base.Type == C.TypeCustom { if warp, ok := base.CustomOptions["warp"].(map[string]interface{}); ok { diff --git a/config/parser.go b/config/parser.go index 37d2cdf..3cbedc6 100644 --- a/config/parser.go +++ b/config/parser.go @@ -29,6 +29,10 @@ func ParseConfig(path string, debug bool) ([]byte, error) { if err != nil { return nil, err } + return ParseConfigContent(string(content), debug) +} +func ParseConfigContent(contentstr string, debug bool) ([]byte, error) { + content := []byte(contentstr) var jsonObj map[string]interface{} = make(map[string]interface{}) fmt.Printf("Convert using json\n") diff --git a/custom/command_server.go b/custom/command_server.go index d90bfe1..17483b2 100644 --- a/custom/command_server.go +++ b/custom/command_server.go @@ -1,8 +1,11 @@ package main import ( + pb "github.com/hiddify/libcore/hiddifyrpc" + v2 "github.com/hiddify/libcore/v2" "github.com/sagernet/sing-box/experimental/libbox" "github.com/sagernet/sing-box/log" + ) var commandServer *libbox.CommandServer @@ -13,14 +16,14 @@ type CommandServerHandler struct { func (csh *CommandServerHandler) ServiceReload() error { csh.logger.Trace("Reloading service") - propagateStatus(Starting) + propagateStatus(pb.CoreState_STARTING) if commandServer != nil { commandServer.SetService(nil) commandServer = nil } - if box != nil { - box.Close() - box = nil + if v2.Box != nil { + v2.Box.Close() + v2.Box = nil } return startService(true) } diff --git a/custom/custom.go b/custom/custom.go index 903d752..48c0532 100644 --- a/custom/custom.go +++ b/custom/custom.go @@ -15,12 +15,15 @@ import ( "github.com/hiddify/libcore/bridge" "github.com/hiddify/libcore/config" + pb "github.com/hiddify/libcore/hiddifyrpc" + v2 "github.com/hiddify/libcore/v2" + "github.com/sagernet/sing-box/experimental/libbox" "github.com/sagernet/sing-box/log" "github.com/sagernet/sing-box/option" ) -var box *libbox.BoxService +// var v2.Box *libbox.BoxService var configOptions *config.ConfigOptions var activeConfigPath *string var logFactory *log.Factory @@ -132,10 +135,10 @@ func start(configPath *C.char, disableMemoryLimit bool) (CErr *C.char) { CErr = C.CString(err.Error()) }) - if status != Stopped { + if v2.CoreState != pb.CoreState_STOPPED { return C.CString("") } - propagateStatus(Starting) + propagateStatus(pb.CoreState_STARTING) path := C.GoString(configPath) activeConfigPath = &path @@ -184,10 +187,10 @@ func startService(delayStart bool) error { if err != nil { return stopAndAlert(StartService, err) } - box = instance - commandServer.SetService(box) + v2.Box = instance + commandServer.SetService(v2.Box) - propagateStatus(Started) + propagateStatus(pb.CoreState_STARTED) return nil } @@ -198,29 +201,29 @@ func stop() (CErr *C.char) { CErr = C.CString(err.Error()) }) config.DeactivateTunnelService() - if status != Started { + if v2.CoreState != pb.CoreState_STARTED { stopAndAlert("Already Stopped", nil) return C.CString("") } - if box == nil { + if v2.Box == nil { return C.CString("instance not found") } - propagateStatus(Stopping) + propagateStatus(pb.CoreState_STOPPING) commandServer.SetService(nil) - err := box.Close() + err := v2.Box.Close() if err != nil { stopAndAlert("Unexpected Error in Close!", err) return C.CString(err.Error()) } - box = nil + v2.Box = nil err = commandServer.Close() if err != nil { stopAndAlert("Unexpected Error in Stop CommandServer/!", err) return C.CString(err.Error()) } commandServer = nil - propagateStatus(Stopped) + propagateStatus(pb.CoreState_STOPPED) return C.CString("") } @@ -232,10 +235,10 @@ func restart(configPath *C.char, disableMemoryLimit bool) (CErr *C.char) { }) log.Debug("[Service] Restarting") - if status != Started { + if v2.CoreState != pb.CoreState_STARTED { return C.CString("") } - if box == nil { + if v2.Box == nil { return C.CString("instance not found") } @@ -244,7 +247,7 @@ func restart(configPath *C.char, disableMemoryLimit bool) (CErr *C.char) { return err } - propagateStatus(Starting) + propagateStatus(pb.CoreState_STARTING) time.Sleep(250 * time.Millisecond) diff --git a/custom/status.go b/custom/status.go index 02b81a1..4b2ec53 100644 --- a/custom/status.go +++ b/custom/status.go @@ -7,10 +7,13 @@ import ( "github.com/hiddify/libcore/bridge" "github.com/hiddify/libcore/config" + pb "github.com/hiddify/libcore/hiddifyrpc" + v2 "github.com/hiddify/libcore/v2" ) var statusPropagationPort int64 -var status = Stopped + +// var status = Stopped type StatusMessage struct { Status string `json:"status"` @@ -18,30 +21,46 @@ type StatusMessage struct { Message *string `json:"message"` } -func propagateStatus(newStatus string) { - status = newStatus +func propagateStatus(newStatus pb.CoreState) { + v2.CoreState = newStatus - msg, _ := json.Marshal(StatusMessage{Status: status}) + msg, _ := json.Marshal(StatusMessage{Status: convert2OldState(v2.CoreState)}) bridge.SendStringToPort(statusPropagationPort, string(msg)) } +func convert2OldState(newStatus pb.CoreState) string { + if newStatus == pb.CoreState_STOPPED { + return Stopped + } + if newStatus == pb.CoreState_STARTED { + return Started + } + if newStatus == pb.CoreState_STARTING { + return Starting + } + if newStatus == pb.CoreState_STOPPING { + return Stopping + } + return "Invalid" +} + func stopAndAlert(alert string, err error) (resultErr error) { defer config.DeferPanicToError("stopAndAlert", func(err error) { resultErr = err }) - status = Stopped + v2.CoreState = pb.CoreState_STOPPED message := err.Error() fmt.Printf("Error: %s: %s\n", alert, message) - msg, _ := json.Marshal(StatusMessage{Status: status, Alert: &alert, Message: &message}) + msg, _ := json.Marshal(StatusMessage{Status: convert2OldState(v2.CoreState), Alert: &alert, Message: &message}) bridge.SendStringToPort(statusPropagationPort, string(msg)) config.DeactivateTunnelService() if commandServer != nil { commandServer.SetService(nil) } - if box != nil { - box.Close() - box = nil + if v2.Box != nil { + v2.Box.Close() + v2.Box = nil } if commandServer != nil { commandServer.Close() diff --git a/hiddifyrpc/hiddify.pb.go b/hiddifyrpc/hiddify.pb.go new file mode 100644 index 0000000..5fdcd62 --- /dev/null +++ b/hiddifyrpc/hiddify.pb.go @@ -0,0 +1,1662 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: hiddifyrpc/hiddify.proto + +package hiddifyrpc + +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +type ResponseCode int32 + +const ( + ResponseCode_OK ResponseCode = 0 + ResponseCode_FAILED ResponseCode = 1 +) + +var ResponseCode_name = map[int32]string{ + 0: "OK", + 1: "FAILED", +} + +var ResponseCode_value = map[string]int32{ + "OK": 0, + "FAILED": 1, +} + +func (x ResponseCode) String() string { + return proto.EnumName(ResponseCode_name, int32(x)) +} + +func (ResponseCode) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{0} +} + +type CoreState int32 + +const ( + CoreState_STOPPED CoreState = 0 + CoreState_STARTING CoreState = 1 + CoreState_STARTED CoreState = 2 + CoreState_STOPPING CoreState = 3 +) + +var CoreState_name = map[int32]string{ + 0: "STOPPED", + 1: "STARTING", + 2: "STARTED", + 3: "STOPPING", +} + +var CoreState_value = map[string]int32{ + "STOPPED": 0, + "STARTING": 1, + "STARTED": 2, + "STOPPING": 3, +} + +func (x CoreState) String() string { + return proto.EnumName(CoreState_name, int32(x)) +} + +func (CoreState) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{1} +} + +type MessageType int32 + +const ( + MessageType_EMPTY MessageType = 0 + MessageType_EMPTY_CONFIGURATION MessageType = 1 + MessageType_START_COMMAND_SERVER MessageType = 2 + MessageType_CREATE_SERVICE MessageType = 3 + MessageType_START_SERVICE MessageType = 4 + MessageType_UNEXPECTED_ERROR MessageType = 5 + MessageType_ALREADY_STARTED MessageType = 6 + MessageType_ALREADY_STOPPED MessageType = 7 + MessageType_INSTANCE_NOT_FOUND MessageType = 8 + MessageType_INSTANCE_NOT_STOPPED MessageType = 9 + MessageType_INSTANCE_NOT_STARTED MessageType = 10 + MessageType_ERROR_BUILDING_CONFIG MessageType = 11 + MessageType_ERROR_PARSING_CONFIG MessageType = 12 + MessageType_ERROR_READING_CONFIG MessageType = 13 +) + +var MessageType_name = map[int32]string{ + 0: "EMPTY", + 1: "EMPTY_CONFIGURATION", + 2: "START_COMMAND_SERVER", + 3: "CREATE_SERVICE", + 4: "START_SERVICE", + 5: "UNEXPECTED_ERROR", + 6: "ALREADY_STARTED", + 7: "ALREADY_STOPPED", + 8: "INSTANCE_NOT_FOUND", + 9: "INSTANCE_NOT_STOPPED", + 10: "INSTANCE_NOT_STARTED", + 11: "ERROR_BUILDING_CONFIG", + 12: "ERROR_PARSING_CONFIG", + 13: "ERROR_READING_CONFIG", +} + +var MessageType_value = map[string]int32{ + "EMPTY": 0, + "EMPTY_CONFIGURATION": 1, + "START_COMMAND_SERVER": 2, + "CREATE_SERVICE": 3, + "START_SERVICE": 4, + "UNEXPECTED_ERROR": 5, + "ALREADY_STARTED": 6, + "ALREADY_STOPPED": 7, + "INSTANCE_NOT_FOUND": 8, + "INSTANCE_NOT_STOPPED": 9, + "INSTANCE_NOT_STARTED": 10, + "ERROR_BUILDING_CONFIG": 11, + "ERROR_PARSING_CONFIG": 12, + "ERROR_READING_CONFIG": 13, +} + +func (x MessageType) String() string { + return proto.EnumName(MessageType_name, int32(x)) +} + +func (MessageType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{2} +} + +type LogLevel int32 + +const ( + LogLevel_DEBUG LogLevel = 0 + LogLevel_INFO LogLevel = 1 + LogLevel_WARNING LogLevel = 2 + LogLevel_ERROR LogLevel = 3 + LogLevel_FATAL LogLevel = 4 +) + +var LogLevel_name = map[int32]string{ + 0: "DEBUG", + 1: "INFO", + 2: "WARNING", + 3: "ERROR", + 4: "FATAL", +} + +var LogLevel_value = map[string]int32{ + "DEBUG": 0, + "INFO": 1, + "WARNING": 2, + "ERROR": 3, + "FATAL": 4, +} + +func (x LogLevel) String() string { + return proto.EnumName(LogLevel_name, int32(x)) +} + +func (LogLevel) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{3} +} + +type LogType int32 + +const ( + LogType_CORE LogType = 0 + LogType_SERVICE LogType = 1 + LogType_CONFIG LogType = 2 +) + +var LogType_name = map[int32]string{ + 0: "CORE", + 1: "SERVICE", + 2: "CONFIG", +} + +var LogType_value = map[string]int32{ + "CORE": 0, + "SERVICE": 1, + "CONFIG": 2, +} + +func (x LogType) String() string { + return proto.EnumName(LogType_name, int32(x)) +} + +func (LogType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{4} +} + +type CoreInfoResponse struct { + CoreState CoreState `protobuf:"varint,1,opt,name=core_state,json=coreState,proto3,enum=hiddifyrpc.CoreState" json:"core_state,omitempty"` + MessageType MessageType `protobuf:"varint,2,opt,name=message_type,json=messageType,proto3,enum=hiddifyrpc.MessageType" json:"message_type,omitempty"` + Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *CoreInfoResponse) Reset() { *m = CoreInfoResponse{} } +func (m *CoreInfoResponse) String() string { return proto.CompactTextString(m) } +func (*CoreInfoResponse) ProtoMessage() {} +func (*CoreInfoResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{0} +} + +func (m *CoreInfoResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_CoreInfoResponse.Unmarshal(m, b) +} +func (m *CoreInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_CoreInfoResponse.Marshal(b, m, deterministic) +} +func (m *CoreInfoResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_CoreInfoResponse.Merge(m, src) +} +func (m *CoreInfoResponse) XXX_Size() int { + return xxx_messageInfo_CoreInfoResponse.Size(m) +} +func (m *CoreInfoResponse) XXX_DiscardUnknown() { + xxx_messageInfo_CoreInfoResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_CoreInfoResponse proto.InternalMessageInfo + +func (m *CoreInfoResponse) GetCoreState() CoreState { + if m != nil { + return m.CoreState + } + return CoreState_STOPPED +} + +func (m *CoreInfoResponse) GetMessageType() MessageType { + if m != nil { + return m.MessageType + } + return MessageType_EMPTY +} + +func (m *CoreInfoResponse) GetMessage() string { + if m != nil { + return m.Message + } + return "" +} + +type StartRequest struct { + ConfigPath string `protobuf:"bytes,1,opt,name=config_path,json=configPath,proto3" json:"config_path,omitempty"` + ConfigContent string `protobuf:"bytes,2,opt,name=config_content,json=configContent,proto3" json:"config_content,omitempty"` + DisableMemoryLimit bool `protobuf:"varint,3,opt,name=disable_memory_limit,json=disableMemoryLimit,proto3" json:"disable_memory_limit,omitempty"` + DelayStart bool `protobuf:"varint,4,opt,name=delay_start,json=delayStart,proto3" json:"delay_start,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *StartRequest) Reset() { *m = StartRequest{} } +func (m *StartRequest) String() string { return proto.CompactTextString(m) } +func (*StartRequest) ProtoMessage() {} +func (*StartRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{1} +} + +func (m *StartRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_StartRequest.Unmarshal(m, b) +} +func (m *StartRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_StartRequest.Marshal(b, m, deterministic) +} +func (m *StartRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_StartRequest.Merge(m, src) +} +func (m *StartRequest) XXX_Size() int { + return xxx_messageInfo_StartRequest.Size(m) +} +func (m *StartRequest) XXX_DiscardUnknown() { + xxx_messageInfo_StartRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_StartRequest proto.InternalMessageInfo + +func (m *StartRequest) GetConfigPath() string { + if m != nil { + return m.ConfigPath + } + return "" +} + +func (m *StartRequest) GetConfigContent() string { + if m != nil { + return m.ConfigContent + } + return "" +} + +func (m *StartRequest) GetDisableMemoryLimit() bool { + if m != nil { + return m.DisableMemoryLimit + } + return false +} + +func (m *StartRequest) GetDelayStart() bool { + if m != nil { + return m.DelayStart + } + return false +} + +type SetupRequest struct { + BasePath string `protobuf:"bytes,1,opt,name=base_path,json=basePath,proto3" json:"base_path,omitempty"` + WorkingPath string `protobuf:"bytes,2,opt,name=working_path,json=workingPath,proto3" json:"working_path,omitempty"` + TempPath string `protobuf:"bytes,3,opt,name=temp_path,json=tempPath,proto3" json:"temp_path,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SetupRequest) Reset() { *m = SetupRequest{} } +func (m *SetupRequest) String() string { return proto.CompactTextString(m) } +func (*SetupRequest) ProtoMessage() {} +func (*SetupRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{2} +} + +func (m *SetupRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SetupRequest.Unmarshal(m, b) +} +func (m *SetupRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SetupRequest.Marshal(b, m, deterministic) +} +func (m *SetupRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_SetupRequest.Merge(m, src) +} +func (m *SetupRequest) XXX_Size() int { + return xxx_messageInfo_SetupRequest.Size(m) +} +func (m *SetupRequest) XXX_DiscardUnknown() { + xxx_messageInfo_SetupRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_SetupRequest proto.InternalMessageInfo + +func (m *SetupRequest) GetBasePath() string { + if m != nil { + return m.BasePath + } + return "" +} + +func (m *SetupRequest) GetWorkingPath() string { + if m != nil { + return m.WorkingPath + } + return "" +} + +func (m *SetupRequest) GetTempPath() string { + if m != nil { + return m.TempPath + } + return "" +} + +type Response struct { + ResponseCode ResponseCode `protobuf:"varint,1,opt,name=response_code,json=responseCode,proto3,enum=hiddifyrpc.ResponseCode" json:"response_code,omitempty"` + Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Response) Reset() { *m = Response{} } +func (m *Response) String() string { return proto.CompactTextString(m) } +func (*Response) ProtoMessage() {} +func (*Response) Descriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{3} +} + +func (m *Response) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Response.Unmarshal(m, b) +} +func (m *Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Response.Marshal(b, m, deterministic) +} +func (m *Response) XXX_Merge(src proto.Message) { + xxx_messageInfo_Response.Merge(m, src) +} +func (m *Response) XXX_Size() int { + return xxx_messageInfo_Response.Size(m) +} +func (m *Response) XXX_DiscardUnknown() { + xxx_messageInfo_Response.DiscardUnknown(m) +} + +var xxx_messageInfo_Response proto.InternalMessageInfo + +func (m *Response) GetResponseCode() ResponseCode { + if m != nil { + return m.ResponseCode + } + return ResponseCode_OK +} + +func (m *Response) GetMessage() string { + if m != nil { + return m.Message + } + return "" +} + +type HelloRequest struct { + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *HelloRequest) Reset() { *m = HelloRequest{} } +func (m *HelloRequest) String() string { return proto.CompactTextString(m) } +func (*HelloRequest) ProtoMessage() {} +func (*HelloRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{4} +} + +func (m *HelloRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_HelloRequest.Unmarshal(m, b) +} +func (m *HelloRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_HelloRequest.Marshal(b, m, deterministic) +} +func (m *HelloRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_HelloRequest.Merge(m, src) +} +func (m *HelloRequest) XXX_Size() int { + return xxx_messageInfo_HelloRequest.Size(m) +} +func (m *HelloRequest) XXX_DiscardUnknown() { + xxx_messageInfo_HelloRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_HelloRequest proto.InternalMessageInfo + +func (m *HelloRequest) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +type HelloResponse struct { + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *HelloResponse) Reset() { *m = HelloResponse{} } +func (m *HelloResponse) String() string { return proto.CompactTextString(m) } +func (*HelloResponse) ProtoMessage() {} +func (*HelloResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{5} +} + +func (m *HelloResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_HelloResponse.Unmarshal(m, b) +} +func (m *HelloResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_HelloResponse.Marshal(b, m, deterministic) +} +func (m *HelloResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_HelloResponse.Merge(m, src) +} +func (m *HelloResponse) XXX_Size() int { + return xxx_messageInfo_HelloResponse.Size(m) +} +func (m *HelloResponse) XXX_DiscardUnknown() { + xxx_messageInfo_HelloResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_HelloResponse proto.InternalMessageInfo + +func (m *HelloResponse) GetMessage() string { + if m != nil { + return m.Message + } + return "" +} + +type Empty struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Empty) Reset() { *m = Empty{} } +func (m *Empty) String() string { return proto.CompactTextString(m) } +func (*Empty) ProtoMessage() {} +func (*Empty) Descriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{6} +} + +func (m *Empty) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Empty.Unmarshal(m, b) +} +func (m *Empty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Empty.Marshal(b, m, deterministic) +} +func (m *Empty) XXX_Merge(src proto.Message) { + xxx_messageInfo_Empty.Merge(m, src) +} +func (m *Empty) XXX_Size() int { + return xxx_messageInfo_Empty.Size(m) +} +func (m *Empty) XXX_DiscardUnknown() { + xxx_messageInfo_Empty.DiscardUnknown(m) +} + +var xxx_messageInfo_Empty proto.InternalMessageInfo + +type SystemInfo struct { + Memory int64 `protobuf:"varint,1,opt,name=memory,proto3" json:"memory,omitempty"` + Goroutines int32 `protobuf:"varint,2,opt,name=goroutines,proto3" json:"goroutines,omitempty"` + ConnectionsIn int32 `protobuf:"varint,3,opt,name=connections_in,json=connectionsIn,proto3" json:"connections_in,omitempty"` + ConnectionsOut int32 `protobuf:"varint,4,opt,name=connections_out,json=connectionsOut,proto3" json:"connections_out,omitempty"` + TrafficAvailable bool `protobuf:"varint,5,opt,name=traffic_available,json=trafficAvailable,proto3" json:"traffic_available,omitempty"` + Uplink int64 `protobuf:"varint,6,opt,name=uplink,proto3" json:"uplink,omitempty"` + Downlink int64 `protobuf:"varint,7,opt,name=downlink,proto3" json:"downlink,omitempty"` + UplinkTotal int64 `protobuf:"varint,8,opt,name=uplink_total,json=uplinkTotal,proto3" json:"uplink_total,omitempty"` + DownlinkTotal int64 `protobuf:"varint,9,opt,name=downlink_total,json=downlinkTotal,proto3" json:"downlink_total,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SystemInfo) Reset() { *m = SystemInfo{} } +func (m *SystemInfo) String() string { return proto.CompactTextString(m) } +func (*SystemInfo) ProtoMessage() {} +func (*SystemInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{7} +} + +func (m *SystemInfo) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SystemInfo.Unmarshal(m, b) +} +func (m *SystemInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SystemInfo.Marshal(b, m, deterministic) +} +func (m *SystemInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_SystemInfo.Merge(m, src) +} +func (m *SystemInfo) XXX_Size() int { + return xxx_messageInfo_SystemInfo.Size(m) +} +func (m *SystemInfo) XXX_DiscardUnknown() { + xxx_messageInfo_SystemInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_SystemInfo proto.InternalMessageInfo + +func (m *SystemInfo) GetMemory() int64 { + if m != nil { + return m.Memory + } + return 0 +} + +func (m *SystemInfo) GetGoroutines() int32 { + if m != nil { + return m.Goroutines + } + return 0 +} + +func (m *SystemInfo) GetConnectionsIn() int32 { + if m != nil { + return m.ConnectionsIn + } + return 0 +} + +func (m *SystemInfo) GetConnectionsOut() int32 { + if m != nil { + return m.ConnectionsOut + } + return 0 +} + +func (m *SystemInfo) GetTrafficAvailable() bool { + if m != nil { + return m.TrafficAvailable + } + return false +} + +func (m *SystemInfo) GetUplink() int64 { + if m != nil { + return m.Uplink + } + return 0 +} + +func (m *SystemInfo) GetDownlink() int64 { + if m != nil { + return m.Downlink + } + return 0 +} + +func (m *SystemInfo) GetUplinkTotal() int64 { + if m != nil { + return m.UplinkTotal + } + return 0 +} + +func (m *SystemInfo) GetDownlinkTotal() int64 { + if m != nil { + return m.DownlinkTotal + } + return 0 +} + +type OutboundGroupItem struct { + Tag string `protobuf:"bytes,1,opt,name=tag,proto3" json:"tag,omitempty"` + Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` + UrlTestTime int64 `protobuf:"varint,3,opt,name=url_test_time,json=urlTestTime,proto3" json:"url_test_time,omitempty"` + UrlTestDelay int32 `protobuf:"varint,4,opt,name=url_test_delay,json=urlTestDelay,proto3" json:"url_test_delay,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *OutboundGroupItem) Reset() { *m = OutboundGroupItem{} } +func (m *OutboundGroupItem) String() string { return proto.CompactTextString(m) } +func (*OutboundGroupItem) ProtoMessage() {} +func (*OutboundGroupItem) Descriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{8} +} + +func (m *OutboundGroupItem) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_OutboundGroupItem.Unmarshal(m, b) +} +func (m *OutboundGroupItem) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_OutboundGroupItem.Marshal(b, m, deterministic) +} +func (m *OutboundGroupItem) XXX_Merge(src proto.Message) { + xxx_messageInfo_OutboundGroupItem.Merge(m, src) +} +func (m *OutboundGroupItem) XXX_Size() int { + return xxx_messageInfo_OutboundGroupItem.Size(m) +} +func (m *OutboundGroupItem) XXX_DiscardUnknown() { + xxx_messageInfo_OutboundGroupItem.DiscardUnknown(m) +} + +var xxx_messageInfo_OutboundGroupItem proto.InternalMessageInfo + +func (m *OutboundGroupItem) GetTag() string { + if m != nil { + return m.Tag + } + return "" +} + +func (m *OutboundGroupItem) GetType() string { + if m != nil { + return m.Type + } + return "" +} + +func (m *OutboundGroupItem) GetUrlTestTime() int64 { + if m != nil { + return m.UrlTestTime + } + return 0 +} + +func (m *OutboundGroupItem) GetUrlTestDelay() int32 { + if m != nil { + return m.UrlTestDelay + } + return 0 +} + +type OutboundGroup struct { + Tag string `protobuf:"bytes,1,opt,name=tag,proto3" json:"tag,omitempty"` + Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` + Selected string `protobuf:"bytes,3,opt,name=selected,proto3" json:"selected,omitempty"` + Items []*OutboundGroupItem `protobuf:"bytes,4,rep,name=items,proto3" json:"items,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *OutboundGroup) Reset() { *m = OutboundGroup{} } +func (m *OutboundGroup) String() string { return proto.CompactTextString(m) } +func (*OutboundGroup) ProtoMessage() {} +func (*OutboundGroup) Descriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{9} +} + +func (m *OutboundGroup) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_OutboundGroup.Unmarshal(m, b) +} +func (m *OutboundGroup) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_OutboundGroup.Marshal(b, m, deterministic) +} +func (m *OutboundGroup) XXX_Merge(src proto.Message) { + xxx_messageInfo_OutboundGroup.Merge(m, src) +} +func (m *OutboundGroup) XXX_Size() int { + return xxx_messageInfo_OutboundGroup.Size(m) +} +func (m *OutboundGroup) XXX_DiscardUnknown() { + xxx_messageInfo_OutboundGroup.DiscardUnknown(m) +} + +var xxx_messageInfo_OutboundGroup proto.InternalMessageInfo + +func (m *OutboundGroup) GetTag() string { + if m != nil { + return m.Tag + } + return "" +} + +func (m *OutboundGroup) GetType() string { + if m != nil { + return m.Type + } + return "" +} + +func (m *OutboundGroup) GetSelected() string { + if m != nil { + return m.Selected + } + return "" +} + +func (m *OutboundGroup) GetItems() []*OutboundGroupItem { + if m != nil { + return m.Items + } + return nil +} + +type OutboundGroupList struct { + Items []*OutboundGroup `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *OutboundGroupList) Reset() { *m = OutboundGroupList{} } +func (m *OutboundGroupList) String() string { return proto.CompactTextString(m) } +func (*OutboundGroupList) ProtoMessage() {} +func (*OutboundGroupList) Descriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{10} +} + +func (m *OutboundGroupList) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_OutboundGroupList.Unmarshal(m, b) +} +func (m *OutboundGroupList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_OutboundGroupList.Marshal(b, m, deterministic) +} +func (m *OutboundGroupList) XXX_Merge(src proto.Message) { + xxx_messageInfo_OutboundGroupList.Merge(m, src) +} +func (m *OutboundGroupList) XXX_Size() int { + return xxx_messageInfo_OutboundGroupList.Size(m) +} +func (m *OutboundGroupList) XXX_DiscardUnknown() { + xxx_messageInfo_OutboundGroupList.DiscardUnknown(m) +} + +var xxx_messageInfo_OutboundGroupList proto.InternalMessageInfo + +func (m *OutboundGroupList) GetItems() []*OutboundGroup { + if m != nil { + return m.Items + } + return nil +} + +type WarpAccount struct { + AccountId string `protobuf:"bytes,1,opt,name=account_id,json=accountId,proto3" json:"account_id,omitempty"` + AccessToken string `protobuf:"bytes,2,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *WarpAccount) Reset() { *m = WarpAccount{} } +func (m *WarpAccount) String() string { return proto.CompactTextString(m) } +func (*WarpAccount) ProtoMessage() {} +func (*WarpAccount) Descriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{11} +} + +func (m *WarpAccount) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_WarpAccount.Unmarshal(m, b) +} +func (m *WarpAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_WarpAccount.Marshal(b, m, deterministic) +} +func (m *WarpAccount) XXX_Merge(src proto.Message) { + xxx_messageInfo_WarpAccount.Merge(m, src) +} +func (m *WarpAccount) XXX_Size() int { + return xxx_messageInfo_WarpAccount.Size(m) +} +func (m *WarpAccount) XXX_DiscardUnknown() { + xxx_messageInfo_WarpAccount.DiscardUnknown(m) +} + +var xxx_messageInfo_WarpAccount proto.InternalMessageInfo + +func (m *WarpAccount) GetAccountId() string { + if m != nil { + return m.AccountId + } + return "" +} + +func (m *WarpAccount) GetAccessToken() string { + if m != nil { + return m.AccessToken + } + return "" +} + +type WarpWireguardConfig struct { + PrivateKey string `protobuf:"bytes,1,opt,name=private_key,json=privateKey,proto3" json:"private_key,omitempty"` + LocalAddressIpv4 string `protobuf:"bytes,2,opt,name=local_address_ipv4,json=localAddressIpv4,proto3" json:"local_address_ipv4,omitempty"` + LocalAddressIpv6 string `protobuf:"bytes,3,opt,name=local_address_ipv6,json=localAddressIpv6,proto3" json:"local_address_ipv6,omitempty"` + PeerPublicKey string `protobuf:"bytes,4,opt,name=peer_public_key,json=peerPublicKey,proto3" json:"peer_public_key,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *WarpWireguardConfig) Reset() { *m = WarpWireguardConfig{} } +func (m *WarpWireguardConfig) String() string { return proto.CompactTextString(m) } +func (*WarpWireguardConfig) ProtoMessage() {} +func (*WarpWireguardConfig) Descriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{12} +} + +func (m *WarpWireguardConfig) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_WarpWireguardConfig.Unmarshal(m, b) +} +func (m *WarpWireguardConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_WarpWireguardConfig.Marshal(b, m, deterministic) +} +func (m *WarpWireguardConfig) XXX_Merge(src proto.Message) { + xxx_messageInfo_WarpWireguardConfig.Merge(m, src) +} +func (m *WarpWireguardConfig) XXX_Size() int { + return xxx_messageInfo_WarpWireguardConfig.Size(m) +} +func (m *WarpWireguardConfig) XXX_DiscardUnknown() { + xxx_messageInfo_WarpWireguardConfig.DiscardUnknown(m) +} + +var xxx_messageInfo_WarpWireguardConfig proto.InternalMessageInfo + +func (m *WarpWireguardConfig) GetPrivateKey() string { + if m != nil { + return m.PrivateKey + } + return "" +} + +func (m *WarpWireguardConfig) GetLocalAddressIpv4() string { + if m != nil { + return m.LocalAddressIpv4 + } + return "" +} + +func (m *WarpWireguardConfig) GetLocalAddressIpv6() string { + if m != nil { + return m.LocalAddressIpv6 + } + return "" +} + +func (m *WarpWireguardConfig) GetPeerPublicKey() string { + if m != nil { + return m.PeerPublicKey + } + return "" +} + +type WarpGenerationResponse struct { + Account *WarpAccount `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` + Log string `protobuf:"bytes,2,opt,name=log,proto3" json:"log,omitempty"` + Config *WarpWireguardConfig `protobuf:"bytes,3,opt,name=config,proto3" json:"config,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *WarpGenerationResponse) Reset() { *m = WarpGenerationResponse{} } +func (m *WarpGenerationResponse) String() string { return proto.CompactTextString(m) } +func (*WarpGenerationResponse) ProtoMessage() {} +func (*WarpGenerationResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{13} +} + +func (m *WarpGenerationResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_WarpGenerationResponse.Unmarshal(m, b) +} +func (m *WarpGenerationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_WarpGenerationResponse.Marshal(b, m, deterministic) +} +func (m *WarpGenerationResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_WarpGenerationResponse.Merge(m, src) +} +func (m *WarpGenerationResponse) XXX_Size() int { + return xxx_messageInfo_WarpGenerationResponse.Size(m) +} +func (m *WarpGenerationResponse) XXX_DiscardUnknown() { + xxx_messageInfo_WarpGenerationResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_WarpGenerationResponse proto.InternalMessageInfo + +func (m *WarpGenerationResponse) GetAccount() *WarpAccount { + if m != nil { + return m.Account + } + return nil +} + +func (m *WarpGenerationResponse) GetLog() string { + if m != nil { + return m.Log + } + return "" +} + +func (m *WarpGenerationResponse) GetConfig() *WarpWireguardConfig { + if m != nil { + return m.Config + } + return nil +} + +type SystemProxyStatus struct { + Available bool `protobuf:"varint,1,opt,name=available,proto3" json:"available,omitempty"` + Enabled bool `protobuf:"varint,2,opt,name=enabled,proto3" json:"enabled,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SystemProxyStatus) Reset() { *m = SystemProxyStatus{} } +func (m *SystemProxyStatus) String() string { return proto.CompactTextString(m) } +func (*SystemProxyStatus) ProtoMessage() {} +func (*SystemProxyStatus) Descriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{14} +} + +func (m *SystemProxyStatus) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SystemProxyStatus.Unmarshal(m, b) +} +func (m *SystemProxyStatus) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SystemProxyStatus.Marshal(b, m, deterministic) +} +func (m *SystemProxyStatus) XXX_Merge(src proto.Message) { + xxx_messageInfo_SystemProxyStatus.Merge(m, src) +} +func (m *SystemProxyStatus) XXX_Size() int { + return xxx_messageInfo_SystemProxyStatus.Size(m) +} +func (m *SystemProxyStatus) XXX_DiscardUnknown() { + xxx_messageInfo_SystemProxyStatus.DiscardUnknown(m) +} + +var xxx_messageInfo_SystemProxyStatus proto.InternalMessageInfo + +func (m *SystemProxyStatus) GetAvailable() bool { + if m != nil { + return m.Available + } + return false +} + +func (m *SystemProxyStatus) GetEnabled() bool { + if m != nil { + return m.Enabled + } + return false +} + +type ParseRequest struct { + Content string `protobuf:"bytes,1,opt,name=content,proto3" json:"content,omitempty"` + Debug bool `protobuf:"varint,2,opt,name=debug,proto3" json:"debug,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ParseRequest) Reset() { *m = ParseRequest{} } +func (m *ParseRequest) String() string { return proto.CompactTextString(m) } +func (*ParseRequest) ProtoMessage() {} +func (*ParseRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{15} +} + +func (m *ParseRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ParseRequest.Unmarshal(m, b) +} +func (m *ParseRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ParseRequest.Marshal(b, m, deterministic) +} +func (m *ParseRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ParseRequest.Merge(m, src) +} +func (m *ParseRequest) XXX_Size() int { + return xxx_messageInfo_ParseRequest.Size(m) +} +func (m *ParseRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ParseRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ParseRequest proto.InternalMessageInfo + +func (m *ParseRequest) GetContent() string { + if m != nil { + return m.Content + } + return "" +} + +func (m *ParseRequest) GetDebug() bool { + if m != nil { + return m.Debug + } + return false +} + +type ParseResponse struct { + ResponseCode ResponseCode `protobuf:"varint,1,opt,name=response_code,json=responseCode,proto3,enum=hiddifyrpc.ResponseCode" json:"response_code,omitempty"` + Content string `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"` + Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ParseResponse) Reset() { *m = ParseResponse{} } +func (m *ParseResponse) String() string { return proto.CompactTextString(m) } +func (*ParseResponse) ProtoMessage() {} +func (*ParseResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{16} +} + +func (m *ParseResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ParseResponse.Unmarshal(m, b) +} +func (m *ParseResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ParseResponse.Marshal(b, m, deterministic) +} +func (m *ParseResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ParseResponse.Merge(m, src) +} +func (m *ParseResponse) XXX_Size() int { + return xxx_messageInfo_ParseResponse.Size(m) +} +func (m *ParseResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ParseResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ParseResponse proto.InternalMessageInfo + +func (m *ParseResponse) GetResponseCode() ResponseCode { + if m != nil { + return m.ResponseCode + } + return ResponseCode_OK +} + +func (m *ParseResponse) GetContent() string { + if m != nil { + return m.Content + } + return "" +} + +func (m *ParseResponse) GetMessage() string { + if m != nil { + return m.Message + } + return "" +} + +type ChangeConfigOptionsRequest struct { + ConfigOptionsJson string `protobuf:"bytes,1,opt,name=config_options_json,json=configOptionsJson,proto3" json:"config_options_json,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ChangeConfigOptionsRequest) Reset() { *m = ChangeConfigOptionsRequest{} } +func (m *ChangeConfigOptionsRequest) String() string { return proto.CompactTextString(m) } +func (*ChangeConfigOptionsRequest) ProtoMessage() {} +func (*ChangeConfigOptionsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{17} +} + +func (m *ChangeConfigOptionsRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ChangeConfigOptionsRequest.Unmarshal(m, b) +} +func (m *ChangeConfigOptionsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ChangeConfigOptionsRequest.Marshal(b, m, deterministic) +} +func (m *ChangeConfigOptionsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ChangeConfigOptionsRequest.Merge(m, src) +} +func (m *ChangeConfigOptionsRequest) XXX_Size() int { + return xxx_messageInfo_ChangeConfigOptionsRequest.Size(m) +} +func (m *ChangeConfigOptionsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ChangeConfigOptionsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ChangeConfigOptionsRequest proto.InternalMessageInfo + +func (m *ChangeConfigOptionsRequest) GetConfigOptionsJson() string { + if m != nil { + return m.ConfigOptionsJson + } + return "" +} + +type GenerateConfigRequest struct { + Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` + TempPath string `protobuf:"bytes,2,opt,name=temp_path,json=tempPath,proto3" json:"temp_path,omitempty"` + Debug bool `protobuf:"varint,3,opt,name=debug,proto3" json:"debug,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GenerateConfigRequest) Reset() { *m = GenerateConfigRequest{} } +func (m *GenerateConfigRequest) String() string { return proto.CompactTextString(m) } +func (*GenerateConfigRequest) ProtoMessage() {} +func (*GenerateConfigRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{18} +} + +func (m *GenerateConfigRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GenerateConfigRequest.Unmarshal(m, b) +} +func (m *GenerateConfigRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GenerateConfigRequest.Marshal(b, m, deterministic) +} +func (m *GenerateConfigRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenerateConfigRequest.Merge(m, src) +} +func (m *GenerateConfigRequest) XXX_Size() int { + return xxx_messageInfo_GenerateConfigRequest.Size(m) +} +func (m *GenerateConfigRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GenerateConfigRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GenerateConfigRequest proto.InternalMessageInfo + +func (m *GenerateConfigRequest) GetPath() string { + if m != nil { + return m.Path + } + return "" +} + +func (m *GenerateConfigRequest) GetTempPath() string { + if m != nil { + return m.TempPath + } + return "" +} + +func (m *GenerateConfigRequest) GetDebug() bool { + if m != nil { + return m.Debug + } + return false +} + +type GenerateConfigResponse struct { + ConfigContent string `protobuf:"bytes,1,opt,name=config_content,json=configContent,proto3" json:"config_content,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GenerateConfigResponse) Reset() { *m = GenerateConfigResponse{} } +func (m *GenerateConfigResponse) String() string { return proto.CompactTextString(m) } +func (*GenerateConfigResponse) ProtoMessage() {} +func (*GenerateConfigResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{19} +} + +func (m *GenerateConfigResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GenerateConfigResponse.Unmarshal(m, b) +} +func (m *GenerateConfigResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GenerateConfigResponse.Marshal(b, m, deterministic) +} +func (m *GenerateConfigResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenerateConfigResponse.Merge(m, src) +} +func (m *GenerateConfigResponse) XXX_Size() int { + return xxx_messageInfo_GenerateConfigResponse.Size(m) +} +func (m *GenerateConfigResponse) XXX_DiscardUnknown() { + xxx_messageInfo_GenerateConfigResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_GenerateConfigResponse proto.InternalMessageInfo + +func (m *GenerateConfigResponse) GetConfigContent() string { + if m != nil { + return m.ConfigContent + } + return "" +} + +type SelectOutboundRequest struct { + GroupTag string `protobuf:"bytes,1,opt,name=group_tag,json=groupTag,proto3" json:"group_tag,omitempty"` + OutboundTag string `protobuf:"bytes,2,opt,name=outbound_tag,json=outboundTag,proto3" json:"outbound_tag,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SelectOutboundRequest) Reset() { *m = SelectOutboundRequest{} } +func (m *SelectOutboundRequest) String() string { return proto.CompactTextString(m) } +func (*SelectOutboundRequest) ProtoMessage() {} +func (*SelectOutboundRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{20} +} + +func (m *SelectOutboundRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SelectOutboundRequest.Unmarshal(m, b) +} +func (m *SelectOutboundRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SelectOutboundRequest.Marshal(b, m, deterministic) +} +func (m *SelectOutboundRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_SelectOutboundRequest.Merge(m, src) +} +func (m *SelectOutboundRequest) XXX_Size() int { + return xxx_messageInfo_SelectOutboundRequest.Size(m) +} +func (m *SelectOutboundRequest) XXX_DiscardUnknown() { + xxx_messageInfo_SelectOutboundRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_SelectOutboundRequest proto.InternalMessageInfo + +func (m *SelectOutboundRequest) GetGroupTag() string { + if m != nil { + return m.GroupTag + } + return "" +} + +func (m *SelectOutboundRequest) GetOutboundTag() string { + if m != nil { + return m.OutboundTag + } + return "" +} + +type UrlTestRequest struct { + GroupTag string `protobuf:"bytes,1,opt,name=group_tag,json=groupTag,proto3" json:"group_tag,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *UrlTestRequest) Reset() { *m = UrlTestRequest{} } +func (m *UrlTestRequest) String() string { return proto.CompactTextString(m) } +func (*UrlTestRequest) ProtoMessage() {} +func (*UrlTestRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{21} +} + +func (m *UrlTestRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_UrlTestRequest.Unmarshal(m, b) +} +func (m *UrlTestRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_UrlTestRequest.Marshal(b, m, deterministic) +} +func (m *UrlTestRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_UrlTestRequest.Merge(m, src) +} +func (m *UrlTestRequest) XXX_Size() int { + return xxx_messageInfo_UrlTestRequest.Size(m) +} +func (m *UrlTestRequest) XXX_DiscardUnknown() { + xxx_messageInfo_UrlTestRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_UrlTestRequest proto.InternalMessageInfo + +func (m *UrlTestRequest) GetGroupTag() string { + if m != nil { + return m.GroupTag + } + return "" +} + +type GenerateWarpConfigRequest struct { + LicenseKey string `protobuf:"bytes,1,opt,name=license_key,json=licenseKey,proto3" json:"license_key,omitempty"` + AccountId string `protobuf:"bytes,2,opt,name=account_id,json=accountId,proto3" json:"account_id,omitempty"` + AccessToken string `protobuf:"bytes,3,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GenerateWarpConfigRequest) Reset() { *m = GenerateWarpConfigRequest{} } +func (m *GenerateWarpConfigRequest) String() string { return proto.CompactTextString(m) } +func (*GenerateWarpConfigRequest) ProtoMessage() {} +func (*GenerateWarpConfigRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{22} +} + +func (m *GenerateWarpConfigRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GenerateWarpConfigRequest.Unmarshal(m, b) +} +func (m *GenerateWarpConfigRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GenerateWarpConfigRequest.Marshal(b, m, deterministic) +} +func (m *GenerateWarpConfigRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenerateWarpConfigRequest.Merge(m, src) +} +func (m *GenerateWarpConfigRequest) XXX_Size() int { + return xxx_messageInfo_GenerateWarpConfigRequest.Size(m) +} +func (m *GenerateWarpConfigRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GenerateWarpConfigRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GenerateWarpConfigRequest proto.InternalMessageInfo + +func (m *GenerateWarpConfigRequest) GetLicenseKey() string { + if m != nil { + return m.LicenseKey + } + return "" +} + +func (m *GenerateWarpConfigRequest) GetAccountId() string { + if m != nil { + return m.AccountId + } + return "" +} + +func (m *GenerateWarpConfigRequest) GetAccessToken() string { + if m != nil { + return m.AccessToken + } + return "" +} + +type SetSystemProxyEnabledRequest struct { + IsEnabled bool `protobuf:"varint,1,opt,name=is_enabled,json=isEnabled,proto3" json:"is_enabled,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SetSystemProxyEnabledRequest) Reset() { *m = SetSystemProxyEnabledRequest{} } +func (m *SetSystemProxyEnabledRequest) String() string { return proto.CompactTextString(m) } +func (*SetSystemProxyEnabledRequest) ProtoMessage() {} +func (*SetSystemProxyEnabledRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{23} +} + +func (m *SetSystemProxyEnabledRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SetSystemProxyEnabledRequest.Unmarshal(m, b) +} +func (m *SetSystemProxyEnabledRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SetSystemProxyEnabledRequest.Marshal(b, m, deterministic) +} +func (m *SetSystemProxyEnabledRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_SetSystemProxyEnabledRequest.Merge(m, src) +} +func (m *SetSystemProxyEnabledRequest) XXX_Size() int { + return xxx_messageInfo_SetSystemProxyEnabledRequest.Size(m) +} +func (m *SetSystemProxyEnabledRequest) XXX_DiscardUnknown() { + xxx_messageInfo_SetSystemProxyEnabledRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_SetSystemProxyEnabledRequest proto.InternalMessageInfo + +func (m *SetSystemProxyEnabledRequest) GetIsEnabled() bool { + if m != nil { + return m.IsEnabled + } + return false +} + +type LogMessage struct { + Level LogLevel `protobuf:"varint,1,opt,name=level,proto3,enum=hiddifyrpc.LogLevel" json:"level,omitempty"` + Type LogType `protobuf:"varint,2,opt,name=type,proto3,enum=hiddifyrpc.LogType" json:"type,omitempty"` + Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *LogMessage) Reset() { *m = LogMessage{} } +func (m *LogMessage) String() string { return proto.CompactTextString(m) } +func (*LogMessage) ProtoMessage() {} +func (*LogMessage) Descriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{24} +} + +func (m *LogMessage) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_LogMessage.Unmarshal(m, b) +} +func (m *LogMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_LogMessage.Marshal(b, m, deterministic) +} +func (m *LogMessage) XXX_Merge(src proto.Message) { + xxx_messageInfo_LogMessage.Merge(m, src) +} +func (m *LogMessage) XXX_Size() int { + return xxx_messageInfo_LogMessage.Size(m) +} +func (m *LogMessage) XXX_DiscardUnknown() { + xxx_messageInfo_LogMessage.DiscardUnknown(m) +} + +var xxx_messageInfo_LogMessage proto.InternalMessageInfo + +func (m *LogMessage) GetLevel() LogLevel { + if m != nil { + return m.Level + } + return LogLevel_DEBUG +} + +func (m *LogMessage) GetType() LogType { + if m != nil { + return m.Type + } + return LogType_CORE +} + +func (m *LogMessage) GetMessage() string { + if m != nil { + return m.Message + } + return "" +} + +type StopRequest struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *StopRequest) Reset() { *m = StopRequest{} } +func (m *StopRequest) String() string { return proto.CompactTextString(m) } +func (*StopRequest) ProtoMessage() {} +func (*StopRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b52c484803f63ee3, []int{25} +} + +func (m *StopRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_StopRequest.Unmarshal(m, b) +} +func (m *StopRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_StopRequest.Marshal(b, m, deterministic) +} +func (m *StopRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_StopRequest.Merge(m, src) +} +func (m *StopRequest) XXX_Size() int { + return xxx_messageInfo_StopRequest.Size(m) +} +func (m *StopRequest) XXX_DiscardUnknown() { + xxx_messageInfo_StopRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_StopRequest proto.InternalMessageInfo + +func init() { + proto.RegisterEnum("hiddifyrpc.ResponseCode", ResponseCode_name, ResponseCode_value) + proto.RegisterEnum("hiddifyrpc.CoreState", CoreState_name, CoreState_value) + proto.RegisterEnum("hiddifyrpc.MessageType", MessageType_name, MessageType_value) + proto.RegisterEnum("hiddifyrpc.LogLevel", LogLevel_name, LogLevel_value) + proto.RegisterEnum("hiddifyrpc.LogType", LogType_name, LogType_value) + proto.RegisterType((*CoreInfoResponse)(nil), "hiddifyrpc.CoreInfoResponse") + proto.RegisterType((*StartRequest)(nil), "hiddifyrpc.StartRequest") + proto.RegisterType((*SetupRequest)(nil), "hiddifyrpc.SetupRequest") + proto.RegisterType((*Response)(nil), "hiddifyrpc.Response") + proto.RegisterType((*HelloRequest)(nil), "hiddifyrpc.HelloRequest") + proto.RegisterType((*HelloResponse)(nil), "hiddifyrpc.HelloResponse") + proto.RegisterType((*Empty)(nil), "hiddifyrpc.Empty") + proto.RegisterType((*SystemInfo)(nil), "hiddifyrpc.SystemInfo") + proto.RegisterType((*OutboundGroupItem)(nil), "hiddifyrpc.OutboundGroupItem") + proto.RegisterType((*OutboundGroup)(nil), "hiddifyrpc.OutboundGroup") + proto.RegisterType((*OutboundGroupList)(nil), "hiddifyrpc.OutboundGroupList") + proto.RegisterType((*WarpAccount)(nil), "hiddifyrpc.WarpAccount") + proto.RegisterType((*WarpWireguardConfig)(nil), "hiddifyrpc.WarpWireguardConfig") + proto.RegisterType((*WarpGenerationResponse)(nil), "hiddifyrpc.WarpGenerationResponse") + proto.RegisterType((*SystemProxyStatus)(nil), "hiddifyrpc.SystemProxyStatus") + proto.RegisterType((*ParseRequest)(nil), "hiddifyrpc.ParseRequest") + proto.RegisterType((*ParseResponse)(nil), "hiddifyrpc.ParseResponse") + proto.RegisterType((*ChangeConfigOptionsRequest)(nil), "hiddifyrpc.ChangeConfigOptionsRequest") + proto.RegisterType((*GenerateConfigRequest)(nil), "hiddifyrpc.GenerateConfigRequest") + proto.RegisterType((*GenerateConfigResponse)(nil), "hiddifyrpc.GenerateConfigResponse") + proto.RegisterType((*SelectOutboundRequest)(nil), "hiddifyrpc.SelectOutboundRequest") + proto.RegisterType((*UrlTestRequest)(nil), "hiddifyrpc.UrlTestRequest") + proto.RegisterType((*GenerateWarpConfigRequest)(nil), "hiddifyrpc.GenerateWarpConfigRequest") + proto.RegisterType((*SetSystemProxyEnabledRequest)(nil), "hiddifyrpc.SetSystemProxyEnabledRequest") + proto.RegisterType((*LogMessage)(nil), "hiddifyrpc.LogMessage") + proto.RegisterType((*StopRequest)(nil), "hiddifyrpc.StopRequest") +} + +func init() { proto.RegisterFile("hiddifyrpc/hiddify.proto", fileDescriptor_b52c484803f63ee3) } + +var fileDescriptor_b52c484803f63ee3 = []byte{ + // 1783 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x18, 0x5d, 0x73, 0xe3, 0x56, + 0x35, 0xb2, 0xe3, 0xd8, 0x3e, 0xb6, 0xb3, 0xca, 0x4d, 0x36, 0xeb, 0x4d, 0x77, 0xd9, 0xad, 0x86, + 0xd2, 0x10, 0x4a, 0xb6, 0xa4, 0x3b, 0xdd, 0x19, 0xa0, 0xec, 0x28, 0xb6, 0x92, 0x35, 0x71, 0x6c, + 0x8f, 0xac, 0xb0, 0x94, 0x07, 0x34, 0x8a, 0x7c, 0xe3, 0x15, 0x91, 0x75, 0x85, 0x74, 0x9d, 0xe2, + 0x61, 0x86, 0x07, 0x98, 0xe1, 0x17, 0x30, 0x3c, 0xf2, 0xce, 0x5f, 0xe0, 0x85, 0x5f, 0xc0, 0x7f, + 0x62, 0xee, 0x97, 0x2d, 0x39, 0x76, 0xb7, 0xd3, 0xf6, 0xed, 0xde, 0xf3, 0xa5, 0xf3, 0x7d, 0xce, + 0x15, 0x34, 0xdf, 0x05, 0xa3, 0x51, 0x70, 0x33, 0x4b, 0x62, 0xff, 0x85, 0x3c, 0x1e, 0xc7, 0x09, + 0xa1, 0x04, 0xc1, 0x02, 0x63, 0xfc, 0x4b, 0x03, 0xbd, 0x45, 0x12, 0xdc, 0x89, 0x6e, 0x88, 0x8d, + 0xd3, 0x98, 0x44, 0x29, 0x46, 0x2f, 0x01, 0x7c, 0x92, 0x60, 0x37, 0xa5, 0x1e, 0xc5, 0x4d, 0xed, + 0xb9, 0x76, 0xb8, 0x7d, 0xf2, 0xf0, 0x78, 0xc1, 0x75, 0xcc, 0x38, 0x86, 0x0c, 0x69, 0x57, 0x7d, + 0x75, 0x44, 0x3f, 0x87, 0xfa,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x86, 0x34, 0x7c, 0xa8, + 0xcc, 0x03, 0xf6, 0x05, 0x34, 0x12, 0x79, 0x76, 0x7d, 0x32, 0x52, 0x31, 0x6b, 0x66, 0x7d, 0xaf, + 0x88, 0x5b, 0x64, 0x84, 0xed, 0x7a, 0x92, 0xb9, 0x65, 0xbd, 0x5f, 0xc8, 0x7b, 0xdf, 0x80, 0xfa, + 0x1b, 0x1c, 0x86, 0x44, 0x59, 0x84, 0x60, 0x33, 0xf2, 0x26, 0x58, 0x1a, 0xc3, 0xcf, 0xc6, 0x8f, + 0xa1, 0x21, 0x69, 0xa4, 0x36, 0x19, 0x71, 0x5a, 0x5e, 0x5c, 0x19, 0x4a, 0xd6, 0x24, 0xa6, 0x33, + 0xe3, 0xbf, 0x05, 0x80, 0xe1, 0x2c, 0xa5, 0x78, 0xc2, 0x12, 0x0f, 0xed, 0xc3, 0x96, 0x88, 0x01, + 0x67, 0x28, 0xda, 0xf2, 0x86, 0x7e, 0x00, 0x30, 0x26, 0x09, 0x99, 0xd2, 0x20, 0xc2, 0x29, 0xd7, + 0xad, 0x64, 0x67, 0x20, 0x32, 0xd4, 0x11, 0xf6, 0x69, 0x40, 0xa2, 0xd4, 0x0d, 0x22, 0xee, 0xa5, + 0x12, 0x0f, 0xb5, 0x82, 0x76, 0x22, 0xf4, 0x31, 0x3c, 0xc8, 0x92, 0x91, 0xa9, 0x08, 0x5e, 0xc9, + 0xce, 0x72, 0xf7, 0xa7, 0x14, 0xfd, 0x04, 0x76, 0x68, 0xe2, 0xdd, 0xdc, 0x04, 0xbe, 0xeb, 0xdd, + 0x79, 0x41, 0xc8, 0x32, 0xa0, 0x59, 0xe2, 0x71, 0xd6, 0x25, 0xc2, 0x54, 0x70, 0xa6, 0xf4, 0x34, + 0x0e, 0x83, 0xe8, 0xb6, 0xb9, 0x25, 0x94, 0x16, 0x37, 0x74, 0x00, 0x95, 0x11, 0xf9, 0x2a, 0xe2, + 0x98, 0x32, 0xc7, 0xcc, 0xef, 0x2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x7b, 0x40, 0x3e, 0xdc, 0xf9, 0x01, 0x7f, 0x26, + 0x9f, 0xa4, 0x43, 0x9c, 0xdc, 0x05, 0x3e, 0xfe, 0xd6, 0x11, 0x7f, 0x05, 0x9b, 0xcc, 0x52, 0xb4, + 0x93, 0xa5, 0xe2, 0x0f, 0xa4, 0xf7, 0x30, 0x9a, 0x50, 0xb6, 0x71, 0xfa, 0x9d, 0xb2, 0x8d, 0x65, + 0x7e, 0x6e, 0x84, 0xa2, 0x0f, 0xf3, 0x3e, 0x5c, 0x31, 0x5e, 0xd7, 0x38, 0xf3, 0x17, 0x50, 0x96, + 0x43, 0x13, 0x1d, 0x64, 0x09, 0xf2, 0x93, 0x74, 0x0d, 0xb3, 0x0b, 0xe8, 0xfe, 0x08, 0x45, 0x1f, + 0x65, 0x69, 0xd7, 0x8e, 0xd8, 0x03, 0x63, 0x79, 0x63, 0x5c, 0xb1, 0xaa, 0xbe, 0x81, 0xbd, 0xf3, + 0xdc, 0x8c, 0x94, 0xfb, 0xe2, 0x0a, 0xa7, 0x3f, 0xbd, 0x9f, 0x6a, 0x59, 0x0e, 0xbe, 0x75, 0xac, + 0x98, 0xb6, 0xe8, 0x70, 0x29, 0xfb, 0xd6, 0x0e, 0xe4, 0x35, 0x3e, 0x38, 0x85, 0x1a, 0x6b, 0xa2, + 0xef, 0x2d, 0xfa, 0xfd, 0xa5, 0x39, 0x2b, 0x07, 0x19, 0x2b, 0x85, 0xd3, 0xed, 0xdf, 0xd5, 0x8f, + 0x5f, 0x2c, 0xd0, 0xd7, 0x5b, 0xfc, 0x5f, 0xcf, 0x67, 0xff, 0x0f, 0x00, 0x00, 0xff, 0xff, 0x78, + 0x0f, 0x0b, 0x3c, 0x07, 0x12, 0x00, 0x00, +} diff --git a/hiddifyrpc/hiddify.proto b/hiddifyrpc/hiddify.proto new file mode 100644 index 0000000..4cfec46 --- /dev/null +++ b/hiddifyrpc/hiddify.proto @@ -0,0 +1,214 @@ +syntax = "proto3"; + +package hiddifyrpc; + +option go_package = "./hiddifyrpc"; + +enum ResponseCode { + OK = 0; + FAILED = 1; +} + +enum CoreState { + STOPPED = 0; + STARTING = 1; + STARTED = 2; + STOPPING = 3; +} + +enum MessageType { + EMPTY=0; + EMPTY_CONFIGURATION = 1; + START_COMMAND_SERVER = 2; + CREATE_SERVICE = 3; + START_SERVICE = 4; + UNEXPECTED_ERROR = 5; + ALREADY_STARTED = 6; + ALREADY_STOPPED = 7; + INSTANCE_NOT_FOUND = 8; + INSTANCE_NOT_STOPPED = 9; + INSTANCE_NOT_STARTED = 10; + ERROR_BUILDING_CONFIG = 11; + ERROR_PARSING_CONFIG = 12; + ERROR_READING_CONFIG = 13; +} + +message CoreInfoResponse { + CoreState core_state = 1; + MessageType message_type = 2; + string message = 3; +} + +message StartRequest { + string config_path = 1; + string config_content = 2; // Optional if configPath is not provided. + bool disable_memory_limit = 3; + bool delay_start = 4; +} + +message SetupRequest { + string base_path = 1; + string working_path = 2; + string temp_path = 3; +} + +message Response { + ResponseCode response_code = 1; + string message = 2; +} + + +message HelloRequest { + string name = 1; +} + +message HelloResponse { + string message = 1; +} + +message Empty { +} + +message SystemInfo { + int64 memory = 1; + int32 goroutines = 2; + int32 connections_in = 3; + int32 connections_out = 4; + bool traffic_available = 5; + int64 uplink = 6; + int64 downlink = 7; + int64 uplink_total = 8; + int64 downlink_total = 9; +} + +message OutboundGroupItem { + string tag = 1; + string type = 2; + int64 url_test_time = 3; + int32 url_test_delay = 4; +} + +message OutboundGroup { + string tag = 1; + string type = 2; + string selected=3; + repeated OutboundGroupItem items = 4; + +} +message OutboundGroupList{ + repeated OutboundGroup items = 1; +} + +message WarpAccount { + string account_id = 1; + string access_token = 2; +} + +message WarpWireguardConfig { + string private_key = 1; + string local_address_ipv4 = 2; + string local_address_ipv6 = 3; + string peer_public_key = 4; +} + +message WarpGenerationResponse { + WarpAccount account = 1; + string log = 2; + WarpWireguardConfig config = 3; +} + +message SystemProxyStatus { + bool available = 1; + bool enabled = 2; +} + +message ParseRequest { + string content = 1; + bool debug = 2; +} + +message ParseResponse { + ResponseCode response_code = 1; + string content = 2; + string message = 3; +} + +message ChangeConfigOptionsRequest { + string config_options_json = 1; +} + +message GenerateConfigRequest { + string path = 1; + string temp_path = 2; + bool debug = 3; +} + +message GenerateConfigResponse { + string config_content = 1; +} + + + +message SelectOutboundRequest { + string group_tag = 1; + string outbound_tag = 2; +} + +message UrlTestRequest { + string group_tag = 1; +} + +message GenerateWarpConfigRequest { + string license_key = 1; + string account_id = 2; + string access_token = 3; +} + +message SetSystemProxyEnabledRequest { + bool is_enabled = 1; +} + +enum LogLevel { + DEBUG = 0; + INFO = 1; + WARNING = 2; + ERROR = 3; + FATAL = 4; +} +enum LogType { + CORE = 0; + SERVICE = 1; + CONFIG = 2; +} +message LogMessage { + LogLevel level = 1; + LogType type = 2; + string message = 3; +} + +message StopRequest{ +} + +service Hiddify { + rpc SayHello (HelloRequest) returns (HelloResponse); + rpc SayHelloStream (stream HelloRequest) returns (stream HelloResponse); + rpc Start (StartRequest) returns (CoreInfoResponse); + rpc CoreInfoListener (stream StopRequest) returns (stream CoreInfoResponse); + rpc OutboundsInfo (stream StopRequest) returns (stream OutboundGroupList); + rpc MainOutboundsInfo (stream StopRequest) returns (stream OutboundGroupList); + rpc GetSystemInfo (stream StopRequest) returns (stream SystemInfo); + rpc Setup (SetupRequest) returns (Response); + rpc Parse (ParseRequest) returns (ParseResponse); + //rpc ChangeConfigOptions (ChangeConfigOptionsRequest) returns (CoreInfoResponse); + //rpc GenerateConfig (GenerateConfigRequest) returns (GenerateConfigResponse); + rpc StartService (StartRequest) returns (CoreInfoResponse); + rpc Stop (Empty) returns (CoreInfoResponse); + rpc Restart (StartRequest) returns (CoreInfoResponse); + rpc SelectOutbound (SelectOutboundRequest) returns (Response); + rpc UrlTest (UrlTestRequest) returns (Response); + rpc GenerateWarpConfig (GenerateWarpConfigRequest) returns (WarpGenerationResponse); + rpc GetSystemProxyStatus (Empty) returns (SystemProxyStatus); + rpc SetSystemProxyEnabled (SetSystemProxyEnabledRequest) returns (Response); + rpc LogListener (stream StopRequest) returns (stream LogMessage); + +} diff --git a/hiddifyrpc/hiddify_grpc.pb.go b/hiddifyrpc/hiddify_grpc.pb.go new file mode 100644 index 0000000..1672d83 --- /dev/null +++ b/hiddifyrpc/hiddify_grpc.pb.go @@ -0,0 +1,935 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc v3.6.1 +// source: hiddifyrpc/hiddify.proto + +package hiddifyrpc + +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.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + Hiddify_SayHello_FullMethodName = "/hiddifyrpc.Hiddify/SayHello" + Hiddify_SayHelloStream_FullMethodName = "/hiddifyrpc.Hiddify/SayHelloStream" + Hiddify_Start_FullMethodName = "/hiddifyrpc.Hiddify/Start" + Hiddify_CoreInfoListener_FullMethodName = "/hiddifyrpc.Hiddify/CoreInfoListener" + Hiddify_OutboundsInfo_FullMethodName = "/hiddifyrpc.Hiddify/OutboundsInfo" + Hiddify_MainOutboundsInfo_FullMethodName = "/hiddifyrpc.Hiddify/MainOutboundsInfo" + Hiddify_GetSystemInfo_FullMethodName = "/hiddifyrpc.Hiddify/GetSystemInfo" + Hiddify_Setup_FullMethodName = "/hiddifyrpc.Hiddify/Setup" + Hiddify_Parse_FullMethodName = "/hiddifyrpc.Hiddify/Parse" + Hiddify_StartService_FullMethodName = "/hiddifyrpc.Hiddify/StartService" + Hiddify_Stop_FullMethodName = "/hiddifyrpc.Hiddify/Stop" + Hiddify_Restart_FullMethodName = "/hiddifyrpc.Hiddify/Restart" + Hiddify_SelectOutbound_FullMethodName = "/hiddifyrpc.Hiddify/SelectOutbound" + Hiddify_UrlTest_FullMethodName = "/hiddifyrpc.Hiddify/UrlTest" + Hiddify_GenerateWarpConfig_FullMethodName = "/hiddifyrpc.Hiddify/GenerateWarpConfig" + Hiddify_GetSystemProxyStatus_FullMethodName = "/hiddifyrpc.Hiddify/GetSystemProxyStatus" + Hiddify_SetSystemProxyEnabled_FullMethodName = "/hiddifyrpc.Hiddify/SetSystemProxyEnabled" + Hiddify_LogListener_FullMethodName = "/hiddifyrpc.Hiddify/LogListener" +) + +// HiddifyClient is the client API for Hiddify 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 HiddifyClient interface { + SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloResponse, error) + SayHelloStream(ctx context.Context, opts ...grpc.CallOption) (Hiddify_SayHelloStreamClient, error) + Start(ctx context.Context, in *StartRequest, opts ...grpc.CallOption) (*CoreInfoResponse, error) + CoreInfoListener(ctx context.Context, opts ...grpc.CallOption) (Hiddify_CoreInfoListenerClient, error) + OutboundsInfo(ctx context.Context, opts ...grpc.CallOption) (Hiddify_OutboundsInfoClient, error) + MainOutboundsInfo(ctx context.Context, opts ...grpc.CallOption) (Hiddify_MainOutboundsInfoClient, error) + GetSystemInfo(ctx context.Context, opts ...grpc.CallOption) (Hiddify_GetSystemInfoClient, error) + Setup(ctx context.Context, in *SetupRequest, opts ...grpc.CallOption) (*Response, error) + Parse(ctx context.Context, in *ParseRequest, opts ...grpc.CallOption) (*ParseResponse, error) + //rpc ChangeConfigOptions (ChangeConfigOptionsRequest) returns (CoreInfoResponse); + //rpc GenerateConfig (GenerateConfigRequest) returns (GenerateConfigResponse); + StartService(ctx context.Context, in *StartRequest, opts ...grpc.CallOption) (*CoreInfoResponse, error) + Stop(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*CoreInfoResponse, error) + Restart(ctx context.Context, in *StartRequest, opts ...grpc.CallOption) (*CoreInfoResponse, error) + SelectOutbound(ctx context.Context, in *SelectOutboundRequest, opts ...grpc.CallOption) (*Response, error) + UrlTest(ctx context.Context, in *UrlTestRequest, opts ...grpc.CallOption) (*Response, error) + GenerateWarpConfig(ctx context.Context, in *GenerateWarpConfigRequest, opts ...grpc.CallOption) (*WarpGenerationResponse, error) + GetSystemProxyStatus(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*SystemProxyStatus, error) + SetSystemProxyEnabled(ctx context.Context, in *SetSystemProxyEnabledRequest, opts ...grpc.CallOption) (*Response, error) + LogListener(ctx context.Context, opts ...grpc.CallOption) (Hiddify_LogListenerClient, error) +} + +type hiddifyClient struct { + cc grpc.ClientConnInterface +} + +func NewHiddifyClient(cc grpc.ClientConnInterface) HiddifyClient { + return &hiddifyClient{cc} +} + +func (c *hiddifyClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloResponse, error) { + out := new(HelloResponse) + err := c.cc.Invoke(ctx, Hiddify_SayHello_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *hiddifyClient) SayHelloStream(ctx context.Context, opts ...grpc.CallOption) (Hiddify_SayHelloStreamClient, error) { + stream, err := c.cc.NewStream(ctx, &Hiddify_ServiceDesc.Streams[0], Hiddify_SayHelloStream_FullMethodName, opts...) + if err != nil { + return nil, err + } + x := &hiddifySayHelloStreamClient{stream} + return x, nil +} + +type Hiddify_SayHelloStreamClient interface { + Send(*HelloRequest) error + Recv() (*HelloResponse, error) + grpc.ClientStream +} + +type hiddifySayHelloStreamClient struct { + grpc.ClientStream +} + +func (x *hiddifySayHelloStreamClient) Send(m *HelloRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *hiddifySayHelloStreamClient) Recv() (*HelloResponse, error) { + m := new(HelloResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *hiddifyClient) Start(ctx context.Context, in *StartRequest, opts ...grpc.CallOption) (*CoreInfoResponse, error) { + out := new(CoreInfoResponse) + err := c.cc.Invoke(ctx, Hiddify_Start_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *hiddifyClient) CoreInfoListener(ctx context.Context, opts ...grpc.CallOption) (Hiddify_CoreInfoListenerClient, error) { + stream, err := c.cc.NewStream(ctx, &Hiddify_ServiceDesc.Streams[1], Hiddify_CoreInfoListener_FullMethodName, opts...) + if err != nil { + return nil, err + } + x := &hiddifyCoreInfoListenerClient{stream} + return x, nil +} + +type Hiddify_CoreInfoListenerClient interface { + Send(*StopRequest) error + Recv() (*CoreInfoResponse, error) + grpc.ClientStream +} + +type hiddifyCoreInfoListenerClient struct { + grpc.ClientStream +} + +func (x *hiddifyCoreInfoListenerClient) Send(m *StopRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *hiddifyCoreInfoListenerClient) Recv() (*CoreInfoResponse, error) { + m := new(CoreInfoResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *hiddifyClient) OutboundsInfo(ctx context.Context, opts ...grpc.CallOption) (Hiddify_OutboundsInfoClient, error) { + stream, err := c.cc.NewStream(ctx, &Hiddify_ServiceDesc.Streams[2], Hiddify_OutboundsInfo_FullMethodName, opts...) + if err != nil { + return nil, err + } + x := &hiddifyOutboundsInfoClient{stream} + return x, nil +} + +type Hiddify_OutboundsInfoClient interface { + Send(*StopRequest) error + Recv() (*OutboundGroupList, error) + grpc.ClientStream +} + +type hiddifyOutboundsInfoClient struct { + grpc.ClientStream +} + +func (x *hiddifyOutboundsInfoClient) Send(m *StopRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *hiddifyOutboundsInfoClient) Recv() (*OutboundGroupList, error) { + m := new(OutboundGroupList) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *hiddifyClient) MainOutboundsInfo(ctx context.Context, opts ...grpc.CallOption) (Hiddify_MainOutboundsInfoClient, error) { + stream, err := c.cc.NewStream(ctx, &Hiddify_ServiceDesc.Streams[3], Hiddify_MainOutboundsInfo_FullMethodName, opts...) + if err != nil { + return nil, err + } + x := &hiddifyMainOutboundsInfoClient{stream} + return x, nil +} + +type Hiddify_MainOutboundsInfoClient interface { + Send(*StopRequest) error + Recv() (*OutboundGroupList, error) + grpc.ClientStream +} + +type hiddifyMainOutboundsInfoClient struct { + grpc.ClientStream +} + +func (x *hiddifyMainOutboundsInfoClient) Send(m *StopRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *hiddifyMainOutboundsInfoClient) Recv() (*OutboundGroupList, error) { + m := new(OutboundGroupList) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *hiddifyClient) GetSystemInfo(ctx context.Context, opts ...grpc.CallOption) (Hiddify_GetSystemInfoClient, error) { + stream, err := c.cc.NewStream(ctx, &Hiddify_ServiceDesc.Streams[4], Hiddify_GetSystemInfo_FullMethodName, opts...) + if err != nil { + return nil, err + } + x := &hiddifyGetSystemInfoClient{stream} + return x, nil +} + +type Hiddify_GetSystemInfoClient interface { + Send(*StopRequest) error + Recv() (*SystemInfo, error) + grpc.ClientStream +} + +type hiddifyGetSystemInfoClient struct { + grpc.ClientStream +} + +func (x *hiddifyGetSystemInfoClient) Send(m *StopRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *hiddifyGetSystemInfoClient) Recv() (*SystemInfo, error) { + m := new(SystemInfo) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *hiddifyClient) Setup(ctx context.Context, in *SetupRequest, opts ...grpc.CallOption) (*Response, error) { + out := new(Response) + err := c.cc.Invoke(ctx, Hiddify_Setup_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *hiddifyClient) Parse(ctx context.Context, in *ParseRequest, opts ...grpc.CallOption) (*ParseResponse, error) { + out := new(ParseResponse) + err := c.cc.Invoke(ctx, Hiddify_Parse_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *hiddifyClient) StartService(ctx context.Context, in *StartRequest, opts ...grpc.CallOption) (*CoreInfoResponse, error) { + out := new(CoreInfoResponse) + err := c.cc.Invoke(ctx, Hiddify_StartService_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *hiddifyClient) Stop(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*CoreInfoResponse, error) { + out := new(CoreInfoResponse) + err := c.cc.Invoke(ctx, Hiddify_Stop_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *hiddifyClient) Restart(ctx context.Context, in *StartRequest, opts ...grpc.CallOption) (*CoreInfoResponse, error) { + out := new(CoreInfoResponse) + err := c.cc.Invoke(ctx, Hiddify_Restart_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *hiddifyClient) SelectOutbound(ctx context.Context, in *SelectOutboundRequest, opts ...grpc.CallOption) (*Response, error) { + out := new(Response) + err := c.cc.Invoke(ctx, Hiddify_SelectOutbound_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *hiddifyClient) UrlTest(ctx context.Context, in *UrlTestRequest, opts ...grpc.CallOption) (*Response, error) { + out := new(Response) + err := c.cc.Invoke(ctx, Hiddify_UrlTest_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *hiddifyClient) GenerateWarpConfig(ctx context.Context, in *GenerateWarpConfigRequest, opts ...grpc.CallOption) (*WarpGenerationResponse, error) { + out := new(WarpGenerationResponse) + err := c.cc.Invoke(ctx, Hiddify_GenerateWarpConfig_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *hiddifyClient) GetSystemProxyStatus(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*SystemProxyStatus, error) { + out := new(SystemProxyStatus) + err := c.cc.Invoke(ctx, Hiddify_GetSystemProxyStatus_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *hiddifyClient) SetSystemProxyEnabled(ctx context.Context, in *SetSystemProxyEnabledRequest, opts ...grpc.CallOption) (*Response, error) { + out := new(Response) + err := c.cc.Invoke(ctx, Hiddify_SetSystemProxyEnabled_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *hiddifyClient) LogListener(ctx context.Context, opts ...grpc.CallOption) (Hiddify_LogListenerClient, error) { + stream, err := c.cc.NewStream(ctx, &Hiddify_ServiceDesc.Streams[5], Hiddify_LogListener_FullMethodName, opts...) + if err != nil { + return nil, err + } + x := &hiddifyLogListenerClient{stream} + return x, nil +} + +type Hiddify_LogListenerClient interface { + Send(*StopRequest) error + Recv() (*LogMessage, error) + grpc.ClientStream +} + +type hiddifyLogListenerClient struct { + grpc.ClientStream +} + +func (x *hiddifyLogListenerClient) Send(m *StopRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *hiddifyLogListenerClient) Recv() (*LogMessage, error) { + m := new(LogMessage) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// HiddifyServer is the server API for Hiddify service. +// All implementations must embed UnimplementedHiddifyServer +// for forward compatibility +type HiddifyServer interface { + SayHello(context.Context, *HelloRequest) (*HelloResponse, error) + SayHelloStream(Hiddify_SayHelloStreamServer) error + Start(context.Context, *StartRequest) (*CoreInfoResponse, error) + CoreInfoListener(Hiddify_CoreInfoListenerServer) error + OutboundsInfo(Hiddify_OutboundsInfoServer) error + MainOutboundsInfo(Hiddify_MainOutboundsInfoServer) error + GetSystemInfo(Hiddify_GetSystemInfoServer) error + Setup(context.Context, *SetupRequest) (*Response, error) + Parse(context.Context, *ParseRequest) (*ParseResponse, error) + //rpc ChangeConfigOptions (ChangeConfigOptionsRequest) returns (CoreInfoResponse); + //rpc GenerateConfig (GenerateConfigRequest) returns (GenerateConfigResponse); + StartService(context.Context, *StartRequest) (*CoreInfoResponse, error) + Stop(context.Context, *Empty) (*CoreInfoResponse, error) + Restart(context.Context, *StartRequest) (*CoreInfoResponse, error) + SelectOutbound(context.Context, *SelectOutboundRequest) (*Response, error) + UrlTest(context.Context, *UrlTestRequest) (*Response, error) + GenerateWarpConfig(context.Context, *GenerateWarpConfigRequest) (*WarpGenerationResponse, error) + GetSystemProxyStatus(context.Context, *Empty) (*SystemProxyStatus, error) + SetSystemProxyEnabled(context.Context, *SetSystemProxyEnabledRequest) (*Response, error) + LogListener(Hiddify_LogListenerServer) error + mustEmbedUnimplementedHiddifyServer() +} + +// UnimplementedHiddifyServer must be embedded to have forward compatible implementations. +type UnimplementedHiddifyServer struct { +} + +func (UnimplementedHiddifyServer) SayHello(context.Context, *HelloRequest) (*HelloResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented") +} +func (UnimplementedHiddifyServer) SayHelloStream(Hiddify_SayHelloStreamServer) error { + return status.Errorf(codes.Unimplemented, "method SayHelloStream not implemented") +} +func (UnimplementedHiddifyServer) Start(context.Context, *StartRequest) (*CoreInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Start not implemented") +} +func (UnimplementedHiddifyServer) CoreInfoListener(Hiddify_CoreInfoListenerServer) error { + return status.Errorf(codes.Unimplemented, "method CoreInfoListener not implemented") +} +func (UnimplementedHiddifyServer) OutboundsInfo(Hiddify_OutboundsInfoServer) error { + return status.Errorf(codes.Unimplemented, "method OutboundsInfo not implemented") +} +func (UnimplementedHiddifyServer) MainOutboundsInfo(Hiddify_MainOutboundsInfoServer) error { + return status.Errorf(codes.Unimplemented, "method MainOutboundsInfo not implemented") +} +func (UnimplementedHiddifyServer) GetSystemInfo(Hiddify_GetSystemInfoServer) error { + return status.Errorf(codes.Unimplemented, "method GetSystemInfo not implemented") +} +func (UnimplementedHiddifyServer) Setup(context.Context, *SetupRequest) (*Response, error) { + return nil, status.Errorf(codes.Unimplemented, "method Setup not implemented") +} +func (UnimplementedHiddifyServer) Parse(context.Context, *ParseRequest) (*ParseResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Parse not implemented") +} +func (UnimplementedHiddifyServer) StartService(context.Context, *StartRequest) (*CoreInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method StartService not implemented") +} +func (UnimplementedHiddifyServer) Stop(context.Context, *Empty) (*CoreInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Stop not implemented") +} +func (UnimplementedHiddifyServer) Restart(context.Context, *StartRequest) (*CoreInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Restart not implemented") +} +func (UnimplementedHiddifyServer) SelectOutbound(context.Context, *SelectOutboundRequest) (*Response, error) { + return nil, status.Errorf(codes.Unimplemented, "method SelectOutbound not implemented") +} +func (UnimplementedHiddifyServer) UrlTest(context.Context, *UrlTestRequest) (*Response, error) { + return nil, status.Errorf(codes.Unimplemented, "method UrlTest not implemented") +} +func (UnimplementedHiddifyServer) GenerateWarpConfig(context.Context, *GenerateWarpConfigRequest) (*WarpGenerationResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GenerateWarpConfig not implemented") +} +func (UnimplementedHiddifyServer) GetSystemProxyStatus(context.Context, *Empty) (*SystemProxyStatus, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetSystemProxyStatus not implemented") +} +func (UnimplementedHiddifyServer) SetSystemProxyEnabled(context.Context, *SetSystemProxyEnabledRequest) (*Response, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetSystemProxyEnabled not implemented") +} +func (UnimplementedHiddifyServer) LogListener(Hiddify_LogListenerServer) error { + return status.Errorf(codes.Unimplemented, "method LogListener not implemented") +} +func (UnimplementedHiddifyServer) mustEmbedUnimplementedHiddifyServer() {} + +// UnsafeHiddifyServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to HiddifyServer will +// result in compilation errors. +type UnsafeHiddifyServer interface { + mustEmbedUnimplementedHiddifyServer() +} + +func RegisterHiddifyServer(s grpc.ServiceRegistrar, srv HiddifyServer) { + s.RegisterService(&Hiddify_ServiceDesc, srv) +} + +func _Hiddify_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(HelloRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HiddifyServer).SayHello(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Hiddify_SayHello_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HiddifyServer).SayHello(ctx, req.(*HelloRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Hiddify_SayHelloStream_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(HiddifyServer).SayHelloStream(&hiddifySayHelloStreamServer{stream}) +} + +type Hiddify_SayHelloStreamServer interface { + Send(*HelloResponse) error + Recv() (*HelloRequest, error) + grpc.ServerStream +} + +type hiddifySayHelloStreamServer struct { + grpc.ServerStream +} + +func (x *hiddifySayHelloStreamServer) Send(m *HelloResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *hiddifySayHelloStreamServer) Recv() (*HelloRequest, error) { + m := new(HelloRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _Hiddify_Start_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StartRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HiddifyServer).Start(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Hiddify_Start_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HiddifyServer).Start(ctx, req.(*StartRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Hiddify_CoreInfoListener_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(HiddifyServer).CoreInfoListener(&hiddifyCoreInfoListenerServer{stream}) +} + +type Hiddify_CoreInfoListenerServer interface { + Send(*CoreInfoResponse) error + Recv() (*StopRequest, error) + grpc.ServerStream +} + +type hiddifyCoreInfoListenerServer struct { + grpc.ServerStream +} + +func (x *hiddifyCoreInfoListenerServer) Send(m *CoreInfoResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *hiddifyCoreInfoListenerServer) Recv() (*StopRequest, error) { + m := new(StopRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _Hiddify_OutboundsInfo_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(HiddifyServer).OutboundsInfo(&hiddifyOutboundsInfoServer{stream}) +} + +type Hiddify_OutboundsInfoServer interface { + Send(*OutboundGroupList) error + Recv() (*StopRequest, error) + grpc.ServerStream +} + +type hiddifyOutboundsInfoServer struct { + grpc.ServerStream +} + +func (x *hiddifyOutboundsInfoServer) Send(m *OutboundGroupList) error { + return x.ServerStream.SendMsg(m) +} + +func (x *hiddifyOutboundsInfoServer) Recv() (*StopRequest, error) { + m := new(StopRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _Hiddify_MainOutboundsInfo_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(HiddifyServer).MainOutboundsInfo(&hiddifyMainOutboundsInfoServer{stream}) +} + +type Hiddify_MainOutboundsInfoServer interface { + Send(*OutboundGroupList) error + Recv() (*StopRequest, error) + grpc.ServerStream +} + +type hiddifyMainOutboundsInfoServer struct { + grpc.ServerStream +} + +func (x *hiddifyMainOutboundsInfoServer) Send(m *OutboundGroupList) error { + return x.ServerStream.SendMsg(m) +} + +func (x *hiddifyMainOutboundsInfoServer) Recv() (*StopRequest, error) { + m := new(StopRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _Hiddify_GetSystemInfo_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(HiddifyServer).GetSystemInfo(&hiddifyGetSystemInfoServer{stream}) +} + +type Hiddify_GetSystemInfoServer interface { + Send(*SystemInfo) error + Recv() (*StopRequest, error) + grpc.ServerStream +} + +type hiddifyGetSystemInfoServer struct { + grpc.ServerStream +} + +func (x *hiddifyGetSystemInfoServer) Send(m *SystemInfo) error { + return x.ServerStream.SendMsg(m) +} + +func (x *hiddifyGetSystemInfoServer) Recv() (*StopRequest, error) { + m := new(StopRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _Hiddify_Setup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SetupRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HiddifyServer).Setup(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Hiddify_Setup_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HiddifyServer).Setup(ctx, req.(*SetupRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Hiddify_Parse_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ParseRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HiddifyServer).Parse(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Hiddify_Parse_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HiddifyServer).Parse(ctx, req.(*ParseRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Hiddify_StartService_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StartRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HiddifyServer).StartService(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Hiddify_StartService_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HiddifyServer).StartService(ctx, req.(*StartRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Hiddify_Stop_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HiddifyServer).Stop(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Hiddify_Stop_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HiddifyServer).Stop(ctx, req.(*Empty)) + } + return interceptor(ctx, in, info, handler) +} + +func _Hiddify_Restart_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StartRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HiddifyServer).Restart(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Hiddify_Restart_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HiddifyServer).Restart(ctx, req.(*StartRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Hiddify_SelectOutbound_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SelectOutboundRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HiddifyServer).SelectOutbound(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Hiddify_SelectOutbound_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HiddifyServer).SelectOutbound(ctx, req.(*SelectOutboundRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Hiddify_UrlTest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UrlTestRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HiddifyServer).UrlTest(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Hiddify_UrlTest_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HiddifyServer).UrlTest(ctx, req.(*UrlTestRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Hiddify_GenerateWarpConfig_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GenerateWarpConfigRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HiddifyServer).GenerateWarpConfig(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Hiddify_GenerateWarpConfig_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HiddifyServer).GenerateWarpConfig(ctx, req.(*GenerateWarpConfigRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Hiddify_GetSystemProxyStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HiddifyServer).GetSystemProxyStatus(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Hiddify_GetSystemProxyStatus_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HiddifyServer).GetSystemProxyStatus(ctx, req.(*Empty)) + } + return interceptor(ctx, in, info, handler) +} + +func _Hiddify_SetSystemProxyEnabled_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SetSystemProxyEnabledRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HiddifyServer).SetSystemProxyEnabled(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Hiddify_SetSystemProxyEnabled_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HiddifyServer).SetSystemProxyEnabled(ctx, req.(*SetSystemProxyEnabledRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Hiddify_LogListener_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(HiddifyServer).LogListener(&hiddifyLogListenerServer{stream}) +} + +type Hiddify_LogListenerServer interface { + Send(*LogMessage) error + Recv() (*StopRequest, error) + grpc.ServerStream +} + +type hiddifyLogListenerServer struct { + grpc.ServerStream +} + +func (x *hiddifyLogListenerServer) Send(m *LogMessage) error { + return x.ServerStream.SendMsg(m) +} + +func (x *hiddifyLogListenerServer) Recv() (*StopRequest, error) { + m := new(StopRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// Hiddify_ServiceDesc is the grpc.ServiceDesc for Hiddify service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Hiddify_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "hiddifyrpc.Hiddify", + HandlerType: (*HiddifyServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "SayHello", + Handler: _Hiddify_SayHello_Handler, + }, + { + MethodName: "Start", + Handler: _Hiddify_Start_Handler, + }, + { + MethodName: "Setup", + Handler: _Hiddify_Setup_Handler, + }, + { + MethodName: "Parse", + Handler: _Hiddify_Parse_Handler, + }, + { + MethodName: "StartService", + Handler: _Hiddify_StartService_Handler, + }, + { + MethodName: "Stop", + Handler: _Hiddify_Stop_Handler, + }, + { + MethodName: "Restart", + Handler: _Hiddify_Restart_Handler, + }, + { + MethodName: "SelectOutbound", + Handler: _Hiddify_SelectOutbound_Handler, + }, + { + MethodName: "UrlTest", + Handler: _Hiddify_UrlTest_Handler, + }, + { + MethodName: "GenerateWarpConfig", + Handler: _Hiddify_GenerateWarpConfig_Handler, + }, + { + MethodName: "GetSystemProxyStatus", + Handler: _Hiddify_GetSystemProxyStatus_Handler, + }, + { + MethodName: "SetSystemProxyEnabled", + Handler: _Hiddify_SetSystemProxyEnabled_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "SayHelloStream", + Handler: _Hiddify_SayHelloStream_Handler, + ServerStreams: true, + ClientStreams: true, + }, + { + StreamName: "CoreInfoListener", + Handler: _Hiddify_CoreInfoListener_Handler, + ServerStreams: true, + ClientStreams: true, + }, + { + StreamName: "OutboundsInfo", + Handler: _Hiddify_OutboundsInfo_Handler, + ServerStreams: true, + ClientStreams: true, + }, + { + StreamName: "MainOutboundsInfo", + Handler: _Hiddify_MainOutboundsInfo_Handler, + ServerStreams: true, + ClientStreams: true, + }, + { + StreamName: "GetSystemInfo", + Handler: _Hiddify_GetSystemInfo_Handler, + ServerStreams: true, + ClientStreams: true, + }, + { + StreamName: "LogListener", + Handler: _Hiddify_LogListener_Handler, + ServerStreams: true, + ClientStreams: true, + }, + }, + Metadata: "hiddifyrpc/hiddify.proto", +} diff --git a/v2/command_client.go b/v2/command_client.go new file mode 100644 index 0000000..62c9ad5 --- /dev/null +++ b/v2/command_client.go @@ -0,0 +1,77 @@ +package v2 + +import ( + pb "github.com/hiddify/libcore/hiddifyrpc" + "github.com/sagernet/sing-box/experimental/libbox" + "github.com/sagernet/sing-box/log" +) + +type CommandClientHandler struct { + port int64 + logger log.Logger +} + +func (cch *CommandClientHandler) Connected() { + cch.logger.Debug("CONNECTED") +} + +func (cch *CommandClientHandler) Disconnected(message string) { + cch.logger.Debug("DISCONNECTED: ", message) +} + +func (cch *CommandClientHandler) ClearLog() { + cch.logger.Debug("clear log") +} + +func (cch *CommandClientHandler) WriteLog(message string) { + cch.logger.Debug("log: ", message) +} + +func (cch *CommandClientHandler) WriteStatus(message *libbox.StatusMessage) { + systemInfoObserver.Emit(pb.SystemInfo{ + ConnectionsIn: message.ConnectionsIn, + ConnectionsOut: message.ConnectionsOut, + Uplink: message.Uplink, + Downlink: message.Downlink, + UplinkTotal: message.UplinkTotal, + DownlinkTotal: message.DownlinkTotal, + Memory: message.Memory, + Goroutines: message.Goroutines, + }) + cch.logger.Debug("Memory: ", libbox.FormatBytes(message.Memory), ", Goroutines: ", message.Goroutines) + +} + +func (cch *CommandClientHandler) WriteGroups(message libbox.OutboundGroupIterator) { + if message == nil { + return + } + groups := pb.OutboundGroupList{} + for message.HasNext() { + group := message.Next() + items := group.GetItems() + groupItems := []*pb.OutboundGroupItem{} + for items.HasNext() { + item := items.Next() + groupItems = append(groupItems, + &pb.OutboundGroupItem{ + Tag: item.Tag, + Type: item.Type, + UrlTestTime: item.URLTestTime, + UrlTestDelay: item.URLTestDelay, + }, + ) + } + groups.Items = append(groups.Items, &pb.OutboundGroup{Tag: group.Tag, Type: group.Type, Selected: group.Selected, Items: groupItems}) + } + outboundsInfoObserver.Emit(groups) + mainOutboundsInfoObserver.Emit(groups) +} + +func (cch *CommandClientHandler) InitializeClashMode(modeList libbox.StringIterator, currentMode string) { + cch.logger.Debug("initial clash mode: ", currentMode) +} + +func (cch *CommandClientHandler) UpdateClashMode(newMode string) { + cch.logger.Debug("update clash mode: ", newMode) +} diff --git a/v2/commands.go b/v2/commands.go new file mode 100644 index 0000000..7a4c4c1 --- /dev/null +++ b/v2/commands.go @@ -0,0 +1,163 @@ +package v2 + +import ( + "context" + "time" + + pb "github.com/hiddify/libcore/hiddifyrpc" + "github.com/sagernet/sing-box/experimental/libbox" + "github.com/sagernet/sing/common/observable" +) + +var systemInfoObserver = observable.Observer[pb.SystemInfo]{} +var outboundsInfoObserver = observable.Observer[pb.OutboundGroupList]{} +var mainOutboundsInfoObserver = observable.Observer[pb.OutboundGroupList]{} + +var ( + statusClient *libbox.CommandClient + groupClient *libbox.CommandClient + groupInfoOnlyClient *libbox.CommandClient +) + +func (s *server) GetSystemInfo(stream pb.Hiddify_GetSystemInfoServer) error { + if statusClient == nil { + statusClient = libbox.NewCommandClient( + &CommandClientHandler{}, + &libbox.CommandClientOptions{ + Command: libbox.CommandStatus, + StatusInterval: 1000000000, //1000ms debounce + }, + ) + + defer func() { + statusClient.Disconnect() + statusClient = nil + }() + statusClient.Connect() + } + + sub, _, _ := systemInfoObserver.Subscribe() + stopch := make(chan int) + go func() { + stream.Recv() + close(stopch) + }() + for { + select { + case <-stream.Context().Done(): + break + case <-stopch: + break + case info := <-sub: + stream.Send(&info) + case <-time.After(1000 * time.Millisecond): + } + } +} + +func (s *server) OutboundsInfo(stream pb.Hiddify_OutboundsInfoServer) error { + if groupClient == nil { + groupClient = libbox.NewCommandClient( + &CommandClientHandler{}, + &libbox.CommandClientOptions{ + Command: libbox.CommandGroup, + StatusInterval: 500000000, //500ms debounce + }, + ) + + defer func() { + groupClient.Disconnect() + groupClient = nil + }() + groupClient.Connect() + } + + sub, _, _ := outboundsInfoObserver.Subscribe() + stopch := make(chan int) + go func() { + stream.Recv() + close(stopch) + }() + for { + select { + case <-stream.Context().Done(): + break + case <-stopch: + break + case info := <-sub: + stream.Send(&info) + case <-time.After(500 * time.Millisecond): + } + } +} + +func (s *server) MainOutboundsInfo(stream pb.Hiddify_MainOutboundsInfoServer) error { + if groupInfoOnlyClient == nil { + groupInfoOnlyClient = libbox.NewCommandClient( + &CommandClientHandler{}, + &libbox.CommandClientOptions{ + Command: libbox.CommandGroupInfoOnly, + StatusInterval: 500000000, //500ms debounce + }, + ) + + defer func() { + groupInfoOnlyClient.Disconnect() + groupInfoOnlyClient = nil + }() + groupInfoOnlyClient.Connect() + } + + sub, _, _ := mainOutboundsInfoObserver.Subscribe() + stopch := make(chan int) + go func() { + stream.Recv() + close(stopch) + }() + for { + select { + case <-stream.Context().Done(): + break + case <-stopch: + break + case info := <-sub: + stream.Send(&info) + case <-time.After(500 * time.Millisecond): + } + } +} + +// Implement the SelectOutbound method +func (s *server) SelectOutbound(ctx context.Context, in *pb.SelectOutboundRequest) (*pb.Response, error) { + err := libbox.NewStandaloneCommandClient().SelectOutbound(in.GroupTag, in.OutboundTag) + + if err != nil { + return &pb.Response{ + ResponseCode: pb.ResponseCode_FAILED, + Message: err.Error(), + }, err + } + + return &pb.Response{ + ResponseCode: pb.ResponseCode_OK, + Message: "", + }, nil +} + +// Implement the UrlTest method +func (s *server) UrlTest(ctx context.Context, in *pb.UrlTestRequest) (*pb.Response, error) { + err := libbox.NewStandaloneCommandClient().URLTest(in.GroupTag) + + if err != nil { + return &pb.Response{ + ResponseCode: pb.ResponseCode_FAILED, + Message: err.Error(), + }, err + } + + return &pb.Response{ + ResponseCode: pb.ResponseCode_OK, + Message: "", + }, nil + +} diff --git a/v2/coreinfo.go b/v2/coreinfo.go new file mode 100644 index 0000000..7c59312 --- /dev/null +++ b/v2/coreinfo.go @@ -0,0 +1,44 @@ +package v2 + +import ( + "time" + + pb "github.com/hiddify/libcore/hiddifyrpc" + "github.com/sagernet/sing/common/observable" +) + +var coreInfoObserver = observable.Observer[pb.CoreInfoResponse]{} +var CoreState = pb.CoreState_STOPPED + +func SetCoreStatus(state pb.CoreState, msgType pb.MessageType, message string) pb.CoreInfoResponse { + CoreState = state + info := pb.CoreInfoResponse{ + CoreState: state, + MessageType: msgType, + Message: message, + } + coreInfoObserver.Emit(info) + return info + +} + +func (s *server) CoreInfoListener(stream pb.Hiddify_CoreInfoListenerServer) error { + coreSub, _, _ := coreInfoObserver.Subscribe() + defer coreInfoObserver.UnSubscribe(coreSub) + stopch := make(chan int) + go func() { + stream.Recv() + close(stopch) + }() + for { + select { + case <-stream.Context().Done(): + break + case <-stopch: + break + case info := <-coreSub: + stream.Send(&info) + case <-time.After(500 * time.Millisecond): + } + } +} diff --git a/v2/custom.go b/v2/custom.go new file mode 100644 index 0000000..03d7ec0 --- /dev/null +++ b/v2/custom.go @@ -0,0 +1,232 @@ +package v2 + +import ( + "context" + "fmt" + "os" + "path/filepath" + "time" + + "github.com/hiddify/libcore/config" + pb "github.com/hiddify/libcore/hiddifyrpc" + "github.com/sagernet/sing-box/experimental/libbox" + "github.com/sagernet/sing-box/log" + "github.com/sagernet/sing-box/option" +) + +var Box *libbox.BoxService +var configOptions *config.ConfigOptions +var activeConfigPath *string +var logFactory *log.Factory + +func stopAndAlert(msgType pb.MessageType, message string) { + SetCoreStatus(pb.CoreState_STOPPED, msgType, message) + config.DeactivateTunnelService() + // if commandServer != nil { + // commandServer.SetService(nil) + // } + if Box != nil { + Box.Close() + Box = nil + } + // if commandServer != nil { + // commandServer.Close() + // } +} + +func (s *server) Start(ctx context.Context, in *pb.StartRequest) (*pb.CoreInfoResponse, error) { + defer config.DeferPanicToError("start", func(err error) { + Log(pb.LogLevel_FATAL, pb.LogType_CORE, err.Error()) + stopAndAlert(pb.MessageType_UNEXPECTED_ERROR, err.Error()) + }) + + if CoreState != pb.CoreState_STOPPED { + return &pb.CoreInfoResponse{ + CoreState: CoreState, + MessageType: pb.MessageType_INSTANCE_NOT_STOPPED, + }, fmt.Errorf("instance not stopped") + } + SetCoreStatus(pb.CoreState_STARTING, pb.MessageType_EMPTY, "") + + libbox.SetMemoryLimit(!in.DisableMemoryLimit) + resp, err := s.StartService(ctx, in) + return resp, err +} + +// Implement the StartService method +func (s *server) StartService(ctx context.Context, in *pb.StartRequest) (*pb.CoreInfoResponse, error) { + + content := in.ConfigContent + if content != "" { + fileContent, err := os.ReadFile(*activeConfigPath) + if err != nil { + resp := SetCoreStatus(pb.CoreState_STOPPED, pb.MessageType_ERROR_READING_CONFIG, err.Error()) + return &resp, err + } + content = string(fileContent) + } + + parsedContent, err := parseConfig(content) + if err != nil { + resp := SetCoreStatus(pb.CoreState_STOPPED, pb.MessageType_ERROR_PARSING_CONFIG, err.Error()) + return &resp, err + } + var patchedOptions *option.Options + patchedOptions, err = config.BuildConfig(*configOptions, parsedContent) + if err != nil { + resp := SetCoreStatus(pb.CoreState_STOPPED, pb.MessageType_ERROR_BUILDING_CONFIG, err.Error()) + return &resp, err + } + + config.SaveCurrentConfig(filepath.Join(sWorkingPath, "current-config.json"), *patchedOptions) + + // err = startCommandServer(*logFactory) + // if err != nil { + // resp := SetCoreStatus(pb.CoreState_STOPPED, pb.MessageType_START_COMMAND_SERVER, err.Error()) + // return &resp, err + // } + + instance, err := NewService(*patchedOptions) + if err != nil { + resp := SetCoreStatus(pb.CoreState_STOPPED, pb.MessageType_CREATE_SERVICE, err.Error()) + return &resp, err + } + + if in.DelayStart { + <-time.After(250 * time.Millisecond) + } + + err = instance.Start() + if err != nil { + resp := SetCoreStatus(pb.CoreState_STOPPED, pb.MessageType_START_SERVICE, err.Error()) + return &resp, err + } + Box = instance + // commandServer.SetService(box) + + resp := SetCoreStatus(pb.CoreState_STARTED, pb.MessageType_EMPTY, "") + return &resp, nil + +} + +func (s *server) Parse(ctx context.Context, in *pb.ParseRequest) (*pb.ParseResponse, error) { + defer config.DeferPanicToError("parse", func(err error) { + Log(pb.LogLevel_FATAL, pb.LogType_CONFIG, err.Error()) + stopAndAlert(pb.MessageType_UNEXPECTED_ERROR, err.Error()) + }) + + config, err := config.ParseConfigContent(in.Content, true) + if err != nil { + return &pb.ParseResponse{ + ResponseCode: pb.ResponseCode_FAILED, + Message: err.Error(), + }, err + } + return &pb.ParseResponse{ + ResponseCode: pb.ResponseCode_OK, + Content: string(config), + Message: "", + }, err +} + +// func (s *server) ChangeConfigOptions(ctx context.Context, in *pb.ChangeConfigOptionsRequest) (*pb.CoreInfoResponse, error) { +// // Implement your change config options logic +// // Return a CoreInfoResponse +// } + +// func (s *server) GenerateConfig(ctx context.Context, in *pb.GenerateConfigRequest) (*pb.GenerateConfigResponse, error) { +// defer config.DeferPanicToError("generateConfig", func(err error) { +// Log(pb.LogLevel_FATAL, pb.LogType_CONFIG, err.Error()) +// stopAndAlert(pb.MessageType_UNEXPECTED_ERROR, err.Error()) +// }) + +// config, err := generateConfigFromFile(C.GoString(path), *configOptions) +// if err != nil { +// return C.CString("error" + err.Error()) +// } +// return C.CString(config) +// } + +// Implement the Stop method +func (s *server) Stop(ctx context.Context, empty *pb.Empty) (*pb.CoreInfoResponse, error) { + defer config.DeferPanicToError("stop", func(err error) { + Log(pb.LogLevel_FATAL, pb.LogType_CORE, err.Error()) + stopAndAlert(pb.MessageType_UNEXPECTED_ERROR, err.Error()) + }) + config.DeactivateTunnelService() + if CoreState != pb.CoreState_STARTED { + Log(pb.LogLevel_FATAL, pb.LogType_CORE, "Core is not started") + return &pb.CoreInfoResponse{ + CoreState: CoreState, + MessageType: pb.MessageType_INSTANCE_NOT_STARTED, + Message: "instance is not started", + }, fmt.Errorf("instance not started") + } + if Box == nil { + return &pb.CoreInfoResponse{ + CoreState: CoreState, + MessageType: pb.MessageType_INSTANCE_NOT_FOUND, + Message: "instance is not found", + }, fmt.Errorf("instance not found") + } + SetCoreStatus(pb.CoreState_STOPPING, pb.MessageType_EMPTY, "") + // commandServer.SetService(nil) + + err := Box.Close() + if err != nil { + return &pb.CoreInfoResponse{ + CoreState: CoreState, + MessageType: pb.MessageType_UNEXPECTED_ERROR, + Message: "Error while stopping the service.", + }, fmt.Errorf("Error while stopping the service.") + } + Box = nil + // err = commandServer.Close() + // if err != nil { + // return &pb.CoreInfoResponse{ + // CoreState: CoreState, + // MessageType: pb.MessageType_UNEXPECTED_ERROR, + // Message: "Error while Closing the comand server.", + // }, fmt.Errorf("Error while Closing the comand server.") + + // } + // commandServer = nil + resp := SetCoreStatus(pb.CoreState_STOPPED, pb.MessageType_EMPTY, "") + return &resp, nil + +} + +func (s *server) Restart(ctx context.Context, in *pb.StartRequest) (*pb.CoreInfoResponse, error) { + defer config.DeferPanicToError("restart", func(err error) { + Log(pb.LogLevel_FATAL, pb.LogType_CORE, err.Error()) + stopAndAlert(pb.MessageType_UNEXPECTED_ERROR, err.Error()) + }) + log.Debug("[Service] Restarting") + + if CoreState != pb.CoreState_STARTED { + return &pb.CoreInfoResponse{ + CoreState: CoreState, + MessageType: pb.MessageType_INSTANCE_NOT_STARTED, + Message: "instance is not started", + }, fmt.Errorf("instance not started") + } + if Box == nil { + return &pb.CoreInfoResponse{ + CoreState: CoreState, + MessageType: pb.MessageType_INSTANCE_NOT_FOUND, + Message: "instance is not found", + }, fmt.Errorf("instance not found") + } + + resp, err := s.Stop(ctx, &pb.Empty{}) + if err != nil { + return resp, err + } + + SetCoreStatus(pb.CoreState_STARTING, pb.MessageType_EMPTY, "") + <-time.After(250 * time.Millisecond) + + libbox.SetMemoryLimit(!in.DisableMemoryLimit) + resp, gErr := s.StartService(ctx, in) + return resp, gErr +} diff --git a/v2/example_client/main.go b/v2/example_client/main.go new file mode 100644 index 0000000..a3ae9e7 --- /dev/null +++ b/v2/example_client/main.go @@ -0,0 +1,62 @@ +package main + +import ( + "context" + "log" + "time" + + pb "github.com/hiddify/libcore/hiddifyrpc" + + "google.golang.org/grpc" +) + +const ( + address = "localhost:50051" + defaultName = "world" +) + +func main() { + conn, err := grpc.Dial(address, grpc.WithInsecure()) + if err != nil { + log.Fatalf("did not connect: %v", err) + } + defer conn.Close() + c := pb.NewHiddifyClient(conn) + + ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) + defer cancel() + + // SayHello + r, err := c.SayHello(ctx, &pb.HelloRequest{Name: defaultName}) + if err != nil { + log.Fatalf("could not greet: %v", err) + } + log.Printf("Greeting: %s", r.Message) + + // SayHelloStream + stream, err := c.SayHelloStream(ctx) + if err != nil { + log.Fatalf("could not stream: %v", err) + } + + names := []string{"Alice", "Bob", "Charlie"} + + for _, name := range names { + err := stream.Send(&pb.HelloRequest{Name: name}) + if err != nil { + log.Fatalf("could not send: %v", err) + } + r, err := stream.Recv() + if err != nil { + log.Fatalf("could not receive: %v", err) + } + log.Printf("Received1: %s", r.Message) + r2, err2 := stream.Recv() + if err2 != nil { + log.Fatalf("could not receive2: %v", err2) + } + log.Printf("Received: %s", r2.Message) + time.Sleep(1 * time.Second) + } + +} diff --git a/v2/example_server/main.go b/v2/example_server/main.go new file mode 100644 index 0000000..5b16ff9 --- /dev/null +++ b/v2/example_server/main.go @@ -0,0 +1,16 @@ +package main + +import ( + "os" + "os/signal" + "syscall" + + v2 "github.com/hiddify/libcore/v2" +) + +func main() { + v2.StartGrpcServer() + sigChan := make(chan os.Signal, 1) + signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM) + <-sigChan +} diff --git a/v2/grpc_server.go b/v2/grpc_server.go new file mode 100644 index 0000000..109e4b3 --- /dev/null +++ b/v2/grpc_server.go @@ -0,0 +1,34 @@ +package v2 + +import "C" +import ( + "log" + "net" + + pb "github.com/hiddify/libcore/hiddifyrpc" + "google.golang.org/grpc" +) + +const ( + port = ":50051" +) + +type server struct { + pb.UnimplementedHiddifyServer +} + +//export StartGrpcServer +func StartGrpcServer() { + lis, err := net.Listen("tcp", port) + if err != nil { + log.Printf("failed to listen: %v", err) + } + s := grpc.NewServer() + pb.RegisterHiddifyServer(s, &server{}) + log.Printf("Server listening on %s", port) + go func() { + if err := s.Serve(lis); err != nil { + log.Printf("failed to serve: %v", err) + } + }() +} diff --git a/v2/hello.go b/v2/hello.go new file mode 100644 index 0000000..30aad98 --- /dev/null +++ b/v2/hello.go @@ -0,0 +1,36 @@ +package v2 + +import ( + "context" + "log" + "time" + + pb "github.com/hiddify/libcore/hiddifyrpc" +) + +func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloResponse, error) { + return &pb.HelloResponse{Message: "Hello, " + in.Name}, nil +} +func (s *server) SayHelloStream(stream pb.Hiddify_SayHelloStreamServer) error { + + for { + req, err := stream.Recv() + if err != nil { + log.Printf("stream.Recv() failed: %v", err) + break + } + log.Printf("Received: %v", req.Name) + time.Sleep(1 * time.Second) + err = stream.Send(&pb.HelloResponse{Message: "Hello, " + req.Name}) + if err != nil { + log.Printf("stream.Send() failed: %v", err) + break + } + err = stream.Send(&pb.HelloResponse{Message: "Hello again, " + req.Name}) + if err != nil { + log.Printf("stream.Send() failed: %v", err) + break + } + } + return nil +} diff --git a/v2/logproto.go b/v2/logproto.go new file mode 100644 index 0000000..8667940 --- /dev/null +++ b/v2/logproto.go @@ -0,0 +1,41 @@ +package v2 + +import ( + "time" + + pb "github.com/hiddify/libcore/hiddifyrpc" + "github.com/sagernet/sing/common/observable" +) + +var logObserver = observable.Observer[pb.LogMessage]{} + +func Log(level pb.LogLevel, typ pb.LogType, message string) { + logObserver.Emit(pb.LogMessage{ + Level: level, + Type: typ, + Message: message, + }) + +} + +func (s *server) LogListener(stream pb.Hiddify_LogListenerServer) error { + logSub, _, _ := logObserver.Subscribe() + defer logObserver.UnSubscribe(logSub) + + stopch := make(chan int) + go func() { + stream.Recv() + close(stopch) + }() + for { + select { + case <-stream.Context().Done(): + break + case <-stopch: + break + case info := <-logSub: + stream.Send(&info) + case <-time.After(500 * time.Millisecond): + } + } +} diff --git a/v2/service.go b/v2/service.go new file mode 100644 index 0000000..4ec4af3 --- /dev/null +++ b/v2/service.go @@ -0,0 +1,68 @@ +package v2 + +import ( + "context" + "os" + "runtime" + runtimeDebug "runtime/debug" + + B "github.com/sagernet/sing-box" + "github.com/sagernet/sing-box/common/urltest" + "github.com/sagernet/sing-box/experimental/libbox" + "github.com/sagernet/sing-box/option" + E "github.com/sagernet/sing/common/exceptions" + "github.com/sagernet/sing/service" + "github.com/sagernet/sing/service/filemanager" + "github.com/sagernet/sing/service/pause" +) + +var ( + sWorkingPath string + sTempPath string + sUserID int + sGroupID int +) + +func Setup(basePath string, workingPath string, tempPath string) { + tcpConn := runtime.GOOS == "windows" //TODO add TVOS + libbox.Setup(basePath, workingPath, tempPath, tcpConn) + sWorkingPath = workingPath + os.Chdir(sWorkingPath) + sTempPath = tempPath + sUserID = os.Getuid() + sGroupID = os.Getgid() +} + +func NewService(options option.Options) (*libbox.BoxService, error) { + runtimeDebug.FreeOSMemory() + ctx, cancel := context.WithCancel(context.Background()) + ctx = filemanager.WithDefault(ctx, sWorkingPath, sTempPath, sUserID, sGroupID) + urlTestHistoryStorage := urltest.NewHistoryStorage() + ctx = service.ContextWithPtr(ctx, urlTestHistoryStorage) + instance, err := B.New(B.Options{ + Context: ctx, + Options: options, + }) + if err != nil { + cancel() + return nil, E.Cause(err, "create service") + } + runtimeDebug.FreeOSMemory() + service := libbox.NewBoxService( + ctx, + cancel, + instance, + service.FromContext[pause.Manager](ctx), + urlTestHistoryStorage, + ) + return &service, nil +} + +func parseConfig(configContent string) (option.Options, error) { + var options option.Options + err := options.UnmarshalJSON([]byte(configContent)) + if err != nil { + return option.Options{}, E.Cause(err, "decode config") + } + return options, nil +} diff --git a/v2/warp.go b/v2/warp.go new file mode 100644 index 0000000..32c2afb --- /dev/null +++ b/v2/warp.go @@ -0,0 +1,65 @@ +package v2 + +import ( + "context" + + "github.com/hiddify/libcore/config" + pb "github.com/hiddify/libcore/hiddifyrpc" + "github.com/sagernet/sing-box/experimental/libbox" +) + +func (s *server) GenerateWarpConfig(ctx context.Context, in *pb.GenerateWarpConfigRequest) (*pb.WarpGenerationResponse, error) { + account, log, wg, err := config.GenerateWarpInfo(in.LicenseKey, in.AccountId, in.AccessToken) + if err != nil { + return nil, err + } + return &pb.WarpGenerationResponse{ + Account: &pb.WarpAccount{ + AccountId: account.AccountID, + AccessToken: account.AccessToken, + }, + Config: &pb.WarpWireguardConfig{ + PrivateKey: wg.PrivateKey, + LocalAddressIpv4: wg.LocalAddressIPv4, + LocalAddressIpv6: wg.LocalAddressIPv6, + PeerPublicKey: wg.PeerPublicKey, + }, + Log: log, + }, nil +} + +// Implement the GetSystemProxyStatus method +func (s *server) GetSystemProxyStatus(ctx context.Context, empty *pb.Empty) (*pb.SystemProxyStatus, error) { + status, err := libbox.NewStandaloneCommandClient().GetSystemProxyStatus() + + if err != nil { + return nil, err + } + + return &pb.SystemProxyStatus{ + Available: status.Available, + Enabled: status.Enabled, + }, nil +} + +// Implement the SetSystemProxyEnabled method +func (s *server) SetSystemProxyEnabled(ctx context.Context, in *pb.SetSystemProxyEnabledRequest) (*pb.Response, error) { + err := libbox.NewStandaloneCommandClient().SetSystemProxyEnabled(in.IsEnabled) + + if err != nil { + return nil, err + } + + if err != nil { + return &pb.Response{ + ResponseCode: pb.ResponseCode_FAILED, + Message: err.Error(), + }, err + } + + return &pb.Response{ + ResponseCode: pb.ResponseCode_OK, + Message: "", + }, nil + +}