mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2026-01-07 05:39:13 +08:00
refactor and improve windows set DNS
This commit is contained in:
parent
53fe65eac8
commit
0219472799
@ -825,62 +825,10 @@ func (x *CompileGeoSiteToSrsRequest) GetPath() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
type SetSystemProxyRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Enable bool `protobuf:"varint,1,opt,name=enable,proto3" json:"enable,omitempty"`
|
||||
Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *SetSystemProxyRequest) Reset() {
|
||||
*x = SetSystemProxyRequest{}
|
||||
mi := &file_libcore_proto_msgTypes[15]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *SetSystemProxyRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SetSystemProxyRequest) ProtoMessage() {}
|
||||
|
||||
func (x *SetSystemProxyRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_libcore_proto_msgTypes[15]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use SetSystemProxyRequest.ProtoReflect.Descriptor instead.
|
||||
func (*SetSystemProxyRequest) Descriptor() ([]byte, []int) {
|
||||
return file_libcore_proto_rawDescGZIP(), []int{15}
|
||||
}
|
||||
|
||||
func (x *SetSystemProxyRequest) GetEnable() bool {
|
||||
if x != nil {
|
||||
return x.Enable
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *SetSystemProxyRequest) GetAddress() string {
|
||||
if x != nil {
|
||||
return x.Address
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type SetSystemDNSRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Clear bool `protobuf:"varint,1,opt,name=clear,proto3" json:"clear,omitempty"`
|
||||
Servers []string `protobuf:"bytes,2,rep,name=servers,proto3" json:"servers,omitempty"`
|
||||
CustomNs string `protobuf:"bytes,2,opt,name=custom_ns,json=customNs,proto3" json:"custom_ns,omitempty"`
|
||||
SetDhcp bool `protobuf:"varint,3,opt,name=set_dhcp,json=setDhcp,proto3" json:"set_dhcp,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
@ -888,7 +836,7 @@ type SetSystemDNSRequest struct {
|
||||
|
||||
func (x *SetSystemDNSRequest) Reset() {
|
||||
*x = SetSystemDNSRequest{}
|
||||
mi := &file_libcore_proto_msgTypes[16]
|
||||
mi := &file_libcore_proto_msgTypes[15]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -900,7 +848,7 @@ func (x *SetSystemDNSRequest) String() string {
|
||||
func (*SetSystemDNSRequest) ProtoMessage() {}
|
||||
|
||||
func (x *SetSystemDNSRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_libcore_proto_msgTypes[16]
|
||||
mi := &file_libcore_proto_msgTypes[15]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -913,7 +861,7 @@ func (x *SetSystemDNSRequest) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use SetSystemDNSRequest.ProtoReflect.Descriptor instead.
|
||||
func (*SetSystemDNSRequest) Descriptor() ([]byte, []int) {
|
||||
return file_libcore_proto_rawDescGZIP(), []int{16}
|
||||
return file_libcore_proto_rawDescGZIP(), []int{15}
|
||||
}
|
||||
|
||||
func (x *SetSystemDNSRequest) GetClear() bool {
|
||||
@ -923,11 +871,11 @@ func (x *SetSystemDNSRequest) GetClear() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *SetSystemDNSRequest) GetServers() []string {
|
||||
func (x *SetSystemDNSRequest) GetCustomNs() string {
|
||||
if x != nil {
|
||||
return x.Servers
|
||||
return x.CustomNs
|
||||
}
|
||||
return nil
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *SetSystemDNSRequest) GetSetDhcp() bool {
|
||||
@ -937,29 +885,28 @@ func (x *SetSystemDNSRequest) GetSetDhcp() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
type GetSystemDNSResponse struct {
|
||||
type GetDNSDHCPStatusResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Servers []string `protobuf:"bytes,1,rep,name=servers,proto3" json:"servers,omitempty"`
|
||||
IsDhcp bool `protobuf:"varint,2,opt,name=is_dhcp,json=isDhcp,proto3" json:"is_dhcp,omitempty"`
|
||||
IsDhcp bool `protobuf:"varint,1,opt,name=is_dhcp,json=isDhcp,proto3" json:"is_dhcp,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetSystemDNSResponse) Reset() {
|
||||
*x = GetSystemDNSResponse{}
|
||||
mi := &file_libcore_proto_msgTypes[17]
|
||||
func (x *GetDNSDHCPStatusResponse) Reset() {
|
||||
*x = GetDNSDHCPStatusResponse{}
|
||||
mi := &file_libcore_proto_msgTypes[16]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetSystemDNSResponse) String() string {
|
||||
func (x *GetDNSDHCPStatusResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetSystemDNSResponse) ProtoMessage() {}
|
||||
func (*GetDNSDHCPStatusResponse) ProtoMessage() {}
|
||||
|
||||
func (x *GetSystemDNSResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_libcore_proto_msgTypes[17]
|
||||
func (x *GetDNSDHCPStatusResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_libcore_proto_msgTypes[16]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -970,19 +917,12 @@ func (x *GetSystemDNSResponse) ProtoReflect() protoreflect.Message {
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetSystemDNSResponse.ProtoReflect.Descriptor instead.
|
||||
func (*GetSystemDNSResponse) Descriptor() ([]byte, []int) {
|
||||
return file_libcore_proto_rawDescGZIP(), []int{17}
|
||||
// Deprecated: Use GetDNSDHCPStatusResponse.ProtoReflect.Descriptor instead.
|
||||
func (*GetDNSDHCPStatusResponse) Descriptor() ([]byte, []int) {
|
||||
return file_libcore_proto_rawDescGZIP(), []int{16}
|
||||
}
|
||||
|
||||
func (x *GetSystemDNSResponse) GetServers() []string {
|
||||
if x != nil {
|
||||
return x.Servers
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *GetSystemDNSResponse) GetIsDhcp() bool {
|
||||
func (x *GetDNSDHCPStatusResponse) GetIsDhcp() bool {
|
||||
if x != nil {
|
||||
return x.IsDhcp
|
||||
}
|
||||
@ -998,7 +938,7 @@ type IsPrivilegedResponse struct {
|
||||
|
||||
func (x *IsPrivilegedResponse) Reset() {
|
||||
*x = IsPrivilegedResponse{}
|
||||
mi := &file_libcore_proto_msgTypes[18]
|
||||
mi := &file_libcore_proto_msgTypes[17]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@ -1010,7 +950,7 @@ func (x *IsPrivilegedResponse) String() string {
|
||||
func (*IsPrivilegedResponse) ProtoMessage() {}
|
||||
|
||||
func (x *IsPrivilegedResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_libcore_proto_msgTypes[18]
|
||||
mi := &file_libcore_proto_msgTypes[17]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@ -1023,7 +963,7 @@ func (x *IsPrivilegedResponse) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use IsPrivilegedResponse.ProtoReflect.Descriptor instead.
|
||||
func (*IsPrivilegedResponse) Descriptor() ([]byte, []int) {
|
||||
return file_libcore_proto_rawDescGZIP(), []int{18}
|
||||
return file_libcore_proto_rawDescGZIP(), []int{17}
|
||||
}
|
||||
|
||||
func (x *IsPrivilegedResponse) GetHasPrivilege() bool {
|
||||
@ -1125,91 +1065,81 @@ var file_libcore_proto_rawDesc = string([]byte{
|
||||
0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x74, 0x65, 0x6d,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x12, 0x12, 0x0a, 0x04,
|
||||
0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68,
|
||||
0x22, 0x49, 0x0a, 0x15, 0x53, 0x65, 0x74, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x50, 0x72, 0x6f,
|
||||
0x78, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x6e, 0x61,
|
||||
0x62, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x65, 0x6e, 0x61, 0x62, 0x6c,
|
||||
0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x60, 0x0a, 0x13, 0x53,
|
||||
0x65, 0x74, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x44, 0x4e, 0x53, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||
0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x08, 0x52, 0x05, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76,
|
||||
0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x65,
|
||||
0x72, 0x73, 0x12, 0x19, 0x0a, 0x08, 0x73, 0x65, 0x74, 0x5f, 0x64, 0x68, 0x63, 0x70, 0x18, 0x03,
|
||||
0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x65, 0x74, 0x44, 0x68, 0x63, 0x70, 0x22, 0x49, 0x0a,
|
||||
0x14, 0x47, 0x65, 0x74, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x44, 0x4e, 0x53, 0x52, 0x65, 0x73,
|
||||
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73,
|
||||
0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x12,
|
||||
0x17, 0x0a, 0x07, 0x69, 0x73, 0x5f, 0x64, 0x68, 0x63, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08,
|
||||
0x52, 0x06, 0x69, 0x73, 0x44, 0x68, 0x63, 0x70, 0x22, 0x3b, 0x0a, 0x14, 0x49, 0x73, 0x50, 0x72,
|
||||
0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
|
||||
0x12, 0x23, 0x0a, 0x0d, 0x68, 0x61, 0x73, 0x5f, 0x70, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67,
|
||||
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x68, 0x61, 0x73, 0x50, 0x72, 0x69, 0x76,
|
||||
0x69, 0x6c, 0x65, 0x67, 0x65, 0x32, 0xf8, 0x07, 0x0a, 0x0e, 0x4c, 0x69, 0x62, 0x63, 0x6f, 0x72,
|
||||
0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x2d, 0x0a, 0x04, 0x45, 0x78, 0x69, 0x74,
|
||||
0x12, 0x11, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79,
|
||||
0x52, 0x65, 0x71, 0x1a, 0x12, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d,
|
||||
0x70, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x33, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x72, 0x74,
|
||||
0x12, 0x16, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x4c, 0x6f, 0x61, 0x64, 0x43,
|
||||
0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x71, 0x1a, 0x12, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f,
|
||||
0x72, 0x65, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2d, 0x0a, 0x04,
|
||||
0x53, 0x74, 0x6f, 0x70, 0x12, 0x11, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45,
|
||||
0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x12, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72,
|
||||
0x65, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x12, 0x39, 0x0a, 0x0b, 0x43,
|
||||
0x68, 0x65, 0x63, 0x6b, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x16, 0x2e, 0x6c, 0x69, 0x62,
|
||||
0x63, 0x6f, 0x72, 0x65, 0x2e, 0x4c, 0x6f, 0x61, 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52,
|
||||
0x65, 0x71, 0x1a, 0x12, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x72, 0x72,
|
||||
0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2b, 0x0a, 0x04, 0x54, 0x65, 0x73, 0x74, 0x12, 0x10,
|
||||
0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x71,
|
||||
0x1a, 0x11, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52,
|
||||
0x65, 0x73, 0x70, 0x12, 0x31, 0x0a, 0x08, 0x53, 0x74, 0x6f, 0x70, 0x54, 0x65, 0x73, 0x74, 0x12,
|
||||
0x11, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52,
|
||||
0x65, 0x71, 0x1a, 0x12, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70,
|
||||
0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x38, 0x0a, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53,
|
||||
0x74, 0x61, 0x74, 0x73, 0x12, 0x11, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45,
|
||||
0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x17, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72,
|
||||
0x65, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70,
|
||||
0x12, 0x42, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x73, 0x12, 0x11, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d,
|
||||
0x70, 0x74, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x1c, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65,
|
||||
0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73,
|
||||
0x52, 0x65, 0x73, 0x70, 0x12, 0x46, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x47, 0x65, 0x6f, 0x49, 0x50,
|
||||
0x4c, 0x69, 0x73, 0x74, 0x12, 0x17, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x47,
|
||||
0x65, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e,
|
||||
0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x47, 0x65, 0x6f, 0x49, 0x50,
|
||||
0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4a, 0x0a, 0x0e,
|
||||
0x47, 0x65, 0x74, 0x47, 0x65, 0x6f, 0x53, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x17,
|
||||
0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x47, 0x65, 0x6f, 0x4c, 0x69, 0x73, 0x74,
|
||||
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72,
|
||||
0x65, 0x2e, 0x47, 0x65, 0x74, 0x47, 0x65, 0x6f, 0x53, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x73, 0x74,
|
||||
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4a, 0x0a, 0x11, 0x43, 0x6f, 0x6d, 0x70,
|
||||
0x69, 0x6c, 0x65, 0x47, 0x65, 0x6f, 0x49, 0x50, 0x54, 0x6f, 0x53, 0x72, 0x73, 0x12, 0x21, 0x2e,
|
||||
0x22, 0x63, 0x0a, 0x13, 0x53, 0x65, 0x74, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x44, 0x4e, 0x53,
|
||||
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6c, 0x65, 0x61, 0x72,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x12, 0x1b, 0x0a,
|
||||
0x09, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x5f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x08, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x4e, 0x73, 0x12, 0x19, 0x0a, 0x08, 0x73, 0x65,
|
||||
0x74, 0x5f, 0x64, 0x68, 0x63, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x65,
|
||||
0x74, 0x44, 0x68, 0x63, 0x70, 0x22, 0x33, 0x0a, 0x18, 0x47, 0x65, 0x74, 0x44, 0x4e, 0x53, 0x44,
|
||||
0x48, 0x43, 0x50, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
|
||||
0x65, 0x12, 0x17, 0x0a, 0x07, 0x69, 0x73, 0x5f, 0x64, 0x68, 0x63, 0x70, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x08, 0x52, 0x06, 0x69, 0x73, 0x44, 0x68, 0x63, 0x70, 0x22, 0x3b, 0x0a, 0x14, 0x49, 0x73,
|
||||
0x50, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
|
||||
0x73, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x68, 0x61, 0x73, 0x5f, 0x70, 0x72, 0x69, 0x76, 0x69, 0x6c,
|
||||
0x65, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x68, 0x61, 0x73, 0x50, 0x72,
|
||||
0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, 0x65, 0x32, 0xba, 0x07, 0x0a, 0x0e, 0x4c, 0x69, 0x62, 0x63,
|
||||
0x6f, 0x72, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x2d, 0x0a, 0x04, 0x45, 0x78,
|
||||
0x69, 0x74, 0x12, 0x11, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70,
|
||||
0x74, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x12, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e,
|
||||
0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x33, 0x0a, 0x05, 0x53, 0x74, 0x61,
|
||||
0x72, 0x74, 0x12, 0x16, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x4c, 0x6f, 0x61,
|
||||
0x64, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x71, 0x1a, 0x12, 0x2e, 0x6c, 0x69, 0x62,
|
||||
0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2d,
|
||||
0x0a, 0x04, 0x53, 0x74, 0x6f, 0x70, 0x12, 0x11, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65,
|
||||
0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x12, 0x2e, 0x6c, 0x69, 0x62, 0x63,
|
||||
0x6f, 0x72, 0x65, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x12, 0x39, 0x0a,
|
||||
0x0b, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x16, 0x2e, 0x6c,
|
||||
0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x4c, 0x6f, 0x61, 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x69,
|
||||
0x67, 0x52, 0x65, 0x71, 0x1a, 0x12, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45,
|
||||
0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2b, 0x0a, 0x04, 0x54, 0x65, 0x73, 0x74,
|
||||
0x12, 0x10, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52,
|
||||
0x65, 0x71, 0x1a, 0x11, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x54, 0x65, 0x73,
|
||||
0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x31, 0x0a, 0x08, 0x53, 0x74, 0x6f, 0x70, 0x54, 0x65, 0x73,
|
||||
0x74, 0x12, 0x11, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74,
|
||||
0x79, 0x52, 0x65, 0x71, 0x1a, 0x12, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45,
|
||||
0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x38, 0x0a, 0x0a, 0x51, 0x75, 0x65, 0x72,
|
||||
0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x11, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65,
|
||||
0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x17, 0x2e, 0x6c, 0x69, 0x62, 0x63,
|
||||
0x6f, 0x72, 0x65, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65,
|
||||
0x73, 0x70, 0x12, 0x42, 0x0a, 0x0f, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x11, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e,
|
||||
0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x1c, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f,
|
||||
0x72, 0x65, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x12, 0x46, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x47, 0x65, 0x6f,
|
||||
0x49, 0x50, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x17, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65,
|
||||
0x2e, 0x47, 0x65, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
|
||||
0x1d, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x47, 0x65, 0x6f,
|
||||
0x49, 0x50, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4a,
|
||||
0x0a, 0x0e, 0x47, 0x65, 0x74, 0x47, 0x65, 0x6f, 0x53, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x73, 0x74,
|
||||
0x12, 0x17, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x47, 0x65, 0x6f, 0x4c, 0x69,
|
||||
0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x6c, 0x69, 0x62, 0x63,
|
||||
0x6f, 0x72, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x47, 0x65, 0x6f, 0x53, 0x69, 0x74, 0x65, 0x4c, 0x69,
|
||||
0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4a, 0x0a, 0x11, 0x43, 0x6f,
|
||||
0x6d, 0x70, 0x69, 0x6c, 0x65, 0x47, 0x65, 0x6f, 0x49, 0x50, 0x54, 0x6f, 0x53, 0x72, 0x73, 0x12,
|
||||
0x21, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c,
|
||||
0x65, 0x47, 0x65, 0x6f, 0x49, 0x50, 0x54, 0x6f, 0x53, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||
0x73, 0x74, 0x1a, 0x12, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70,
|
||||
0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x4e, 0x0a, 0x13, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c,
|
||||
0x65, 0x47, 0x65, 0x6f, 0x53, 0x69, 0x74, 0x65, 0x54, 0x6f, 0x53, 0x72, 0x73, 0x12, 0x23, 0x2e,
|
||||
0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x47,
|
||||
0x65, 0x6f, 0x49, 0x50, 0x54, 0x6f, 0x53, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
|
||||
0x1a, 0x12, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79,
|
||||
0x52, 0x65, 0x73, 0x70, 0x12, 0x4e, 0x0a, 0x13, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x47,
|
||||
0x65, 0x6f, 0x53, 0x69, 0x74, 0x65, 0x54, 0x6f, 0x53, 0x72, 0x73, 0x12, 0x23, 0x2e, 0x6c, 0x69,
|
||||
0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x47, 0x65, 0x6f,
|
||||
0x53, 0x69, 0x74, 0x65, 0x54, 0x6f, 0x53, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
|
||||
0x1a, 0x12, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79,
|
||||
0x52, 0x65, 0x73, 0x70, 0x12, 0x44, 0x0a, 0x0e, 0x53, 0x65, 0x74, 0x53, 0x79, 0x73, 0x74, 0x65,
|
||||
0x6d, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x1e, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65,
|
||||
0x2e, 0x53, 0x65, 0x74, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x52,
|
||||
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65,
|
||||
0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x40, 0x0a, 0x0c, 0x47, 0x65,
|
||||
0x74, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x44, 0x4e, 0x53, 0x12, 0x11, 0x2e, 0x6c, 0x69, 0x62,
|
||||
0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x1d, 0x2e,
|
||||
0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x79, 0x73, 0x74, 0x65,
|
||||
0x6d, 0x44, 0x4e, 0x53, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x40, 0x0a, 0x0c,
|
||||
0x53, 0x65, 0x74, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x44, 0x4e, 0x53, 0x12, 0x1c, 0x2e, 0x6c,
|
||||
0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x53, 0x65, 0x74, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d,
|
||||
0x44, 0x4e, 0x53, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x6c, 0x69, 0x62,
|
||||
0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x40,
|
||||
0x0a, 0x0c, 0x49, 0x73, 0x50, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, 0x65, 0x64, 0x12, 0x11,
|
||||
0x65, 0x6f, 0x53, 0x69, 0x74, 0x65, 0x54, 0x6f, 0x53, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||
0x73, 0x74, 0x1a, 0x12, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70,
|
||||
0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x48, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x44, 0x4e, 0x53,
|
||||
0x44, 0x48, 0x43, 0x50, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x11, 0x2e, 0x6c, 0x69, 0x62,
|
||||
0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x21, 0x2e,
|
||||
0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x44, 0x4e, 0x53, 0x44, 0x48,
|
||||
0x43, 0x50, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
|
||||
0x12, 0x40, 0x0a, 0x0c, 0x53, 0x65, 0x74, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x44, 0x4e, 0x53,
|
||||
0x12, 0x1c, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x53, 0x65, 0x74, 0x53, 0x79,
|
||||
0x73, 0x74, 0x65, 0x6d, 0x44, 0x4e, 0x53, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12,
|
||||
0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65,
|
||||
0x71, 0x1a, 0x1d, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x49, 0x73, 0x50, 0x72,
|
||||
0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
|
||||
0x42, 0x11, 0x5a, 0x0f, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2f,
|
||||
0x67, 0x65, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x73, 0x70, 0x12, 0x40, 0x0a, 0x0c, 0x49, 0x73, 0x50, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67,
|
||||
0x65, 0x64, 0x12, 0x11, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70,
|
||||
0x74, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x1d, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e,
|
||||
0x49, 0x73, 0x50, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70,
|
||||
0x6f, 0x6e, 0x73, 0x65, 0x42, 0x11, 0x5a, 0x0f, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x73, 0x65, 0x72,
|
||||
0x76, 0x65, 0x72, 0x2f, 0x67, 0x65, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
})
|
||||
|
||||
var (
|
||||
@ -1224,7 +1154,7 @@ func file_libcore_proto_rawDescGZIP() []byte {
|
||||
return file_libcore_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_libcore_proto_msgTypes = make([]protoimpl.MessageInfo, 21)
|
||||
var file_libcore_proto_msgTypes = make([]protoimpl.MessageInfo, 20)
|
||||
var file_libcore_proto_goTypes = []any{
|
||||
(*EmptyReq)(nil), // 0: libcore.EmptyReq
|
||||
(*EmptyResp)(nil), // 1: libcore.EmptyResp
|
||||
@ -1241,17 +1171,16 @@ var file_libcore_proto_goTypes = []any{
|
||||
(*GeoListRequest)(nil), // 12: libcore.GeoListRequest
|
||||
(*CompileGeoIPToSrsRequest)(nil), // 13: libcore.CompileGeoIPToSrsRequest
|
||||
(*CompileGeoSiteToSrsRequest)(nil), // 14: libcore.CompileGeoSiteToSrsRequest
|
||||
(*SetSystemProxyRequest)(nil), // 15: libcore.SetSystemProxyRequest
|
||||
(*SetSystemDNSRequest)(nil), // 16: libcore.SetSystemDNSRequest
|
||||
(*GetSystemDNSResponse)(nil), // 17: libcore.GetSystemDNSResponse
|
||||
(*IsPrivilegedResponse)(nil), // 18: libcore.IsPrivilegedResponse
|
||||
nil, // 19: libcore.QueryStatsResp.UpsEntry
|
||||
nil, // 20: libcore.QueryStatsResp.DownsEntry
|
||||
(*SetSystemDNSRequest)(nil), // 15: libcore.SetSystemDNSRequest
|
||||
(*GetDNSDHCPStatusResponse)(nil), // 16: libcore.GetDNSDHCPStatusResponse
|
||||
(*IsPrivilegedResponse)(nil), // 17: libcore.IsPrivilegedResponse
|
||||
nil, // 18: libcore.QueryStatsResp.UpsEntry
|
||||
nil, // 19: libcore.QueryStatsResp.DownsEntry
|
||||
}
|
||||
var file_libcore_proto_depIdxs = []int32{
|
||||
4, // 0: libcore.TestResp.results:type_name -> libcore.URLTestResp
|
||||
19, // 1: libcore.QueryStatsResp.ups:type_name -> libcore.QueryStatsResp.UpsEntry
|
||||
20, // 2: libcore.QueryStatsResp.downs:type_name -> libcore.QueryStatsResp.DownsEntry
|
||||
18, // 1: libcore.QueryStatsResp.ups:type_name -> libcore.QueryStatsResp.UpsEntry
|
||||
19, // 2: libcore.QueryStatsResp.downs:type_name -> libcore.QueryStatsResp.DownsEntry
|
||||
9, // 3: libcore.ListConnectionsResp.connections:type_name -> libcore.ConnectionMetaData
|
||||
0, // 4: libcore.LibcoreService.Exit:input_type -> libcore.EmptyReq
|
||||
3, // 5: libcore.LibcoreService.Start:input_type -> libcore.LoadConfigReq
|
||||
@ -1265,28 +1194,26 @@ var file_libcore_proto_depIdxs = []int32{
|
||||
12, // 13: libcore.LibcoreService.GetGeoSiteList:input_type -> libcore.GeoListRequest
|
||||
13, // 14: libcore.LibcoreService.CompileGeoIPToSrs:input_type -> libcore.CompileGeoIPToSrsRequest
|
||||
14, // 15: libcore.LibcoreService.CompileGeoSiteToSrs:input_type -> libcore.CompileGeoSiteToSrsRequest
|
||||
15, // 16: libcore.LibcoreService.SetSystemProxy:input_type -> libcore.SetSystemProxyRequest
|
||||
0, // 17: libcore.LibcoreService.GetSystemDNS:input_type -> libcore.EmptyReq
|
||||
16, // 18: libcore.LibcoreService.SetSystemDNS:input_type -> libcore.SetSystemDNSRequest
|
||||
0, // 19: libcore.LibcoreService.IsPrivileged:input_type -> libcore.EmptyReq
|
||||
1, // 20: libcore.LibcoreService.Exit:output_type -> libcore.EmptyResp
|
||||
2, // 21: libcore.LibcoreService.Start:output_type -> libcore.ErrorResp
|
||||
2, // 22: libcore.LibcoreService.Stop:output_type -> libcore.ErrorResp
|
||||
2, // 23: libcore.LibcoreService.CheckConfig:output_type -> libcore.ErrorResp
|
||||
6, // 24: libcore.LibcoreService.Test:output_type -> libcore.TestResp
|
||||
1, // 25: libcore.LibcoreService.StopTest:output_type -> libcore.EmptyResp
|
||||
7, // 26: libcore.LibcoreService.QueryStats:output_type -> libcore.QueryStatsResp
|
||||
8, // 27: libcore.LibcoreService.ListConnections:output_type -> libcore.ListConnectionsResp
|
||||
10, // 28: libcore.LibcoreService.GetGeoIPList:output_type -> libcore.GetGeoIPListResponse
|
||||
11, // 29: libcore.LibcoreService.GetGeoSiteList:output_type -> libcore.GetGeoSiteListResponse
|
||||
1, // 30: libcore.LibcoreService.CompileGeoIPToSrs:output_type -> libcore.EmptyResp
|
||||
1, // 31: libcore.LibcoreService.CompileGeoSiteToSrs:output_type -> libcore.EmptyResp
|
||||
1, // 32: libcore.LibcoreService.SetSystemProxy:output_type -> libcore.EmptyResp
|
||||
17, // 33: libcore.LibcoreService.GetSystemDNS:output_type -> libcore.GetSystemDNSResponse
|
||||
1, // 34: libcore.LibcoreService.SetSystemDNS:output_type -> libcore.EmptyResp
|
||||
18, // 35: libcore.LibcoreService.IsPrivileged:output_type -> libcore.IsPrivilegedResponse
|
||||
20, // [20:36] is the sub-list for method output_type
|
||||
4, // [4:20] is the sub-list for method input_type
|
||||
0, // 16: libcore.LibcoreService.GetDNSDHCPStatus:input_type -> libcore.EmptyReq
|
||||
15, // 17: libcore.LibcoreService.SetSystemDNS:input_type -> libcore.SetSystemDNSRequest
|
||||
0, // 18: libcore.LibcoreService.IsPrivileged:input_type -> libcore.EmptyReq
|
||||
1, // 19: libcore.LibcoreService.Exit:output_type -> libcore.EmptyResp
|
||||
2, // 20: libcore.LibcoreService.Start:output_type -> libcore.ErrorResp
|
||||
2, // 21: libcore.LibcoreService.Stop:output_type -> libcore.ErrorResp
|
||||
2, // 22: libcore.LibcoreService.CheckConfig:output_type -> libcore.ErrorResp
|
||||
6, // 23: libcore.LibcoreService.Test:output_type -> libcore.TestResp
|
||||
1, // 24: libcore.LibcoreService.StopTest:output_type -> libcore.EmptyResp
|
||||
7, // 25: libcore.LibcoreService.QueryStats:output_type -> libcore.QueryStatsResp
|
||||
8, // 26: libcore.LibcoreService.ListConnections:output_type -> libcore.ListConnectionsResp
|
||||
10, // 27: libcore.LibcoreService.GetGeoIPList:output_type -> libcore.GetGeoIPListResponse
|
||||
11, // 28: libcore.LibcoreService.GetGeoSiteList:output_type -> libcore.GetGeoSiteListResponse
|
||||
1, // 29: libcore.LibcoreService.CompileGeoIPToSrs:output_type -> libcore.EmptyResp
|
||||
1, // 30: libcore.LibcoreService.CompileGeoSiteToSrs:output_type -> libcore.EmptyResp
|
||||
16, // 31: libcore.LibcoreService.GetDNSDHCPStatus:output_type -> libcore.GetDNSDHCPStatusResponse
|
||||
1, // 32: libcore.LibcoreService.SetSystemDNS:output_type -> libcore.EmptyResp
|
||||
17, // 33: libcore.LibcoreService.IsPrivileged:output_type -> libcore.IsPrivilegedResponse
|
||||
19, // [19:34] is the sub-list for method output_type
|
||||
4, // [4:19] is the sub-list for method input_type
|
||||
4, // [4:4] is the sub-list for extension type_name
|
||||
4, // [4:4] is the sub-list for extension extendee
|
||||
0, // [0:4] is the sub-list for field type_name
|
||||
@ -1303,7 +1230,7 @@ func file_libcore_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_libcore_proto_rawDesc), len(file_libcore_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 21,
|
||||
NumMessages: 20,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
|
||||
@ -19,9 +19,7 @@ service LibcoreService {
|
||||
rpc CompileGeoIPToSrs(CompileGeoIPToSrsRequest) returns (EmptyResp);
|
||||
rpc CompileGeoSiteToSrs(CompileGeoSiteToSrsRequest) returns (EmptyResp);
|
||||
//
|
||||
rpc SetSystemProxy(SetSystemProxyRequest) returns (EmptyResp);
|
||||
//
|
||||
rpc GetSystemDNS(EmptyReq) returns (GetSystemDNSResponse);
|
||||
rpc GetDNSDHCPStatus(EmptyReq) returns (GetDNSDHCPStatusResponse);
|
||||
rpc SetSystemDNS(SetSystemDNSRequest) returns (EmptyResp);
|
||||
//
|
||||
rpc IsPrivileged(EmptyReq) returns (IsPrivilegedResponse);
|
||||
@ -103,20 +101,14 @@ message CompileGeoSiteToSrsRequest {
|
||||
string path = 2;
|
||||
}
|
||||
|
||||
message SetSystemProxyRequest {
|
||||
bool enable = 1;
|
||||
string address = 2;
|
||||
}
|
||||
|
||||
message SetSystemDNSRequest {
|
||||
bool clear = 1;
|
||||
repeated string servers = 2;
|
||||
string custom_ns = 2;
|
||||
bool set_dhcp = 3;
|
||||
}
|
||||
|
||||
message GetSystemDNSResponse {
|
||||
repeated string servers = 1;
|
||||
bool is_dhcp = 2;
|
||||
message GetDNSDHCPStatusResponse {
|
||||
bool is_dhcp = 1;
|
||||
}
|
||||
|
||||
message IsPrivilegedResponse {
|
||||
|
||||
@ -31,8 +31,7 @@ const (
|
||||
LibcoreService_GetGeoSiteList_FullMethodName = "/libcore.LibcoreService/GetGeoSiteList"
|
||||
LibcoreService_CompileGeoIPToSrs_FullMethodName = "/libcore.LibcoreService/CompileGeoIPToSrs"
|
||||
LibcoreService_CompileGeoSiteToSrs_FullMethodName = "/libcore.LibcoreService/CompileGeoSiteToSrs"
|
||||
LibcoreService_SetSystemProxy_FullMethodName = "/libcore.LibcoreService/SetSystemProxy"
|
||||
LibcoreService_GetSystemDNS_FullMethodName = "/libcore.LibcoreService/GetSystemDNS"
|
||||
LibcoreService_GetDNSDHCPStatus_FullMethodName = "/libcore.LibcoreService/GetDNSDHCPStatus"
|
||||
LibcoreService_SetSystemDNS_FullMethodName = "/libcore.LibcoreService/SetSystemDNS"
|
||||
LibcoreService_IsPrivileged_FullMethodName = "/libcore.LibcoreService/IsPrivileged"
|
||||
)
|
||||
@ -53,8 +52,7 @@ type LibcoreServiceClient interface {
|
||||
GetGeoSiteList(ctx context.Context, in *GeoListRequest, opts ...grpc.CallOption) (*GetGeoSiteListResponse, error)
|
||||
CompileGeoIPToSrs(ctx context.Context, in *CompileGeoIPToSrsRequest, opts ...grpc.CallOption) (*EmptyResp, error)
|
||||
CompileGeoSiteToSrs(ctx context.Context, in *CompileGeoSiteToSrsRequest, opts ...grpc.CallOption) (*EmptyResp, error)
|
||||
SetSystemProxy(ctx context.Context, in *SetSystemProxyRequest, opts ...grpc.CallOption) (*EmptyResp, error)
|
||||
GetSystemDNS(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*GetSystemDNSResponse, error)
|
||||
GetDNSDHCPStatus(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*GetDNSDHCPStatusResponse, error)
|
||||
SetSystemDNS(ctx context.Context, in *SetSystemDNSRequest, opts ...grpc.CallOption) (*EmptyResp, error)
|
||||
IsPrivileged(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*IsPrivilegedResponse, error)
|
||||
}
|
||||
@ -187,20 +185,10 @@ func (c *libcoreServiceClient) CompileGeoSiteToSrs(ctx context.Context, in *Comp
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *libcoreServiceClient) SetSystemProxy(ctx context.Context, in *SetSystemProxyRequest, opts ...grpc.CallOption) (*EmptyResp, error) {
|
||||
func (c *libcoreServiceClient) GetDNSDHCPStatus(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*GetDNSDHCPStatusResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(EmptyResp)
|
||||
err := c.cc.Invoke(ctx, LibcoreService_SetSystemProxy_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *libcoreServiceClient) GetSystemDNS(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*GetSystemDNSResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(GetSystemDNSResponse)
|
||||
err := c.cc.Invoke(ctx, LibcoreService_GetSystemDNS_FullMethodName, in, out, cOpts...)
|
||||
out := new(GetDNSDHCPStatusResponse)
|
||||
err := c.cc.Invoke(ctx, LibcoreService_GetDNSDHCPStatus_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -243,8 +231,7 @@ type LibcoreServiceServer interface {
|
||||
GetGeoSiteList(context.Context, *GeoListRequest) (*GetGeoSiteListResponse, error)
|
||||
CompileGeoIPToSrs(context.Context, *CompileGeoIPToSrsRequest) (*EmptyResp, error)
|
||||
CompileGeoSiteToSrs(context.Context, *CompileGeoSiteToSrsRequest) (*EmptyResp, error)
|
||||
SetSystemProxy(context.Context, *SetSystemProxyRequest) (*EmptyResp, error)
|
||||
GetSystemDNS(context.Context, *EmptyReq) (*GetSystemDNSResponse, error)
|
||||
GetDNSDHCPStatus(context.Context, *EmptyReq) (*GetDNSDHCPStatusResponse, error)
|
||||
SetSystemDNS(context.Context, *SetSystemDNSRequest) (*EmptyResp, error)
|
||||
IsPrivileged(context.Context, *EmptyReq) (*IsPrivilegedResponse, error)
|
||||
mustEmbedUnimplementedLibcoreServiceServer()
|
||||
@ -293,11 +280,8 @@ func (UnimplementedLibcoreServiceServer) CompileGeoIPToSrs(context.Context, *Com
|
||||
func (UnimplementedLibcoreServiceServer) CompileGeoSiteToSrs(context.Context, *CompileGeoSiteToSrsRequest) (*EmptyResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CompileGeoSiteToSrs not implemented")
|
||||
}
|
||||
func (UnimplementedLibcoreServiceServer) SetSystemProxy(context.Context, *SetSystemProxyRequest) (*EmptyResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method SetSystemProxy not implemented")
|
||||
}
|
||||
func (UnimplementedLibcoreServiceServer) GetSystemDNS(context.Context, *EmptyReq) (*GetSystemDNSResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetSystemDNS not implemented")
|
||||
func (UnimplementedLibcoreServiceServer) GetDNSDHCPStatus(context.Context, *EmptyReq) (*GetDNSDHCPStatusResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetDNSDHCPStatus not implemented")
|
||||
}
|
||||
func (UnimplementedLibcoreServiceServer) SetSystemDNS(context.Context, *SetSystemDNSRequest) (*EmptyResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method SetSystemDNS not implemented")
|
||||
@ -542,38 +526,20 @@ func _LibcoreService_CompileGeoSiteToSrs_Handler(srv interface{}, ctx context.Co
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _LibcoreService_SetSystemProxy_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(SetSystemProxyRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(LibcoreServiceServer).SetSystemProxy(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: LibcoreService_SetSystemProxy_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(LibcoreServiceServer).SetSystemProxy(ctx, req.(*SetSystemProxyRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _LibcoreService_GetSystemDNS_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
func _LibcoreService_GetDNSDHCPStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(EmptyReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(LibcoreServiceServer).GetSystemDNS(ctx, in)
|
||||
return srv.(LibcoreServiceServer).GetDNSDHCPStatus(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: LibcoreService_GetSystemDNS_FullMethodName,
|
||||
FullMethod: LibcoreService_GetDNSDHCPStatus_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(LibcoreServiceServer).GetSystemDNS(ctx, req.(*EmptyReq))
|
||||
return srv.(LibcoreServiceServer).GetDNSDHCPStatus(ctx, req.(*EmptyReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
@ -670,12 +636,8 @@ var LibcoreService_ServiceDesc = grpc.ServiceDesc{
|
||||
Handler: _LibcoreService_CompileGeoSiteToSrs_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "SetSystemProxy",
|
||||
Handler: _LibcoreService_SetSystemProxy_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetSystemDNS",
|
||||
Handler: _LibcoreService_GetSystemDNS_Handler,
|
||||
MethodName: "GetDNSDHCPStatus",
|
||||
Handler: _LibcoreService_GetDNSDHCPStatus_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "SetSystemDNS",
|
||||
|
||||
@ -2,6 +2,7 @@ package boxdns
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/sagernet/sing/common"
|
||||
"github.com/sagernet/sing/common/control"
|
||||
E "github.com/sagernet/sing/common/exceptions"
|
||||
"golang.org/x/sys/windows"
|
||||
@ -13,11 +14,10 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
dhcpNameServerRegistryKey = "DhcpNameServer"
|
||||
nameServerRegistryKey = "NameServer"
|
||||
nameServerRegistryKey = "NameServer"
|
||||
)
|
||||
|
||||
var customDNS []netip.Addr
|
||||
var customns netip.Addr
|
||||
var dnsIsSet bool
|
||||
|
||||
func (d *DnsManager) HandleSystemDNS(ifc *control.Interface, flag int) {
|
||||
@ -31,7 +31,7 @@ func (d *DnsManager) HandleSystemDNS(ifc *control.Interface, flag int) {
|
||||
if !dnsIsSet {
|
||||
return
|
||||
}
|
||||
_ = d.SetDefaultDNS(customDNS, false, false)
|
||||
_ = d.SetDefaultDNS(customns, false, false)
|
||||
}
|
||||
|
||||
func (d *DnsManager) getDefaultInterfaceGuid() (string, error) {
|
||||
@ -71,46 +71,45 @@ func (d *DnsManager) getDefaultInterfaceLUID() (winipcfg.LUID, error) {
|
||||
return luid, nil
|
||||
}
|
||||
|
||||
func (d *DnsManager) GetDefaultDNS() (servers []netip.Addr, dhcp bool, err error) {
|
||||
func (d *DnsManager) getNewNameservers(current []netip.Addr, customNS netip.Addr, clear bool) []netip.Addr {
|
||||
res := common.Filter(current, func(addr netip.Addr) bool {
|
||||
return addr.String() != customNS.String() && addr.Is4()
|
||||
})
|
||||
if clear {
|
||||
return res
|
||||
}
|
||||
|
||||
res = append([]netip.Addr{customNS}, res...)
|
||||
return res
|
||||
}
|
||||
|
||||
func (d *DnsManager) DefaultIfcIsDHCP() (dhcp bool, err error) {
|
||||
if d == nil {
|
||||
fmt.Println("No DnsManager, you may need to restart nekoray")
|
||||
return nil, false, E.New("No Dns Manager, you may need to restart nekoray")
|
||||
return false, E.New("No Dns Manager, you may need to restart nekoray")
|
||||
}
|
||||
guidStr, err := d.getDefaultInterfaceGuid()
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
return false, err
|
||||
}
|
||||
|
||||
key, err := registry.OpenKey(registry.LOCAL_MACHINE, `SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\`+guidStr, registry.QUERY_VALUE)
|
||||
if err != nil {
|
||||
log.Println("getNameServersForInterface OpenKey:", err)
|
||||
return nil, false, err
|
||||
return false, err
|
||||
}
|
||||
defer key.Close()
|
||||
|
||||
if dhcpServers, _, err := key.GetStringValue(dhcpNameServerRegistryKey); err == nil {
|
||||
if dhcpServers, _, err := key.GetStringValue(nameServerRegistryKey); err == nil {
|
||||
if len(strings.TrimSpace(dhcpServers)) > 0 {
|
||||
return nil, true, nil
|
||||
return false, nil
|
||||
}
|
||||
}
|
||||
|
||||
nameServersRaw, _, err := key.GetStringValue(nameServerRegistryKey)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
resp := make([]netip.Addr, 0)
|
||||
nameServers := strings.Split(strings.ReplaceAll(nameServersRaw, ",", " "), " ")
|
||||
for _, server := range nameServers {
|
||||
if server != "" {
|
||||
addr, _ := netip.ParseAddr(server)
|
||||
resp = append(resp, addr)
|
||||
}
|
||||
}
|
||||
|
||||
return resp, false, nil
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (d *DnsManager) SetDefaultDNS(servers []netip.Addr, dhcp bool, clear bool) error {
|
||||
func (d *DnsManager) SetDefaultDNS(customNS netip.Addr, dhcp bool, clear bool) error {
|
||||
if d == nil {
|
||||
fmt.Println("No DnsManager, you may need to restart nekoray")
|
||||
return E.New("No dns Manager, you may need to restart nekoray")
|
||||
@ -118,7 +117,7 @@ func (d *DnsManager) SetDefaultDNS(servers []netip.Addr, dhcp bool, clear bool)
|
||||
if clear {
|
||||
dnsIsSet = false
|
||||
} else {
|
||||
customDNS = servers
|
||||
customns = customNS
|
||||
dnsIsSet = true
|
||||
if ifc := d.Monitor.DefaultInterface(); ifc != nil {
|
||||
d.lastIfc = *ifc
|
||||
@ -138,14 +137,13 @@ func (d *DnsManager) SetDefaultDNS(servers []netip.Addr, dhcp bool, clear bool)
|
||||
return nil
|
||||
}
|
||||
|
||||
hasV4 := false
|
||||
for _, server := range servers {
|
||||
if server.Is4() {
|
||||
hasV4 = true
|
||||
}
|
||||
servers, err := luid.DNS()
|
||||
if err != nil {
|
||||
return E.New("Failed to get DNS servers", err)
|
||||
}
|
||||
servers = d.getNewNameservers(servers, customNS, clear)
|
||||
|
||||
if hasV4 {
|
||||
if len(servers) > 0 {
|
||||
err = luid.SetDNS(winipcfg.AddressFamily(windows.AF_INET), servers, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@ -3,16 +3,13 @@ package boxdns
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
tun "github.com/sagernet/sing-tun"
|
||||
"github.com/sagernet/sing/common/control"
|
||||
logger2 "github.com/sagernet/sing/common/logger"
|
||||
"log"
|
||||
"nekobox_core/internal/boxdns/winipcfg"
|
||||
"strings"
|
||||
|
||||
tun "github.com/sagernet/sing-tun"
|
||||
|
||||
"github.com/gofrs/uuid/v5"
|
||||
"golang.org/x/sys/windows/registry"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -40,8 +37,6 @@ func init() {
|
||||
fmt.Println("Could not start monitor")
|
||||
return
|
||||
}
|
||||
|
||||
//DnsManagerInstance.HandleUnderlyingDNS(monitor.DefaultInterface(), 0)
|
||||
}
|
||||
|
||||
var DnsManagerInstance *DnsManager
|
||||
@ -60,51 +55,35 @@ func (d *DnsManager) HandleUnderlyingDNS(ifc *control.Interface, flag int) {
|
||||
log.Println("Default interface is nil!")
|
||||
return
|
||||
}
|
||||
index := ifc.Index
|
||||
u, err := ifcIdxtoUUID(index)
|
||||
luid, err := winipcfg.LUIDFromIndex(uint32(ifc.Index))
|
||||
if err != nil {
|
||||
log.Println("Failed to get uuid for interface")
|
||||
return
|
||||
}
|
||||
guidStr := "{" + u.String() + "}"
|
||||
dns := getFirstDNS(guidStr)
|
||||
if len(customDNS) > 0 && dns == customDNS[0].String() {
|
||||
log.Println("Interface DNS is the same as Hijack dns, You may need to fix it manually!")
|
||||
log.Println("Could not get LUID from index")
|
||||
return
|
||||
}
|
||||
dns := getFirstDNS(luid)
|
||||
if dns != "" && dns != underlyingDNS {
|
||||
underlyingDNS = dns
|
||||
log.Println("underlyingDNS:", guidStr, underlyingDNS)
|
||||
log.Println("underlyingDNS:", underlyingDNS)
|
||||
}
|
||||
}
|
||||
|
||||
func getFirstDNS(guid string) string {
|
||||
dns, err := getNameServersForInterface(guid)
|
||||
func getFirstDNS(luid winipcfg.LUID) string {
|
||||
dns, err := getNameServersForInterface(luid)
|
||||
if err != nil || len(dns) == 0 {
|
||||
return ""
|
||||
}
|
||||
return dns[0]
|
||||
}
|
||||
|
||||
func getNameServersForInterface(guid string) ([]string, error) {
|
||||
key, err := registry.OpenKey(registry.LOCAL_MACHINE, `SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\`+guid, registry.QUERY_VALUE)
|
||||
func getNameServersForInterface(luid winipcfg.LUID) ([]string, error) {
|
||||
nameservers := make([]string, 0, 4)
|
||||
nsAddrs, err := luid.DNS()
|
||||
if err != nil {
|
||||
log.Println("getNameServersForInterface OpenKey:", err)
|
||||
return nil, err
|
||||
}
|
||||
defer key.Close()
|
||||
|
||||
nameservers := make([]string, 0, 4)
|
||||
for _, name := range []string{`NameServer`, `DhcpNameServer`} {
|
||||
s, _, err := key.GetStringValue(name)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
s = strings.ReplaceAll(s, ",", " ")
|
||||
for _, server := range strings.Split(s, " ") {
|
||||
if server != "" && server != "127.0.0.1" {
|
||||
nameservers = append(nameservers, server)
|
||||
}
|
||||
for _, server := range nsAddrs {
|
||||
if server.IsValid() && server.String() != customns.String() {
|
||||
nameservers = append(nameservers, server.String())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -300,29 +300,6 @@ func (s *server) CompileGeoSiteToSrs(ctx context.Context, in *gen.CompileGeoSite
|
||||
return &gen.EmptyResp{}, nil
|
||||
}
|
||||
|
||||
func (s *server) SetSystemProxy(ctx context.Context, in *gen.SetSystemProxyRequest) (*gen.EmptyResp, error) {
|
||||
var err error
|
||||
addr := metadata.ParseSocksaddr(in.Address)
|
||||
if systemProxyController == nil || systemProxyAddr.String() != addr.String() {
|
||||
systemProxyController, err = settings.NewSystemProxy(context.Background(), addr, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
systemProxyAddr = addr
|
||||
}
|
||||
if in.Enable && !systemProxyController.IsEnabled() {
|
||||
err = systemProxyController.Enable()
|
||||
}
|
||||
if !in.Enable && systemProxyController.IsEnabled() {
|
||||
err = systemProxyController.Disable()
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &gen.EmptyResp{}, nil
|
||||
}
|
||||
|
||||
func (s *server) IsPrivileged(ctx context.Context, _ *gen.EmptyReq) (*gen.IsPrivilegedResponse, error) {
|
||||
if runtime.GOOS == "windows" {
|
||||
return &gen.IsPrivilegedResponse{
|
||||
|
||||
@ -7,33 +7,23 @@ import (
|
||||
"net/netip"
|
||||
)
|
||||
|
||||
func (s *server) GetSystemDNS(ctx context.Context, in *gen.EmptyReq) (*gen.GetSystemDNSResponse, error) {
|
||||
servers, dhcp, err := boxdns.DnsManagerInstance.GetDefaultDNS()
|
||||
func (s *server) GetDNSDHCPStatus(ctx context.Context, in *gen.EmptyReq) (*gen.GetDNSDHCPStatusResponse, error) {
|
||||
dhcp, err := boxdns.DnsManagerInstance.DefaultIfcIsDHCP()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
stringServers := make([]string, 0)
|
||||
for _, server := range servers {
|
||||
stringServers = append(stringServers, server.String())
|
||||
}
|
||||
|
||||
return &gen.GetSystemDNSResponse{
|
||||
Servers: stringServers,
|
||||
IsDhcp: dhcp,
|
||||
return &gen.GetDNSDHCPStatusResponse{
|
||||
IsDhcp: dhcp,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *server) SetSystemDNS(ctx context.Context, in *gen.SetSystemDNSRequest) (*gen.EmptyResp, error) {
|
||||
var servers []netip.Addr
|
||||
for _, server := range in.Servers {
|
||||
s, err := netip.ParseAddr(server)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
servers = append(servers, s)
|
||||
customNS, err := netip.ParseAddr(in.CustomNs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err := boxdns.DnsManagerInstance.SetDefaultDNS(servers, in.SetDhcp, in.Clear)
|
||||
err = boxdns.DnsManagerInstance.SetDefaultDNS(customNS, in.SetDhcp, in.Clear)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -32,11 +32,9 @@ namespace NekoGui_rpc {
|
||||
|
||||
QString CompileGeoSet(bool *rpcOK, GeoRuleSetType mode, std::string category, const QString& basePath);
|
||||
|
||||
QString SetSystemProxy(bool *rpcOK, bool enable);
|
||||
bool GetDNSDHCPStatus(bool *rpcOK) const;
|
||||
|
||||
libcore::GetSystemDNSResponse GetSystemDNS(bool *rpcOK) const;
|
||||
|
||||
QString SetSystemDNS(bool *rpcOK, const QStringList& servers, bool dhcp, bool clear) const;
|
||||
QString SetSystemDNS(bool *rpcOK, const QString& customNS, bool dhcp, bool clear) const;
|
||||
|
||||
libcore::ListConnectionsResp ListConnections(bool *rpcOK) const;
|
||||
|
||||
|
||||
@ -29,6 +29,7 @@ namespace NekoGui_ConfigItem {
|
||||
// 可格式化对象
|
||||
class JsonStore {
|
||||
public:
|
||||
virtual ~JsonStore() = default;
|
||||
QMap<QString, std::shared_ptr<configItem>> _map;
|
||||
|
||||
std::function<void()> callback_after_load = nullptr;
|
||||
|
||||
@ -144,7 +144,6 @@ namespace NekoGui {
|
||||
// System dns
|
||||
bool system_dns_set = false;
|
||||
bool is_dhcp = false;
|
||||
QStringList system_dns_servers = {};
|
||||
|
||||
// Hotkey
|
||||
QString hotkey_mainwindow = "";
|
||||
|
||||
@ -229,7 +229,7 @@ private:
|
||||
|
||||
static void stop_core_daemon();
|
||||
|
||||
bool set_system_dns(bool set, bool save_set = true);
|
||||
bool set_system_dns(bool set, const QString& customServer, bool save_set = true);
|
||||
|
||||
void CheckUpdate();
|
||||
|
||||
|
||||
@ -522,7 +522,7 @@
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@ -342,43 +342,25 @@ namespace NekoGui_rpc {
|
||||
return "";
|
||||
}
|
||||
|
||||
QString Client::SetSystemProxy(bool *rpcOK, bool enable) {
|
||||
libcore::SetSystemProxyRequest req;
|
||||
libcore::EmptyResp resp;
|
||||
req.set_enable(enable);
|
||||
req.set_address(QString("127.0.0.1:" + Int2String(NekoGui::dataStore->inbound_socks_port)).toStdString());
|
||||
|
||||
auto status = default_grpc_channel->Call("SetSystemProxy", req, &resp);
|
||||
if (status == QNetworkReply::NoError) {
|
||||
*rpcOK = true;
|
||||
return "";
|
||||
} else {
|
||||
NOT_OK
|
||||
return qt_error_string(status);
|
||||
}
|
||||
}
|
||||
|
||||
libcore::GetSystemDNSResponse Client::GetSystemDNS(bool *rpcOK) const {
|
||||
bool Client::GetDNSDHCPStatus(bool *rpcOK) const {
|
||||
libcore::EmptyReq req;
|
||||
libcore::GetSystemDNSResponse resp;
|
||||
libcore::GetDNSDHCPStatusResponse resp;
|
||||
|
||||
auto status = default_grpc_channel->Call("GetSystemDNS", req, &resp);
|
||||
auto status = default_grpc_channel->Call("GetDNSDHCPStatus", req, &resp);
|
||||
if (status == QNetworkReply::NoError) {
|
||||
*rpcOK = true;
|
||||
return resp;
|
||||
return resp.is_dhcp();
|
||||
} else {
|
||||
NOT_OK
|
||||
return {};
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QString Client::SetSystemDNS(bool *rpcOK, const QStringList& servers, const bool dhcp, const bool clear) const {
|
||||
QString Client::SetSystemDNS(bool *rpcOK, const QString& customNS, const bool dhcp, const bool clear) const {
|
||||
libcore::SetSystemDNSRequest req;
|
||||
libcore::EmptyResp resp;
|
||||
|
||||
for (const auto& server : servers) {
|
||||
req.add_servers(server.toStdString());
|
||||
}
|
||||
req.set_custom_ns(customNS.toStdString());
|
||||
req.set_set_dhcp(dhcp);
|
||||
req.set_clear(clear);
|
||||
|
||||
|
||||
@ -304,7 +304,6 @@ namespace NekoGui {
|
||||
_add(new configItem("redirect_listen_port", &redirect_listen_port, itemType::integer));
|
||||
_add(new configItem("system_dns_set", &system_dns_set, itemType::boolean));
|
||||
_add(new configItem("is_dhcp", &is_dhcp, itemType::boolean));
|
||||
_add(new configItem("system_dns_servers", &system_dns_servers, itemType::stringList));
|
||||
_add(new configItem("windows_set_admin", &windows_set_admin, itemType::boolean));
|
||||
_add(new configItem("enable_stats", &enable_stats, itemType::boolean));
|
||||
_add(new configItem("stats_tab", &stats_tab, itemType::string));
|
||||
|
||||
@ -405,7 +405,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
||||
});
|
||||
connect(ui->menu_qr, &QAction::triggered, this, [=]() { display_qr_link(false); });
|
||||
connect(ui->system_dns, &QCheckBox::clicked, this, [=](bool checked) {
|
||||
if (const auto ok = set_system_dns(checked); !ok) {
|
||||
if (const auto ok = set_system_dns(checked, NekoGui::dataStore->dns_server_listen_addr); !ok) {
|
||||
ui->system_dns->setChecked(!checked);
|
||||
} else {
|
||||
refresh_status();
|
||||
@ -608,6 +608,15 @@ void MainWindow::dialog_message_impl(const QString &sender, const QString &info)
|
||||
}
|
||||
refresh_status();
|
||||
}
|
||||
if (info.contains("DNSServerChanged"))
|
||||
{
|
||||
if (NekoGui::dataStore->system_dns_set)
|
||||
{
|
||||
auto oldAddr = info.split(",")[1];
|
||||
set_system_dns(false, oldAddr);
|
||||
set_system_dns(true, NekoGui::dataStore->dns_server_listen_addr);
|
||||
}
|
||||
}
|
||||
if (info.contains("NeedRestart")) {
|
||||
auto n = QMessageBox::warning(GetMessageBoxParent(), tr("Settings changed"), tr("Restart the program to take effect."), QMessageBox::Yes | QMessageBox::No);
|
||||
if (n == QMessageBox::Yes) {
|
||||
@ -671,7 +680,7 @@ void MainWindow::dialog_message_impl(const QString &sender, const QString &info)
|
||||
neko_set_spmode_vpn(true, false);
|
||||
}
|
||||
if (NekoGui::dataStore->flag_dns_set) {
|
||||
set_system_dns(true);
|
||||
set_system_dns(true, NekoGui::dataStore->dns_server_listen_addr);
|
||||
}
|
||||
}
|
||||
if (auto id = info.split(",")[1].toInt(); id >= 0)
|
||||
@ -679,7 +688,7 @@ void MainWindow::dialog_message_impl(const QString &sender, const QString &info)
|
||||
neko_start(id);
|
||||
}
|
||||
if (NekoGui::dataStore->system_dns_set) {
|
||||
set_system_dns(true);
|
||||
set_system_dns(true, NekoGui::dataStore->dns_server_listen_addr);
|
||||
ui->system_dns->setChecked(true);
|
||||
}
|
||||
}
|
||||
@ -722,7 +731,7 @@ void MainWindow::on_menu_hotkey_settings_triggered() {
|
||||
|
||||
void MainWindow::on_commitDataRequest() {
|
||||
qDebug() << "Handling DNS setting";
|
||||
if (NekoGui::dataStore->system_dns_set) set_system_dns(false, false);
|
||||
if (NekoGui::dataStore->system_dns_set) set_system_dns(false, NekoGui::dataStore->dns_server_listen_addr, false);
|
||||
qDebug() << "Done handling DNS setting";
|
||||
qDebug() << "Start of data save";
|
||||
//
|
||||
|
||||
@ -174,7 +174,7 @@ void MainWindow::stop_core_daemon() {
|
||||
NekoGui_rpc::defaultClient->Exit();
|
||||
}
|
||||
|
||||
bool MainWindow::set_system_dns(bool set, bool save_set) {
|
||||
bool MainWindow::set_system_dns(bool set, const QString& customServer, bool save_set) {
|
||||
if (!NekoGui::dataStore->enable_dns_server) {
|
||||
MW_show_log(tr("You need to enable hijack DNS server first"));
|
||||
return false;
|
||||
@ -183,28 +183,18 @@ bool MainWindow::set_system_dns(bool set, bool save_set) {
|
||||
return false;
|
||||
}
|
||||
bool rpcOK;
|
||||
QStringList servers;
|
||||
bool is_dhcp = false;
|
||||
QString res;
|
||||
if (set) {
|
||||
bool ok;
|
||||
auto sysDefaults = defaultClient->GetSystemDNS(&ok);
|
||||
auto isDHCP = defaultClient->GetDNSDHCPStatus(&ok);
|
||||
if (!ok) {
|
||||
MW_show_log(tr("Failed to get system dns settings"));
|
||||
return false;
|
||||
}
|
||||
QStringList sysDefServers;
|
||||
for (const auto& server : sysDefaults.servers()) {
|
||||
sysDefServers.append(server.c_str());
|
||||
}
|
||||
NekoGui::dataStore->system_dns_servers = sysDefServers;
|
||||
NekoGui::dataStore->is_dhcp = sysDefaults.is_dhcp();
|
||||
servers = {NekoGui::dataStore->dns_server_listen_addr};
|
||||
res = defaultClient->SetSystemDNS(&rpcOK, servers, is_dhcp, false);
|
||||
NekoGui::dataStore->is_dhcp = isDHCP;
|
||||
res = defaultClient->SetSystemDNS(&rpcOK, customServer, false, false);
|
||||
} else {
|
||||
servers = NekoGui::dataStore->system_dns_servers;
|
||||
is_dhcp = NekoGui::dataStore->is_dhcp;
|
||||
res = defaultClient->SetSystemDNS(&rpcOK, servers, is_dhcp, true);
|
||||
res = defaultClient->SetSystemDNS(&rpcOK, customServer, NekoGui::dataStore->is_dhcp, true);
|
||||
}
|
||||
if (!rpcOK) {
|
||||
MW_show_log(tr("Failed to set system dns: ") + res);
|
||||
|
||||
@ -212,6 +212,7 @@ void DialogManageRoutes::accept() {
|
||||
NekoGui::dataStore->routing->def_outbound = ui->default_out->currentText();
|
||||
|
||||
NekoGui::dataStore->enable_dns_server = ui->dnshijack_enable->isChecked();
|
||||
auto prevDNSListenAddr = NekoGui::dataStore->dns_server_listen_addr;
|
||||
NekoGui::dataStore->dns_server_listen_addr = ui->dnshijack_listenaddr->text();
|
||||
NekoGui::dataStore->dns_server_listen_port = ui->dnshijack_listenport->text().toInt();
|
||||
NekoGui::dataStore->dns_v4_resp = ui->dnshijack_v4resp->text();
|
||||
@ -228,6 +229,13 @@ void DialogManageRoutes::accept() {
|
||||
NekoGui::dataStore->redirect_listen_address = ui->redirect_listenaddr->text();
|
||||
NekoGui::dataStore->redirect_listen_port = ui->redirect_listenport->text().toInt();
|
||||
|
||||
if (prevDNSListenAddr != NekoGui::dataStore->dns_server_listen_addr)
|
||||
{
|
||||
QStringList msg{"DNSServerChanged"};
|
||||
msg << prevDNSListenAddr;
|
||||
MW_dialog_message("", msg.join(","));
|
||||
}
|
||||
|
||||
//
|
||||
QStringList msg{"UpdateDataStore"};
|
||||
msg << "RouteChanged";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user