migrate to clash for traffic &&

refactor
This commit is contained in:
Nova 2025-02-13 20:09:40 +03:30
parent aedf4e2201
commit 9e66635244
20 changed files with 379 additions and 533 deletions

View File

@ -446,10 +446,8 @@ type QueryStatsResp struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
DirectTrafficUp int64 `protobuf:"varint,1,opt,name=direct_traffic_up,json=directTrafficUp,proto3" json:"direct_traffic_up,omitempty"`
DirectTrafficDown int64 `protobuf:"varint,2,opt,name=direct_traffic_down,json=directTrafficDown,proto3" json:"direct_traffic_down,omitempty"`
ProxyTrafficUp int64 `protobuf:"varint,3,opt,name=proxy_traffic_up,json=proxyTrafficUp,proto3" json:"proxy_traffic_up,omitempty"`
ProxyTrafficDown int64 `protobuf:"varint,4,opt,name=proxy_traffic_down,json=proxyTrafficDown,proto3" json:"proxy_traffic_down,omitempty"`
Ups map[string]int64 `protobuf:"bytes,1,rep,name=ups,proto3" json:"ups,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
Downs map[string]int64 `protobuf:"bytes,2,rep,name=downs,proto3" json:"downs,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
}
func (x *QueryStatsResp) Reset() {
@ -484,32 +482,18 @@ func (*QueryStatsResp) Descriptor() ([]byte, []int) {
return file_libcore_proto_rawDescGZIP(), []int{7}
}
func (x *QueryStatsResp) GetDirectTrafficUp() int64 {
func (x *QueryStatsResp) GetUps() map[string]int64 {
if x != nil {
return x.DirectTrafficUp
return x.Ups
}
return 0
return nil
}
func (x *QueryStatsResp) GetDirectTrafficDown() int64 {
func (x *QueryStatsResp) GetDowns() map[string]int64 {
if x != nil {
return x.DirectTrafficDown
return x.Downs
}
return 0
}
func (x *QueryStatsResp) GetProxyTrafficUp() int64 {
if x != nil {
return x.ProxyTrafficUp
}
return 0
}
func (x *QueryStatsResp) GetProxyTrafficDown() int64 {
if x != nil {
return x.ProxyTrafficDown
}
return 0
return nil
}
type UpdateReq struct {
@ -1281,158 +1265,161 @@ var file_libcore_proto_rawDesc = []byte{
0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2e, 0x0a, 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c,
0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f,
0x72, 0x65, 0x2e, 0x55, 0x52, 0x4c, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x52, 0x07,
0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x22, 0xc4, 0x01, 0x0a, 0x0e, 0x51, 0x75, 0x65, 0x72,
0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2a, 0x0a, 0x11, 0x64, 0x69,
0x72, 0x65, 0x63, 0x74, 0x5f, 0x74, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x5f, 0x75, 0x70, 0x18,
0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x54, 0x72, 0x61,
0x66, 0x66, 0x69, 0x63, 0x55, 0x70, 0x12, 0x2e, 0x0a, 0x13, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74,
0x5f, 0x74, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x5f, 0x64, 0x6f, 0x77, 0x6e, 0x18, 0x02, 0x20,
0x01, 0x28, 0x03, 0x52, 0x11, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x54, 0x72, 0x61, 0x66, 0x66,
0x69, 0x63, 0x44, 0x6f, 0x77, 0x6e, 0x12, 0x28, 0x0a, 0x10, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f,
0x74, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x5f, 0x75, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03,
0x52, 0x0e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x54, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x55, 0x70,
0x12, 0x2c, 0x0a, 0x12, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x74, 0x72, 0x61, 0x66, 0x66, 0x69,
0x63, 0x5f, 0x64, 0x6f, 0x77, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x10, 0x70, 0x72,
0x6f, 0x78, 0x79, 0x54, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x44, 0x6f, 0x77, 0x6e, 0x22, 0x66,
0x0a, 0x09, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x12, 0x2d, 0x0a, 0x06, 0x61,
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x6c, 0x69,
0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x63, 0x74, 0x69,
0x6f, 0x6e, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2a, 0x0a, 0x11, 0x63, 0x68,
0x65, 0x63, 0x6b, 0x5f, 0x70, 0x72, 0x65, 0x5f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x18,
0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x50, 0x72, 0x65, 0x52,
0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x22, 0xd0, 0x01, 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74,
0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x1f, 0x0a, 0x0b, 0x61,
0x73, 0x73, 0x65, 0x74, 0x73, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x52, 0x0a, 0x61, 0x73, 0x73, 0x65, 0x74, 0x73, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x21, 0x0a, 0x0c,
0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x03, 0x20, 0x01,
0x28, 0x09, 0x52, 0x0b, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x55, 0x72, 0x6c, 0x12,
0x1f, 0x0a, 0x0b, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x04,
0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x55, 0x72, 0x6c,
0x12, 0x21, 0x0a, 0x0c, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x6e, 0x6f, 0x74, 0x65,
0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x4e,
0x6f, 0x74, 0x65, 0x12, 0x24, 0x0a, 0x0e, 0x69, 0x73, 0x5f, 0x70, 0x72, 0x65, 0x5f, 0x72, 0x65,
0x6c, 0x65, 0x61, 0x73, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x69, 0x73, 0x50,
0x72, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x22, 0x54, 0x0a, 0x13, 0x4c, 0x69, 0x73,
0x74, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70,
0x12, 0x3d, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18,
0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e,
0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x22, 0xf0, 0x01, 0x0a, 0x0e, 0x51, 0x75, 0x65, 0x72,
0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x12, 0x32, 0x0a, 0x03, 0x75, 0x70,
0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72,
0x65, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70,
0x2e, 0x55, 0x70, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x03, 0x75, 0x70, 0x73, 0x12, 0x38,
0x0a, 0x05, 0x64, 0x6f, 0x77, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e,
0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61,
0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x2e, 0x44, 0x6f, 0x77, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72,
0x79, 0x52, 0x05, 0x64, 0x6f, 0x77, 0x6e, 0x73, 0x1a, 0x36, 0x0a, 0x08, 0x55, 0x70, 0x73, 0x45,
0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18,
0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01,
0x1a, 0x38, 0x0a, 0x0a, 0x44, 0x6f, 0x77, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10,
0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79,
0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52,
0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x66, 0x0a, 0x09, 0x55, 0x70,
0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x12, 0x2d, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f,
0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72,
0x65, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x06,
0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2a, 0x0a, 0x11, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x5f,
0x70, 0x72, 0x65, 0x5f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
0x08, 0x52, 0x0f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x50, 0x72, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61,
0x73, 0x65, 0x22, 0xd0, 0x01, 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73,
0x70, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x73, 0x73, 0x65, 0x74,
0x73, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x73,
0x73, 0x65, 0x74, 0x73, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x6f, 0x77, 0x6e,
0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b,
0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x55, 0x72, 0x6c, 0x12, 0x1f, 0x0a, 0x0b, 0x72,
0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09,
0x52, 0x0a, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x55, 0x72, 0x6c, 0x12, 0x21, 0x0a, 0x0c,
0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x6e, 0x6f, 0x74, 0x65, 0x18, 0x05, 0x20, 0x01,
0x28, 0x09, 0x52, 0x0b, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x4e, 0x6f, 0x74, 0x65, 0x12,
0x24, 0x0a, 0x0e, 0x69, 0x73, 0x5f, 0x70, 0x72, 0x65, 0x5f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73,
0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x69, 0x73, 0x50, 0x72, 0x65, 0x52, 0x65,
0x6c, 0x65, 0x61, 0x73, 0x65, 0x22, 0x54, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6e,
0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x12, 0x3d, 0x0a, 0x0b,
0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28,
0x0b, 0x32, 0x1b, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x43, 0x6f, 0x6e, 0x6e,
0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x74, 0x61, 0x44, 0x61, 0x74, 0x61, 0x52, 0x0b,
0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x8f, 0x02, 0x0a, 0x12,
0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x74, 0x61, 0x44, 0x61,
0x74, 0x61, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22,
0x8f, 0x02, 0x0a, 0x12, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65,
0x74, 0x61, 0x44, 0x61, 0x74, 0x61, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65,
0x64, 0x5f, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61,
0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x18,
0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x1a, 0x0a,
0x08, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52,
0x08, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x6f, 0x75, 0x74,
0x62, 0x6f, 0x75, 0x6e, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6f, 0x75, 0x74,
0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b,
0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12,
0x12, 0x0a, 0x04, 0x64, 0x65, 0x73, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64,
0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18,
0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12,
0x16, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52,
0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x63, 0x65,
0x73, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73,
0x73, 0x22, 0x2c, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x47, 0x65, 0x6f, 0x49, 0x50, 0x4c, 0x69, 0x73,
0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x74, 0x65,
0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x22,
0x2e, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x47, 0x65, 0x6f, 0x53, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x73,
0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x74, 0x65,
0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x22,
0x24, 0x0a, 0x0e, 0x47, 0x65, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x04, 0x70, 0x61, 0x74, 0x68, 0x22, 0x42, 0x0a, 0x18, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65,
0x47, 0x65, 0x6f, 0x49, 0x50, 0x54, 0x6f, 0x53, 0x72, 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, 0x44, 0x0a, 0x1a, 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, 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, 0x2a, 0x27, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74,
0x65, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x09, 0x0a, 0x05, 0x43, 0x68, 0x65, 0x63, 0x6b,
0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x10, 0x01,
0x32, 0xbc, 0x07, 0x0a, 0x0e, 0x4c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x53, 0x65, 0x72, 0x76,
0x69, 0x63, 0x65, 0x12, 0x2f, 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, 0x22, 0x00, 0x12, 0x33, 0x0a, 0x06, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x12,
0x74, 0x61, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02,
0x69, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74,
0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41,
0x74, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28,
0x03, 0x52, 0x06, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x6f, 0x77,
0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x64, 0x6f, 0x77,
0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e,
0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e,
0x64, 0x12, 0x18, 0x0a, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x06, 0x20, 0x01,
0x28, 0x09, 0x52, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x64,
0x65, 0x73, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x65, 0x73, 0x74, 0x12,
0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28,
0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x16, 0x0a, 0x06, 0x64,
0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x6f, 0x6d,
0x61, 0x69, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x18, 0x0a,
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x22, 0x2c, 0x0a,
0x14, 0x47, 0x65, 0x74, 0x47, 0x65, 0x6f, 0x49, 0x50, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x01,
0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x22, 0x2e, 0x0a, 0x16, 0x47,
0x65, 0x74, 0x47, 0x65, 0x6f, 0x53, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x02,
0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x22, 0x24, 0x0a, 0x0e, 0x47,
0x65, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a,
0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74,
0x68, 0x22, 0x42, 0x0a, 0x18, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x47, 0x65, 0x6f, 0x49,
0x50, 0x54, 0x6f, 0x53, 0x72, 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, 0x44, 0x0a, 0x1a, 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, 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, 0x2a, 0x27, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x63, 0x74,
0x69, 0x6f, 0x6e, 0x12, 0x09, 0x0a, 0x05, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x10, 0x00, 0x12, 0x0c,
0x0a, 0x08, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x10, 0x01, 0x32, 0xbc, 0x07, 0x0a,
0x0e, 0x4c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12,
0x2f, 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, 0x22, 0x00,
0x12, 0x33, 0x0a, 0x06, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x12, 0x2e, 0x6c, 0x69, 0x62,
0x63, 0x6f, 0x72, 0x65, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x13,
0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52,
0x65, 0x71, 0x1a, 0x13, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x55, 0x70, 0x64,
0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x35, 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, 0x22, 0x00,
0x12, 0x2f, 0x0a, 0x04, 0x53, 0x74, 0x6f, 0x70, 0x12, 0x11, 0x2e, 0x6c, 0x69, 0x62, 0x63, 0x6f,
0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x35, 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, 0x22, 0x00, 0x12, 0x2f, 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, 0x22, 0x00, 0x12, 0x2d, 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, 0x22, 0x00, 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, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x22,
0x00, 0x12, 0x2d, 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, 0x22, 0x00,
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, 0x3a, 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, 0x22, 0x00, 0x12,
0x44, 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, 0x22, 0x00, 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, 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,
0x62, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12,
0x3a, 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, 0x22, 0x00, 0x12, 0x44, 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, 0x22,
0x00, 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, 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, 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, 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,
0x65, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 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 (
@ -1448,7 +1435,7 @@ func file_libcore_proto_rawDescGZIP() []byte {
}
var file_libcore_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_libcore_proto_msgTypes = make([]protoimpl.MessageInfo, 20)
var file_libcore_proto_msgTypes = make([]protoimpl.MessageInfo, 22)
var file_libcore_proto_goTypes = []any{
(UpdateAction)(0), // 0: libcore.UpdateAction
(*EmptyReq)(nil), // 1: libcore.EmptyReq
@ -1471,46 +1458,50 @@ var file_libcore_proto_goTypes = []any{
(*SetSystemProxyRequest)(nil), // 18: libcore.SetSystemProxyRequest
(*SetSystemDNSRequest)(nil), // 19: libcore.SetSystemDNSRequest
(*GetSystemDNSResponse)(nil), // 20: libcore.GetSystemDNSResponse
nil, // 21: libcore.QueryStatsResp.UpsEntry
nil, // 22: libcore.QueryStatsResp.DownsEntry
}
var file_libcore_proto_depIdxs = []int32{
5, // 0: libcore.TestResp.results:type_name -> libcore.URLTestResp
0, // 1: libcore.UpdateReq.action:type_name -> libcore.UpdateAction
12, // 2: libcore.ListConnectionsResp.connections:type_name -> libcore.ConnectionMetaData
1, // 3: libcore.LibcoreService.Exit:input_type -> libcore.EmptyReq
9, // 4: libcore.LibcoreService.Update:input_type -> libcore.UpdateReq
4, // 5: libcore.LibcoreService.Start:input_type -> libcore.LoadConfigReq
1, // 6: libcore.LibcoreService.Stop:input_type -> libcore.EmptyReq
6, // 7: libcore.LibcoreService.Test:input_type -> libcore.TestReq
1, // 8: libcore.LibcoreService.StopTest:input_type -> libcore.EmptyReq
1, // 9: libcore.LibcoreService.QueryStats:input_type -> libcore.EmptyReq
1, // 10: libcore.LibcoreService.ListConnections:input_type -> libcore.EmptyReq
15, // 11: libcore.LibcoreService.GetGeoIPList:input_type -> libcore.GeoListRequest
15, // 12: libcore.LibcoreService.GetGeoSiteList:input_type -> libcore.GeoListRequest
16, // 13: libcore.LibcoreService.CompileGeoIPToSrs:input_type -> libcore.CompileGeoIPToSrsRequest
17, // 14: libcore.LibcoreService.CompileGeoSiteToSrs:input_type -> libcore.CompileGeoSiteToSrsRequest
18, // 15: libcore.LibcoreService.SetSystemProxy:input_type -> libcore.SetSystemProxyRequest
1, // 16: libcore.LibcoreService.GetSystemDNS:input_type -> libcore.EmptyReq
19, // 17: libcore.LibcoreService.SetSystemDNS:input_type -> libcore.SetSystemDNSRequest
2, // 18: libcore.LibcoreService.Exit:output_type -> libcore.EmptyResp
10, // 19: libcore.LibcoreService.Update:output_type -> libcore.UpdateResp
3, // 20: libcore.LibcoreService.Start:output_type -> libcore.ErrorResp
3, // 21: libcore.LibcoreService.Stop:output_type -> libcore.ErrorResp
7, // 22: libcore.LibcoreService.Test:output_type -> libcore.TestResp
2, // 23: libcore.LibcoreService.StopTest:output_type -> libcore.EmptyResp
8, // 24: libcore.LibcoreService.QueryStats:output_type -> libcore.QueryStatsResp
11, // 25: libcore.LibcoreService.ListConnections:output_type -> libcore.ListConnectionsResp
13, // 26: libcore.LibcoreService.GetGeoIPList:output_type -> libcore.GetGeoIPListResponse
14, // 27: libcore.LibcoreService.GetGeoSiteList:output_type -> libcore.GetGeoSiteListResponse
2, // 28: libcore.LibcoreService.CompileGeoIPToSrs:output_type -> libcore.EmptyResp
2, // 29: libcore.LibcoreService.CompileGeoSiteToSrs:output_type -> libcore.EmptyResp
2, // 30: libcore.LibcoreService.SetSystemProxy:output_type -> libcore.EmptyResp
20, // 31: libcore.LibcoreService.GetSystemDNS:output_type -> libcore.GetSystemDNSResponse
2, // 32: libcore.LibcoreService.SetSystemDNS:output_type -> libcore.EmptyResp
18, // [18:33] is the sub-list for method output_type
3, // [3:18] is the sub-list for method input_type
3, // [3:3] is the sub-list for extension type_name
3, // [3:3] is the sub-list for extension extendee
0, // [0:3] is the sub-list for field type_name
21, // 1: libcore.QueryStatsResp.ups:type_name -> libcore.QueryStatsResp.UpsEntry
22, // 2: libcore.QueryStatsResp.downs:type_name -> libcore.QueryStatsResp.DownsEntry
0, // 3: libcore.UpdateReq.action:type_name -> libcore.UpdateAction
12, // 4: libcore.ListConnectionsResp.connections:type_name -> libcore.ConnectionMetaData
1, // 5: libcore.LibcoreService.Exit:input_type -> libcore.EmptyReq
9, // 6: libcore.LibcoreService.Update:input_type -> libcore.UpdateReq
4, // 7: libcore.LibcoreService.Start:input_type -> libcore.LoadConfigReq
1, // 8: libcore.LibcoreService.Stop:input_type -> libcore.EmptyReq
6, // 9: libcore.LibcoreService.Test:input_type -> libcore.TestReq
1, // 10: libcore.LibcoreService.StopTest:input_type -> libcore.EmptyReq
1, // 11: libcore.LibcoreService.QueryStats:input_type -> libcore.EmptyReq
1, // 12: libcore.LibcoreService.ListConnections:input_type -> libcore.EmptyReq
15, // 13: libcore.LibcoreService.GetGeoIPList:input_type -> libcore.GeoListRequest
15, // 14: libcore.LibcoreService.GetGeoSiteList:input_type -> libcore.GeoListRequest
16, // 15: libcore.LibcoreService.CompileGeoIPToSrs:input_type -> libcore.CompileGeoIPToSrsRequest
17, // 16: libcore.LibcoreService.CompileGeoSiteToSrs:input_type -> libcore.CompileGeoSiteToSrsRequest
18, // 17: libcore.LibcoreService.SetSystemProxy:input_type -> libcore.SetSystemProxyRequest
1, // 18: libcore.LibcoreService.GetSystemDNS:input_type -> libcore.EmptyReq
19, // 19: libcore.LibcoreService.SetSystemDNS:input_type -> libcore.SetSystemDNSRequest
2, // 20: libcore.LibcoreService.Exit:output_type -> libcore.EmptyResp
10, // 21: libcore.LibcoreService.Update:output_type -> libcore.UpdateResp
3, // 22: libcore.LibcoreService.Start:output_type -> libcore.ErrorResp
3, // 23: libcore.LibcoreService.Stop:output_type -> libcore.ErrorResp
7, // 24: libcore.LibcoreService.Test:output_type -> libcore.TestResp
2, // 25: libcore.LibcoreService.StopTest:output_type -> libcore.EmptyResp
8, // 26: libcore.LibcoreService.QueryStats:output_type -> libcore.QueryStatsResp
11, // 27: libcore.LibcoreService.ListConnections:output_type -> libcore.ListConnectionsResp
13, // 28: libcore.LibcoreService.GetGeoIPList:output_type -> libcore.GetGeoIPListResponse
14, // 29: libcore.LibcoreService.GetGeoSiteList:output_type -> libcore.GetGeoSiteListResponse
2, // 30: libcore.LibcoreService.CompileGeoIPToSrs:output_type -> libcore.EmptyResp
2, // 31: libcore.LibcoreService.CompileGeoSiteToSrs:output_type -> libcore.EmptyResp
2, // 32: libcore.LibcoreService.SetSystemProxy:output_type -> libcore.EmptyResp
20, // 33: libcore.LibcoreService.GetSystemDNS:output_type -> libcore.GetSystemDNSResponse
2, // 34: libcore.LibcoreService.SetSystemDNS:output_type -> libcore.EmptyResp
20, // [20:35] is the sub-list for method output_type
5, // [5:20] is the sub-list for method input_type
5, // [5:5] is the sub-list for extension type_name
5, // [5:5] is the sub-list for extension extendee
0, // [0:5] is the sub-list for field type_name
}
func init() { file_libcore_proto_init() }
@ -1766,7 +1757,7 @@ func file_libcore_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_libcore_proto_rawDesc,
NumEnums: 1,
NumMessages: 20,
NumMessages: 22,
NumExtensions: 0,
NumServices: 1,
},

View File

@ -58,10 +58,8 @@ message TestResp {
}
message QueryStatsResp{
int64 direct_traffic_up = 1;
int64 direct_traffic_down = 2;
int64 proxy_traffic_up = 3;
int64 proxy_traffic_down = 4;
map<string, int64> ups = 1;
map<string, int64> downs = 2;
}
enum UpdateAction {

View File

@ -1 +0,0 @@
package boxdns

View File

@ -26,14 +26,14 @@ func init() {
}
func check() error {
options, err := readConfigAndMerge()
options, err := parseConfig(nil)
if err != nil {
return err
}
ctx, cancel := context.WithCancel(context.Background())
instance, err := boxbox.New(boxbox.Options{
Context: ctx,
Options: options,
Options: *options,
})
if err == nil {
instance.Close()

View File

@ -2,24 +2,19 @@ package boxmain
import (
"context"
"github.com/sagernet/sing/common/json"
"github.com/sagernet/sing/common/json/badjson"
"io"
"github.com/sagernet/sing-box/include"
"nekobox_core/internal/boxbox"
"os"
"os/signal"
"path/filepath"
runtimeDebug "runtime/debug"
"sort"
"strings"
"syscall"
"time"
"github.com/matsuridayo/libneko/protect_server"
C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/log"
"github.com/sagernet/sing-box/option"
E "github.com/sagernet/sing/common/exceptions"
"nekobox_core/internal/boxbox"
"github.com/sagernet/sing/common/json"
"github.com/spf13/cobra"
)
@ -27,10 +22,6 @@ var commandRun = &cobra.Command{
Use: "run",
Short: "Run service",
Run: func(cmd *cobra.Command, args []string) {
if protectListenPath != "" {
// for v2ray now
go protect_server.ServeProtect(protectListenPath, true, protectFwMark, nil)
}
err := run()
if err != nil {
log.Fatal(err)
@ -48,111 +39,34 @@ type OptionsEntry struct {
options option.Options
}
func readConfigAt(path string) (*OptionsEntry, error) {
func parseConfig(configContent []byte) (*option.Options, error) {
var (
configContent []byte
err error
err error
)
if path == "stdin" {
configContent, err = io.ReadAll(os.Stdin)
} else {
configContent, err = os.ReadFile(path)
}
options, err := json.UnmarshalExtendedContext[option.Options](globalCtx, configContent)
if err != nil {
return nil, E.Cause(err, "read config at ", path)
return nil, E.Cause(err, "decode config at ", string(configContent))
}
var options option.Options
err = options.UnmarshalJSONContext(context.Background(), configContent)
if err != nil {
return nil, E.Cause(err, "decode config at ", path)
}
return &OptionsEntry{
content: configContent,
path: path,
options: options,
}, nil
return &options, nil
}
func readConfig() ([]*OptionsEntry, error) {
var optionsList []*OptionsEntry
for _, path := range configPaths {
optionsEntry, err := readConfigAt(path)
if err != nil {
return nil, err
}
optionsList = append(optionsList, optionsEntry)
}
for _, directory := range configDirectories {
entries, err := os.ReadDir(directory)
if err != nil {
return nil, E.Cause(err, "read config directory at ", directory)
}
for _, entry := range entries {
if !strings.HasSuffix(entry.Name(), ".json") || entry.IsDir() {
continue
}
optionsEntry, err := readConfigAt(filepath.Join(directory, entry.Name()))
if err != nil {
return nil, err
}
optionsList = append(optionsList, optionsEntry)
}
}
sort.Slice(optionsList, func(i, j int) bool {
return optionsList[i].path < optionsList[j].path
})
return optionsList, nil
}
func readConfigAndMerge() (option.Options, error) {
optionsList, err := readConfig()
if err != nil {
return option.Options{}, err
}
if len(optionsList) == 1 {
return optionsList[0].options, nil
}
var mergedMessage json.RawMessage
for _, options := range optionsList {
mergedMessage, err = badjson.MergeJSON(context.Background(), options.options.RawMessage, mergedMessage, false)
if err != nil {
return option.Options{}, E.Cause(err, "merge config at ", options.path)
}
}
var mergedOptions option.Options
err = mergedOptions.UnmarshalJSONContext(context.Background(), mergedMessage)
if err != nil {
return option.Options{}, E.Cause(err, "unmarshal merged config")
}
return mergedOptions, nil
}
func Create(nekoConfigContent []byte) (*boxbox.Box, context.CancelFunc, error) {
var options option.Options
var err error
//
if nekoConfigContent == nil {
options, err = readConfigAndMerge()
} else {
err = options.UnmarshalJSONContext(context.Background(), nekoConfigContent)
}
func Create(configContent []byte) (*boxbox.Box, context.CancelFunc, error) {
globalCtx = context.Background()
globalCtx = boxbox.Context(globalCtx, include.InboundRegistry(), include.OutboundRegistry(), include.EndpointRegistry())
options, err := parseConfig(configContent)
if err != nil {
return nil, nil, err
}
//
if disableColor {
if options.Log == nil {
options.Log = &option.LogOptions{}
}
options.Log.DisableColor = true
}
ctx, cancel := context.WithCancel(context.Background())
ctx, cancel := context.WithCancel(globalCtx)
instance, err := boxbox.New(boxbox.Options{
Context: ctx,
Options: options,
Options: *options,
})
if err != nil {
cancel()
@ -165,14 +79,16 @@ func Create(nekoConfigContent []byte) (*boxbox.Box, context.CancelFunc, error) {
signal.Stop(osSignals)
close(osSignals)
}()
startCtx, finishStart := context.WithCancel(context.Background())
go func() {
_, loaded := <-osSignals
if loaded {
cancel()
closeMonitor(startCtx)
}
}()
err = instance.Start()
finishStart()
if err != nil {
cancel()
return nil, nil, E.Cause(err, "start service")
@ -185,7 +101,7 @@ func run() error {
signal.Notify(osSignals, os.Interrupt, syscall.SIGTERM, syscall.SIGHUP)
defer signal.Stop(osSignals)
for {
instance, cancel, err := Create(nil)
instance, cancel, err := Create([]byte{})
if err != nil {
return err
}
@ -202,9 +118,12 @@ func run() error {
cancel()
closeCtx, closed := context.WithCancel(context.Background())
go closeMonitor(closeCtx)
instance.Close()
err = instance.Close()
closed()
if osSignal != syscall.SIGHUP {
if err != nil {
log.Error(E.Cause(err, "sing-box did not closed properly"))
}
return nil
}
break
@ -213,7 +132,7 @@ func run() error {
}
func closeMonitor(ctx context.Context) {
time.Sleep(3 * time.Second)
time.Sleep(C.FatalStopTimeout)
select {
case <-ctx.Done():
return
@ -221,24 +140,3 @@ func closeMonitor(ctx context.Context) {
}
log.Fatal("sing-box did not close!")
}
func MergeOptions(source option.Options, destination option.Options) (option.Options, error) {
rawSource, err := json.Marshal(source)
if err != nil {
return option.Options{}, E.Cause(err, "marshal source")
}
rawDestination, err := json.Marshal(destination)
if err != nil {
return option.Options{}, E.Cause(err, "marshal destination")
}
rawMerged, err := badjson.MergeJSON(context.Background(), rawSource, rawDestination, false)
if err != nil {
return option.Options{}, E.Cause(err, "merge options")
}
var merged option.Options
err = json.Unmarshal(rawMerged, &merged)
if err != nil {
return option.Options{}, E.Cause(err, "unmarshal merged options")
}
return merged, nil
}

View File

@ -1,24 +1,28 @@
package boxmain
import (
"github.com/sagernet/sing-box/option"
"context"
"os"
"os/user"
"strconv"
"time"
_ "github.com/sagernet/sing-box/include"
"github.com/sagernet/sing-box"
"github.com/sagernet/sing-box/experimental/deprecated"
"github.com/sagernet/sing-box/include"
"github.com/sagernet/sing-box/log"
"github.com/sagernet/sing/service"
"github.com/sagernet/sing/service/filemanager"
"github.com/spf13/cobra"
)
var (
globalCtx context.Context
configPaths []string
configDirectories []string
workingDir string
disableColor bool
//
protectListenPath string
protectFwMark int
)
var mainCommand = &cobra.Command{
@ -31,31 +35,39 @@ func init() {
mainCommand.PersistentFlags().StringArrayVarP(&configDirectories, "config-directory", "C", nil, "set configuration directory path")
mainCommand.PersistentFlags().StringVarP(&workingDir, "directory", "D", "", "set working directory")
mainCommand.PersistentFlags().BoolVarP(&disableColor, "disable-color", "", false, "disable color output")
mainCommand.PersistentFlags().StringVarP(&protectListenPath, "protect-listen-path", "", "", "Linux Only")
mainCommand.PersistentFlags().IntVarP(&protectFwMark, "protect-fwmark", "", 0, "Linux Only")
}
func Main() {
if err := mainCommand.Execute(); err != nil {
log.Fatal(err)
}
}
func preRun(cmd *cobra.Command, args []string) {
globalCtx = context.Background()
sudoUser := os.Getenv("SUDO_USER")
sudoUID, _ := strconv.Atoi(os.Getenv("SUDO_UID"))
sudoGID, _ := strconv.Atoi(os.Getenv("SUDO_GID"))
if sudoUID == 0 && sudoGID == 0 && sudoUser != "" {
sudoUserObject, _ := user.Lookup(sudoUser)
if sudoUserObject != nil {
sudoUID, _ = strconv.Atoi(sudoUserObject.Uid)
sudoGID, _ = strconv.Atoi(sudoUserObject.Gid)
}
}
if sudoUID > 0 && sudoGID > 0 {
globalCtx = filemanager.WithDefault(globalCtx, "", "", sudoUID, sudoGID)
}
if disableColor {
factory, _ := log.New(log.Options{Options: option.LogOptions{Output: "stderr", DisableColor: true}, BaseTime: time.Now()})
log.SetStdLogger(factory.Logger())
log.SetStdLogger(log.NewDefaultFactory(context.Background(), log.Formatter{BaseTime: time.Now(), DisableColors: true}, os.Stderr, "", nil, false).Logger())
}
if workingDir != "" {
_, err := os.Stat(workingDir)
if err != nil {
os.MkdirAll(workingDir, 0o777)
filemanager.MkdirAll(globalCtx, workingDir, 0o777)
}
if err := os.Chdir(workingDir); err != nil {
err = os.Chdir(workingDir)
if err != nil {
log.Fatal(err)
}
}
if len(configPaths) == 0 && len(configDirectories) == 0 {
configPaths = append(configPaths, "config.json")
}
globalCtx = service.ContextWith(globalCtx, deprecated.NewStderrManager(log.StdLogger()))
globalCtx = box.Context(globalCtx, include.InboundRegistry(), include.OutboundRegistry(), include.EndpointRegistry())
}

View File

@ -58,7 +58,7 @@ func RunCore() {
)
gen.RegisterLibcoreServiceServer(s, &server{})
log.Printf("Core grpc server listening at %v\n", lis.Addr())
fmt.Printf("Core listening at %v\n", lis.Addr())
if err := s.Serve(lis); err != nil {
log.Fatalf("failed to serve: %v", err)
}

View File

@ -12,7 +12,7 @@ import (
"github.com/sagernet/sing/service"
"io"
"log"
gen2 "nekobox_core/gen"
"nekobox_core/gen"
"nekobox_core/internal/boxapi"
"nekobox_core/internal/boxbox"
"nekobox_core/internal/boxmain"
@ -32,22 +32,22 @@ var instanceCancel context.CancelFunc
var debug bool
type server struct {
gen2.LibcoreServiceServer
gen.UnimplementedLibcoreServiceServer
}
func (s *server) Exit(ctx context.Context, in *gen2.EmptyReq) (out *gen2.EmptyResp, _ error) {
out = &gen2.EmptyResp{}
func (s *server) Exit(ctx context.Context, in *gen.EmptyReq) (out *gen.EmptyResp, _ error) {
out = &gen.EmptyResp{}
// Connection closed
os.Exit(0)
return
}
func (s *server) Start(ctx context.Context, in *gen2.LoadConfigReq) (out *gen2.ErrorResp, _ error) {
func (s *server) Start(ctx context.Context, in *gen.LoadConfigReq) (out *gen.ErrorResp, _ error) {
var err error
defer func() {
out = &gen2.ErrorResp{}
out = &gen.ErrorResp{}
if err != nil {
out.Error = err.Error()
boxInstance = nil
@ -75,11 +75,11 @@ func (s *server) Start(ctx context.Context, in *gen2.LoadConfigReq) (out *gen2.E
return
}
func (s *server) Stop(ctx context.Context, in *gen2.EmptyReq) (out *gen2.ErrorResp, _ error) {
func (s *server) Stop(ctx context.Context, in *gen.EmptyReq) (out *gen.ErrorResp, _ error) {
var err error
defer func() {
out = &gen2.ErrorResp{}
out = &gen.ErrorResp{}
if err != nil {
out.Error = err.Error()
}
@ -103,14 +103,14 @@ func (s *server) Stop(ctx context.Context, in *gen2.EmptyReq) (out *gen2.ErrorRe
return
}
func (s *server) Test(ctx context.Context, in *gen2.TestReq) (*gen2.TestResp, error) {
func (s *server) Test(ctx context.Context, in *gen.TestReq) (*gen.TestResp, error) {
var testInstance *boxbox.Box
var cancel context.CancelFunc
var err error
var twice = true
if in.TestCurrent {
if boxInstance == nil {
return &gen2.TestResp{Results: []*gen2.URLTestResp{{
return &gen.TestResp{Results: []*gen.URLTestResp{{
OutboundTag: "proxy",
LatencyMs: 0,
Error: "Instance is not running",
@ -139,31 +139,34 @@ func (s *server) Test(ctx context.Context, in *gen2.TestReq) (*gen2.TestResp, er
}
results := BatchURLTest(testCtx, testInstance, outboundTags, in.Url, int(maxConcurrency), twice)
res := make([]*gen2.URLTestResp, 0)
res := make([]*gen.URLTestResp, 0)
for idx, data := range results {
errStr := ""
if data.Error != nil {
errStr = data.Error.Error()
}
res = append(res, &gen2.URLTestResp{
res = append(res, &gen.URLTestResp{
OutboundTag: outboundTags[idx],
LatencyMs: int32(data.Duration.Milliseconds()),
Error: errStr,
})
}
return &gen2.TestResp{Results: res}, nil
return &gen.TestResp{Results: res}, nil
}
func (s *server) StopTest(ctx context.Context, in *gen2.EmptyReq) (*gen2.EmptyResp, error) {
func (s *server) StopTest(ctx context.Context, in *gen.EmptyReq) (*gen.EmptyResp, error) {
cancelTests()
testCtx, cancelTests = context.WithCancel(context.Background())
return &gen2.EmptyResp{}, nil
return &gen.EmptyResp{}, nil
}
func (s *server) QueryStats(ctx context.Context, _ *gen2.EmptyReq) (*gen2.QueryStatsResp, error) {
resp := &gen2.QueryStatsResp{}
func (s *server) QueryStats(ctx context.Context, _ *gen.EmptyReq) (*gen.QueryStatsResp, error) {
resp := &gen.QueryStatsResp{
Ups: make(map[string]int64),
Downs: make(map[string]int64),
}
if boxInstance != nil {
clash := service.FromContext[adapter.ClashServer](boxInstance.Context())
if clash != nil {
@ -172,20 +175,19 @@ func (s *server) QueryStats(ctx context.Context, _ *gen2.EmptyReq) (*gen2.QueryS
log.Println("Failed to assert clash server")
return nil, E.New("invalid clash server type")
}
outbounds := service.FromContext[adapter.OutboundManager](ctx)
outbounds := service.FromContext[adapter.OutboundManager](boxInstance.Context())
if outbounds == nil {
log.Println("Failed to assert outbound manager")
return nil, E.New("invalid outbound manager type")
}
for _, out := range outbounds.Outbounds() {
u, d := cApi.TrafficManager().TotalOutbound(out.Tag())
if strings.ToLower(out.Tag()) == "direct" {
resp.DirectTrafficUp += u
resp.DirectTrafficDown += d
} else {
resp.ProxyTrafficUp += u
resp.ProxyTrafficDown += d
if len(out.Dependencies()) > 0 {
// ignore, has detour
continue
}
u, d := cApi.TrafficManager().TotalOutbound(out.Tag())
resp.Ups[out.Tag()] = u
resp.Downs[out.Tag()] = d
}
cApi.TrafficManager().ResetStatistic()
}
@ -194,9 +196,9 @@ func (s *server) QueryStats(ctx context.Context, _ *gen2.EmptyReq) (*gen2.QueryS
return resp, nil
}
func (s *server) ListConnections(ctx context.Context, in *gen2.EmptyReq) (*gen2.ListConnectionsResp, error) {
func (s *server) ListConnections(ctx context.Context, in *gen.EmptyReq) (*gen.ListConnectionsResp, error) {
if boxInstance == nil {
return &gen2.ListConnectionsResp{}, nil
return &gen.ListConnectionsResp{}, nil
}
if service.FromContext[adapter.ClashServer](boxInstance.Context()) == nil {
return nil, errors.New("no clash server found")
@ -207,14 +209,14 @@ func (s *server) ListConnections(ctx context.Context, in *gen2.EmptyReq) (*gen2.
}
connections := clash.TrafficManager().Connections()
res := make([]*gen2.ConnectionMetaData, 0)
res := make([]*gen.ConnectionMetaData, 0)
for _, c := range connections {
process := ""
if c.Metadata.ProcessInfo != nil {
spl := strings.Split(c.Metadata.ProcessInfo.ProcessPath, string(os.PathSeparator))
process = spl[len(spl)-1]
}
r := &gen2.ConnectionMetaData{
r := &gen.ConnectionMetaData{
Id: c.ID.String(),
CreatedAt: c.CreatedAt.UnixMilli(),
Upload: c.Upload.Load(),
@ -228,13 +230,13 @@ func (s *server) ListConnections(ctx context.Context, in *gen2.EmptyReq) (*gen2.
}
res = append(res, r)
}
out := &gen2.ListConnectionsResp{
out := &gen.ListConnectionsResp{
Connections: res,
}
return out, nil
}
func (s *server) GetGeoIPList(ctx context.Context, in *gen2.GeoListRequest) (*gen2.GetGeoIPListResponse, error) {
func (s *server) GetGeoIPList(ctx context.Context, in *gen.GeoListRequest) (*gen.GetGeoIPListResponse, error) {
resp, err := boxmain.ListGeoip(in.Path + string(os.PathSeparator) + "geoip.db")
if err != nil {
return nil, err
@ -246,10 +248,10 @@ func (s *server) GetGeoIPList(ctx context.Context, in *gen2.GeoListRequest) (*ge
res = append(res, r)
}
return &gen2.GetGeoIPListResponse{Items: res}, nil
return &gen.GetGeoIPListResponse{Items: res}, nil
}
func (s *server) GetGeoSiteList(ctx context.Context, in *gen2.GeoListRequest) (*gen2.GetGeoSiteListResponse, error) {
func (s *server) GetGeoSiteList(ctx context.Context, in *gen.GeoListRequest) (*gen.GetGeoSiteListResponse, error) {
resp, err := boxmain.GeositeList(in.Path + string(os.PathSeparator) + "geosite.db")
if err != nil {
return nil, err
@ -261,30 +263,30 @@ func (s *server) GetGeoSiteList(ctx context.Context, in *gen2.GeoListRequest) (*
res = append(res, r)
}
return &gen2.GetGeoSiteListResponse{Items: res}, nil
return &gen.GetGeoSiteListResponse{Items: res}, nil
}
func (s *server) CompileGeoIPToSrs(ctx context.Context, in *gen2.CompileGeoIPToSrsRequest) (*gen2.EmptyResp, error) {
func (s *server) CompileGeoIPToSrs(ctx context.Context, in *gen.CompileGeoIPToSrsRequest) (*gen.EmptyResp, error) {
category := strings.TrimSuffix(in.Item, "_IP")
err := boxmain.CompileRuleSet(in.Path+string(os.PathSeparator)+"geoip.db", category, boxmain.IpRuleSet, "./rule_sets/"+in.Item+".srs")
if err != nil {
return nil, err
}
return &gen2.EmptyResp{}, nil
return &gen.EmptyResp{}, nil
}
func (s *server) CompileGeoSiteToSrs(ctx context.Context, in *gen2.CompileGeoSiteToSrsRequest) (*gen2.EmptyResp, error) {
func (s *server) CompileGeoSiteToSrs(ctx context.Context, in *gen.CompileGeoSiteToSrsRequest) (*gen.EmptyResp, error) {
category := strings.TrimSuffix(in.Item, "_SITE")
err := boxmain.CompileRuleSet(in.Path+string(os.PathSeparator)+"geosite.db", category, boxmain.SiteRuleSet, "./rule_sets/"+in.Item+".srs")
if err != nil {
return nil, err
}
return &gen2.EmptyResp{}, nil
return &gen.EmptyResp{}, nil
}
func (s *server) SetSystemProxy(ctx context.Context, in *gen2.SetSystemProxyRequest) (*gen2.EmptyResp, error) {
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() {
@ -304,16 +306,16 @@ func (s *server) SetSystemProxy(ctx context.Context, in *gen2.SetSystemProxyRequ
return nil, err
}
return &gen2.EmptyResp{}, nil
return &gen.EmptyResp{}, nil
}
func (s *server) Update(ctx context.Context, in *gen2.UpdateReq) (*gen2.UpdateResp, error) {
func (s *server) Update(ctx context.Context, in *gen.UpdateReq) (*gen.UpdateResp, error) {
var updateDownloadUrl string
ret := &gen2.UpdateResp{}
ret := &gen.UpdateResp{}
client := boxapi.CreateProxyHttpClient(boxInstance)
if in.Action == gen2.UpdateAction_Check { // Check update
if in.Action == gen.UpdateAction_Check { // Check update
ctx, cancel := context.WithTimeout(ctx, time.Second*10)
defer cancel()

View File

@ -2,7 +2,7 @@
#ifndef NKR_NO_GRPC
#include "core/cmd/nekobox_core/server/gen/libcore.pb.h"
#include "core/server/gen/libcore.pb.h"
#include <QString>
namespace QtGrpc {
@ -24,7 +24,7 @@ namespace NekoGui_rpc {
QString Stop(bool *rpcOK);
long long QueryStats(const std::string &tag, const std::string &direct);
libcore::QueryStatsResp QueryStats();
libcore::TestResp Test(bool *rpcOK, const libcore::TestReq &request);

View File

@ -10,8 +10,6 @@ namespace NekoGui {
QJsonObject coreConfig;
QList<std::shared_ptr<NekoGui_traffic::TrafficData>> outboundStats; // all, but not including "bypass" "block"
std::shared_ptr<NekoGui_traffic::TrafficData> outboundStat; // main
QStringList ignoreConnTag;
};
class BuildTestConfigResult {

View File

@ -39,7 +39,7 @@ namespace NekoGui {
bool invert = false;
int outboundID = -2; // -1 is proxy -2 is direct -3 is block -4 is dns_out
// since sing-box 1.11.0
QString actionType = "route";
QString action = "route";
// reject options
QString rejectMethod;

View File

@ -14,16 +14,12 @@ namespace NekoGui_traffic {
QMutex loop_mutex;
QList<std::shared_ptr<TrafficData>> items;
TrafficData *proxy = nullptr;
std::shared_ptr<TrafficData> proxy;
std::shared_ptr<TrafficData> direct;
void UpdateAll();
void Loop();
private:
TrafficData *direct = new TrafficData("direct");
[[nodiscard]] static TrafficData *update_stats(TrafficData *item);
};
extern TrafficLooper *trafficLooper;

View File

@ -1,7 +1,6 @@
#include "include/api/gRPC.h"
#include <utility>
#include <QStringList>
#include "include/global/NekoGui.hpp"
@ -13,8 +12,6 @@
#include <QMutex>
#include <QAbstractNetworkCache>
#include <iostream>
namespace QtGrpc {
const char *GrpcAcceptEncodingHeader = "grpc-accept-encoding";
const char *AcceptEncodingHeader = "accept-encoding";
@ -55,28 +52,22 @@ namespace QtGrpc {
QString url_base;
QString serviceName;
QByteArray nekoray_auth;
// async
QNetworkReply *post(const QString &method, const QString &service, const QByteArray &args) {
QUrl callUrl = url_base + "/" + service + "/" + method;
// qDebug() << "Service call url: " << callUrl;
QNetworkRequest request(callUrl);
// request.setAttribute(QNetworkRequest::CacheSaveControlAttribute, false);
// request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork);
request.setAttribute(QNetworkRequest::Http2DirectAttribute, true);
request.setHeader(QNetworkRequest::ContentTypeHeader, QLatin1String{"application/grpc"});
request.setRawHeader("Cache-Control", "no-store");
request.setRawHeader(GrpcAcceptEncodingHeader, QByteArray{"identity,deflate,gzip"});
request.setRawHeader(AcceptEncodingHeader, QByteArray{"identity,gzip"});
request.setRawHeader(TEHeader, QByteArray{"trailers"});
request.setRawHeader("nekoray_auth", nekoray_auth);
QByteArray msg(GrpcMessageSizeHeaderSize, '\0');
*reinterpret_cast<int *>(msg.data() + 1) = qToBigEndian((int) args.size());
msg += args;
// qDebug() << "SEND: " << msg.size();
QNetworkReply *networkReply = nm->post(request, msg);
return networkReply;
@ -128,8 +119,6 @@ namespace QtGrpc {
auto grpcStatus = QNetworkReply::NetworkError::ProtocolUnknownError;
qByteArray = processReply(networkReply, grpcStatus);
// qDebug() << __func__ << "RECV: " << qByteArray.toHex() << "grpcStatus" << grpcStatus;
// qDebug() << networkReply->rawHeaderPairs();
networkReply->deleteLater();
return grpcStatus;
@ -138,7 +127,6 @@ namespace QtGrpc {
public:
Http2GrpcChannelPrivate(const QString &url_, const QString &nekoray_auth_, const QString &serviceName_) {
url_base = "http://" + url_;
nekoray_auth = nekoray_auth_.toLatin1();
serviceName = serviceName_;
//
thread = new QThread;
@ -237,18 +225,16 @@ namespace NekoGui_rpc {
}
}
long long Client::QueryStats(const std::string &tag, const std::string &direct) {
libcore::QueryStatsReq request;
request.set_tag(tag);
request.set_direct(direct);
libcore::QueryStatsResp Client::QueryStats() {
libcore::EmptyReq request;
libcore::QueryStatsResp reply;
auto status = default_grpc_channel->Call("QueryStats", request, &reply, 500);
if (status == QNetworkReply::NoError) {
return reply.traffic();
return reply;
} else {
return 0;
return {};
}
}

View File

@ -246,28 +246,15 @@ namespace NekoGui {
tagOut = "proxy";
}
// ignoreConnTag
if (index != 0) {
status->result->ignoreConnTag << tagOut;
}
if (index > 0) {
// chain rules: past
if (pastExternalStat == 0) {
auto replaced = status->outbounds.last().toObject();
replaced["detour"] = tagOut;
status->outbounds.removeLast();
status->outbounds += replaced;
} else {
status->routingRules += QJsonObject{
{"inbound", QJsonArray{pastTag + "-mapping"}},
{"outbound", tagOut},
};
}
auto replaced = status->outbounds.last().toObject();
replaced["detour"] = tagOut;
status->outbounds.removeLast();
status->outbounds += replaced;
} else {
// index == 0 means last profile in chain / not chain
chainTagOut = tagOut;
status->result->outboundStat = ent->traffic_data;
}
// Outbound
@ -276,7 +263,6 @@ namespace NekoGui {
BuildOutbound(ent, status, outbound, tagOut);
// apply custom outbound settings
MergeJson(QString2QJsonObject(ent->bean->custom_outbound), outbound);
@ -433,11 +419,12 @@ namespace NekoGui {
auto tagProxy = BuildChain(status->chainID, status);
if (!status->result->error.isEmpty()) return;
// direct & block & dns-out
// direct
status->outbounds += QJsonObject{
{"type", "direct"},
{"tag", "direct"},
};
status->result->outboundStats += std::make_shared<NekoGui_traffic::TrafficData>("direct");
status->outbounds += QJsonObject{
{"type", "block"},
{"tag", "block"},
@ -715,7 +702,7 @@ namespace NekoGui {
// experimental
QJsonObject experimentalObj;
QJsonObject clash_api = {
{"default_mode", "Rule"} // dummy to make sure it is created
{"default_mode", ""} // dummy to make sure it is created
};
if (!status->forTest)

View File

@ -46,7 +46,7 @@ namespace NekoGui {
rule_set << other.rule_set;
invert = other.invert;
outboundID = other.outboundID;
actionType = other.actionType;
action = other.action;
rejectMethod = other.rejectMethod;
no_drop = other.no_drop;
override_address = other.override_address;
@ -78,7 +78,7 @@ namespace NekoGui {
_add(new configItem("rule_set", &rule_set, itemType::stringList));
_add(new configItem("invert", &invert, itemType::boolean));
_add(new configItem("outboundID", &outboundID, itemType::integer));
_add(new configItem("actionType", &actionType, itemType::string));
_add(new configItem("actionType", &action, itemType::string));
_add(new configItem("rejectMethod", &rejectMethod, itemType::string));
_add(new configItem("noDrop", &no_drop, itemType::boolean));
_add(new configItem("override_address", &override_address, itemType::string));
@ -113,24 +113,24 @@ namespace NekoGui {
if (isValidStrArray(rule_set)) obj["rule_set"] = get_as_array(rule_set);
if (invert) obj["invert"] = invert;
// fix action type
if (actionType == "route")
if (action == "route")
{
if (outboundID == -3) actionType = "reject";
if (outboundID == -4) actionType = "resolve";
if (outboundID == -3) action = "reject";
if (outboundID == -4) action = "hijack-dns";
}
obj["action_type"] = actionType;
obj["action"] = action;
if (actionType == "reject")
if (action == "reject")
{
if (!rejectMethod.isEmpty()) obj["reject_method"] = rejectMethod;
if (no_drop) obj["no_drop"] = no_drop;
}
if (actionType == "route" || actionType == "route-options")
if (action == "route" || action == "route-options")
{
if (!override_address.isEmpty()) obj["override_address"] = override_address;
if (override_port.toInt() > 0) obj["override_port"] = override_port.toInt();
if (actionType == "route")
if (action == "route")
{
if (forView) {
switch (outboundID) { // TODO use constants
@ -154,12 +154,12 @@ namespace NekoGui {
}
}
}
if (actionType == "sniff")
if (action == "sniff")
{
if (isValidStrArray(sniffers)) obj["sniffers"] = get_as_array(sniffers);
if (sniffOverrideDest) obj["override_destination"] = sniffOverrideDest;
}
if (actionType == "resolve")
if (action == "resolve")
{
if (!strategy.isEmpty()) obj["strategy"] = strategy;
}
@ -192,7 +192,7 @@ namespace NekoGui {
"process_path_regex",
"rule_set",
"invert",
"action_type",
"action",
"outbound",
"override_address",
"override_port",
@ -213,7 +213,7 @@ namespace NekoGui {
if (fieldName == "ip_version" ||
fieldName == "network" ||
fieldName == "protocol" ||
fieldName == "action_type" ||
fieldName == "action" ||
fieldName == "method" ||
fieldName == "strategy" ||
fieldName == "outbound") return select;
@ -233,7 +233,7 @@ namespace NekoGui {
resp.prepend("");
return resp;
}
if (fieldName == "action_type")
if (fieldName == "action")
{
return Preset::SingBox::ActionTypes;
}
@ -262,9 +262,9 @@ namespace NekoGui {
if (fieldName == "protocol") {
return {protocol};
}
if (fieldName == "action_type")
if (fieldName == "action")
{
return {actionType};
return {action};
}
if (fieldName == "method")
{
@ -398,9 +398,9 @@ namespace NekoGui {
if (fieldName == "invert") {
invert = value[0]=="true";
}
if (fieldName == "action_type")
if (fieldName == "action")
{
actionType = value[0];
action = value[0];
}
if (fieldName == "method")
{
@ -429,7 +429,10 @@ namespace NekoGui {
}
bool RouteRule::isEmpty() {
return get_rule_json().keys().length() == 1;
auto ruleJson = get_rule_json();
if (action == "route" || action == "route-options" || action == "hijack-dns") return ruleJson.keys().length() <= 1;
if (action == "sniff" || action == "resolve" || action == "reject") return ruleJson.keys().length() < 1;
return false;
}
bool isOutboundIDValid(int id) {
@ -536,7 +539,8 @@ namespace NekoGui {
defaultChain->name = "Default";
auto defaultRule = std::make_shared<RouteRule>();
defaultRule->name = "Route DNS";
defaultRule->actionType = "hijack-dns";
defaultRule->action = "hijack-dns";
defaultRule->protocol = "dns";
defaultChain->Rules << defaultRule;
return defaultChain;
}
@ -549,7 +553,8 @@ namespace NekoGui {
auto rule0 = std::make_shared<RouteRule>();
rule0->name = "Route DNS";
rule0->actionType = "hijack-dns";
rule0->action = "hijack-dns";
rule0->protocol = "dns";
chain->Rules << rule0;
auto rule1 = std::make_shared<RouteRule>();
@ -575,7 +580,8 @@ namespace NekoGui {
auto rule0 = std::make_shared<RouteRule>();
rule0->name = "Route DNS";
rule0->actionType = "hijack-dns";
rule0->action = "hijack-dns";
rule0->protocol = "dns";
chain->Rules << rule0;
auto rule1 = std::make_shared<RouteRule>();

View File

@ -1,5 +1,5 @@
#include <QThread>
#include <core/cmd/nekobox_core/server/gen/libcore.pb.h>
#include <core/server/gen/libcore.pb.h>
#include <include/api/gRPC.h>
#include "include/ui/mainwindow_interface.h"
#include <include/stats/connections/connectionLister.hpp>

View File

@ -4,8 +4,6 @@
#include "include/ui/mainwindow_interface.h"
#include <QThread>
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonDocument>
#include <QElapsedTimer>
@ -14,59 +12,37 @@ namespace NekoGui_traffic {
TrafficLooper *trafficLooper = new TrafficLooper;
QElapsedTimer elapsedTimer;
TrafficData *TrafficLooper::update_stats(TrafficData *item) {
if (NekoGui::dataStore->disable_traffic_stats) {
return nullptr;
}
// last update
auto now = elapsedTimer.elapsed();
auto interval = now - item->last_update;
item->last_update = now;
if (interval <= 0) return nullptr;
// query
auto uplink = NekoGui_rpc::defaultClient->QueryStats(item->tag, "uplink");
auto downlink = NekoGui_rpc::defaultClient->QueryStats(item->tag, "downlink");
// add diff
item->downlink += downlink;
item->uplink += uplink;
item->downlink_rate = downlink * 1000 / interval;
item->uplink_rate = uplink * 1000 / interval;
// return diff
auto ret = new TrafficData(item->tag);
ret->downlink = downlink;
ret->uplink = uplink;
ret->downlink_rate = item->downlink_rate;
ret->uplink_rate = item->uplink_rate;
return ret;
}
void TrafficLooper::UpdateAll() {
if (NekoGui::dataStore->disable_traffic_stats) {
return;
}
std::map<std::string, TrafficData *> updated; // tag to diff
auto resp = NekoGui_rpc::defaultClient->QueryStats();
proxy->uplink_rate = 0;
proxy->downlink_rate = 0;
for (const auto &item: this->items) {
auto data = item.get();
auto diff = updated[data->tag];
// 避免重复查询一个 outbound tag
if (diff == nullptr) {
diff = update_stats(data);
updated[data->tag] = diff;
} else {
data->uplink += diff->uplink;
data->downlink += diff->downlink;
data->uplink_rate = diff->uplink_rate;
data->downlink_rate = diff->downlink_rate;
if (!resp.ups().contains(item->tag)) continue;
auto now = elapsedTimer.elapsed();
auto interval = now - item->last_update;
item->last_update = now;
if (interval <= 0) continue;
auto up = resp.ups().at(item->tag);
auto down = resp.downs().at(item->tag);
item->uplink += up;
item->downlink += down;
item->uplink_rate = up * 1000 / interval;
item->downlink_rate = down * 1000 / interval;
if (item->tag == "direct")
{
direct->uplink_rate = item->uplink_rate;
direct->downlink_rate = item->downlink_rate;
} else
{
proxy->uplink_rate += item->uplink_rate;
proxy->downlink_rate += item->downlink_rate;
}
}
updated[direct->tag] = update_stats(direct);
//
for (const auto &pair: updated) {
delete pair.second;
}
}
void TrafficLooper::Loop() {

View File

@ -36,7 +36,7 @@ namespace NekoGui_sys {
connect(this, &QProcess::readyReadStandardOutput, this, [&]() {
auto log = readAllStandardOutput();
if (!NekoGui::dataStore->core_running) {
if (log.contains("grpc server listening")) {
if (log.contains("Core listening at")) {
// The core really started
NekoGui::dataStore->core_running = true;
if (start_profile_when_core_is_up >= 0) {

View File

@ -249,10 +249,6 @@ void MainWindow::neko_start(int _id) {
libcore::LoadConfigReq req;
req.set_core_config(QJsonObject2QString(result->coreConfig, true).toStdString());
req.set_disable_stats(NekoGui::dataStore->disable_traffic_stats);
if (NekoGui::dataStore->traffic_loop_interval > 0) {
req.add_stats_outbounds("proxy");
req.add_stats_outbounds("direct");
}
//
bool rpcOK;
QString error = defaultClient->Start(&rpcOK, req);
@ -276,9 +272,9 @@ void MainWindow::neko_start(int _id) {
return false;
}
//
NekoGui_traffic::trafficLooper->proxy = result->outboundStat.get();
NekoGui_traffic::trafficLooper->proxy = std::make_shared<NekoGui_traffic::TrafficData>("proxy");
NekoGui_traffic::trafficLooper->direct = std::make_shared<NekoGui_traffic::TrafficData>("direct");
NekoGui_traffic::trafficLooper->items = result->outboundStats;
NekoGui::dataStore->ignoreConnTag = result->ignoreConnTag;
NekoGui_traffic::trafficLooper->loop_enabled = true;
NekoGui_traffic::connection_lister->suspend = false;
@ -411,6 +407,7 @@ void MainWindow::neko_stop(bool crash, bool sem, bool manual) {
if (NekoGui::dataStore->traffic_loop_interval != 0) {
NekoGui_traffic::trafficLooper->UpdateAll();
for (const auto &item: NekoGui_traffic::trafficLooper->items) {
if (item->id < 0) continue;
NekoGui::profileManager->GetProfile(item->id)->Save();
refresh_proxy_list(item->id);
}

View File

@ -59,7 +59,7 @@ RouteItem::RouteItem(QWidget *parent, const std::shared_ptr<NekoGui::RoutingChai
auto routeItem = std::make_shared<NekoGui::RouteRule>();
routeItem->name = "dns-hijack";
routeItem->protocol = "dns";
routeItem->actionType = "hijack-dns";
routeItem->action = "hijack-dns";
chain->Rules << routeItem;
}