增加批量查询IP信息API

This commit is contained in:
刘祥超
2021-01-13 17:00:24 +08:00
parent 0275c6da26
commit 89d5ccdf12
2 changed files with 281 additions and 75 deletions

View File

@@ -518,7 +518,7 @@ type LookupIPRegionResponse struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Region *IPRegion `protobuf:"bytes,1,opt,name=region,proto3" json:"region,omitempty"`
IpRegion *IPRegion `protobuf:"bytes,1,opt,name=ipRegion,proto3" json:"ipRegion,omitempty"`
}
func (x *LookupIPRegionResponse) Reset() {
@@ -553,9 +553,104 @@ func (*LookupIPRegionResponse) Descriptor() ([]byte, []int) {
return file_service_ip_library_proto_rawDescGZIP(), []int{10}
}
func (x *LookupIPRegionResponse) GetRegion() *IPRegion {
func (x *LookupIPRegionResponse) GetIpRegion() *IPRegion {
if x != nil {
return x.Region
return x.IpRegion
}
return nil
}
// 查询一组IP信息
type LookupIPRegionsRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
IpList []string `protobuf:"bytes,1,rep,name=ipList,proto3" json:"ipList,omitempty"`
}
func (x *LookupIPRegionsRequest) Reset() {
*x = LookupIPRegionsRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_service_ip_library_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *LookupIPRegionsRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*LookupIPRegionsRequest) ProtoMessage() {}
func (x *LookupIPRegionsRequest) ProtoReflect() protoreflect.Message {
mi := &file_service_ip_library_proto_msgTypes[11]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use LookupIPRegionsRequest.ProtoReflect.Descriptor instead.
func (*LookupIPRegionsRequest) Descriptor() ([]byte, []int) {
return file_service_ip_library_proto_rawDescGZIP(), []int{11}
}
func (x *LookupIPRegionsRequest) GetIpList() []string {
if x != nil {
return x.IpList
}
return nil
}
type LookupIPRegionsResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
IpRegionMap map[string]*IPRegion `protobuf:"bytes,1,rep,name=ipRegionMap,proto3" json:"ipRegionMap,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
}
func (x *LookupIPRegionsResponse) Reset() {
*x = LookupIPRegionsResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_service_ip_library_proto_msgTypes[12]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *LookupIPRegionsResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*LookupIPRegionsResponse) ProtoMessage() {}
func (x *LookupIPRegionsResponse) ProtoReflect() protoreflect.Message {
mi := &file_service_ip_library_proto_msgTypes[12]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use LookupIPRegionsResponse.ProtoReflect.Descriptor instead.
func (*LookupIPRegionsResponse) Descriptor() ([]byte, []int) {
return file_service_ip_library_proto_rawDescGZIP(), []int{12}
}
func (x *LookupIPRegionsResponse) GetIpRegionMap() map[string]*IPRegion {
if x != nil {
return x.IpRegionMap
}
return nil
}
@@ -573,12 +668,13 @@ type IPRegion struct {
Isp string `protobuf:"bytes,5,opt,name=isp,proto3" json:"isp,omitempty"`
CountryId int64 `protobuf:"varint,6,opt,name=countryId,proto3" json:"countryId,omitempty"`
ProvinceId int64 `protobuf:"varint,7,opt,name=provinceId,proto3" json:"provinceId,omitempty"`
Summary string `protobuf:"bytes,8,opt,name=summary,proto3" json:"summary,omitempty"` // 完整的地区组合
}
func (x *IPRegion) Reset() {
*x = IPRegion{}
if protoimpl.UnsafeEnabled {
mi := &file_service_ip_library_proto_msgTypes[11]
mi := &file_service_ip_library_proto_msgTypes[13]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -591,7 +687,7 @@ func (x *IPRegion) String() string {
func (*IPRegion) ProtoMessage() {}
func (x *IPRegion) ProtoReflect() protoreflect.Message {
mi := &file_service_ip_library_proto_msgTypes[11]
mi := &file_service_ip_library_proto_msgTypes[13]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -604,7 +700,7 @@ func (x *IPRegion) ProtoReflect() protoreflect.Message {
// Deprecated: Use IPRegion.ProtoReflect.Descriptor instead.
func (*IPRegion) Descriptor() ([]byte, []int) {
return file_service_ip_library_proto_rawDescGZIP(), []int{11}
return file_service_ip_library_proto_rawDescGZIP(), []int{13}
}
func (x *IPRegion) GetCountry() string {
@@ -656,6 +752,13 @@ func (x *IPRegion) GetProvinceId() int64 {
return 0
}
func (x *IPRegion) GetSummary() string {
if x != nil {
return x.Summary
}
return ""
}
var File_service_ip_library_proto protoreflect.FileDescriptor
var file_service_ip_library_proto_rawDesc = []byte{
@@ -705,11 +808,26 @@ var file_service_ip_library_proto_rawDesc = []byte{
0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x69, 0x70, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72,
0x79, 0x49, 0x64, 0x22, 0x27, 0x0a, 0x15, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x49, 0x50, 0x52,
0x65, 0x67, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02,
0x69, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x70, 0x22, 0x3e, 0x0a, 0x16,
0x69, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x70, 0x22, 0x42, 0x0a, 0x16,
0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x49, 0x50, 0x52, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x24, 0x0a, 0x06, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e,
0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x70, 0x62, 0x2e, 0x49, 0x50, 0x52, 0x65,
0x67, 0x69, 0x6f, 0x6e, 0x52, 0x06, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x22, 0xbc, 0x01, 0x0a,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x28, 0x0a, 0x08, 0x69, 0x70, 0x52, 0x65, 0x67, 0x69,
0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x70, 0x62, 0x2e, 0x49, 0x50,
0x52, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x69, 0x70, 0x52, 0x65, 0x67, 0x69, 0x6f, 0x6e,
0x22, 0x30, 0x0a, 0x16, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x49, 0x50, 0x52, 0x65, 0x67, 0x69,
0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x70,
0x4c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x69, 0x70, 0x4c, 0x69,
0x73, 0x74, 0x22, 0xb7, 0x01, 0x0a, 0x17, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x49, 0x50, 0x52,
0x65, 0x67, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4e,
0x0a, 0x0b, 0x69, 0x70, 0x52, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x4d, 0x61, 0x70, 0x18, 0x01, 0x20,
0x03, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x49,
0x50, 0x52, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x2e, 0x49, 0x70, 0x52, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x4d, 0x61, 0x70, 0x45, 0x6e, 0x74, 0x72,
0x79, 0x52, 0x0b, 0x69, 0x70, 0x52, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x4d, 0x61, 0x70, 0x1a, 0x4c,
0x0a, 0x10, 0x49, 0x70, 0x52, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x4d, 0x61, 0x70, 0x45, 0x6e, 0x74,
0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x03, 0x6b, 0x65, 0x79, 0x12, 0x22, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x70, 0x62, 0x2e, 0x49, 0x50, 0x52, 0x65, 0x67, 0x69, 0x6f,
0x6e, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xd6, 0x01, 0x0a,
0x08, 0x49, 0x50, 0x52, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x75,
0x6e, 0x74, 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x75, 0x6e,
0x74, 0x72, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20,
@@ -721,44 +839,50 @@ var file_service_ip_library_proto_rawDesc = []byte{
0x09, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x49, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03,
0x52, 0x09, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x70,
0x72, 0x6f, 0x76, 0x69, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52,
0x0a, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x32, 0xb4, 0x04, 0x0a, 0x10,
0x49, 0x50, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
0x12, 0x4a, 0x0a, 0x0f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x49, 0x50, 0x4c, 0x69, 0x62, 0x72,
0x61, 0x72, 0x79, 0x12, 0x1a, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x49,
0x0a, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x73,
0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x75,
0x6d, 0x6d, 0x61, 0x72, 0x79, 0x32, 0x80, 0x05, 0x0a, 0x10, 0x49, 0x50, 0x4c, 0x69, 0x62, 0x72,
0x61, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x4a, 0x0a, 0x0f, 0x63, 0x72,
0x65, 0x61, 0x74, 0x65, 0x49, 0x50, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x12, 0x1a, 0x2e,
0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x49, 0x50, 0x4c, 0x69, 0x62, 0x72, 0x61,
0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x70, 0x62, 0x2e, 0x43,
0x72, 0x65, 0x61, 0x74, 0x65, 0x49, 0x50, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6e, 0x0a, 0x1b, 0x66, 0x69, 0x6e, 0x64, 0x4c, 0x61,
0x74, 0x65, 0x73, 0x74, 0x49, 0x50, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x57, 0x69, 0x74,
0x68, 0x54, 0x79, 0x70, 0x65, 0x12, 0x26, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x4c,
0x61, 0x74, 0x65, 0x73, 0x74, 0x49, 0x50, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x57, 0x69,
0x74, 0x68, 0x54, 0x79, 0x70, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e,
0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x49, 0x50, 0x4c,
0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x57, 0x69, 0x74, 0x68, 0x54, 0x79, 0x70, 0x65, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x59, 0x0a, 0x14, 0x66, 0x69, 0x6e, 0x64, 0x45, 0x6e,
0x61, 0x62, 0x6c, 0x65, 0x64, 0x49, 0x50, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x12, 0x1f,
0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x49,
0x50, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
0x1b, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x49, 0x50, 0x4c, 0x69, 0x62,
0x72, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6e, 0x0a, 0x1b,
0x66, 0x69, 0x6e, 0x64, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x49, 0x50, 0x4c, 0x69, 0x62, 0x72,
0x61, 0x72, 0x79, 0x57, 0x69, 0x74, 0x68, 0x54, 0x79, 0x70, 0x65, 0x12, 0x26, 0x2e, 0x70, 0x62,
0x2e, 0x46, 0x69, 0x6e, 0x64, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x49, 0x50, 0x4c, 0x69, 0x62,
0x72, 0x61, 0x72, 0x79, 0x57, 0x69, 0x74, 0x68, 0x54, 0x79, 0x70, 0x65, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x4c, 0x61, 0x74,
0x65, 0x73, 0x74, 0x49, 0x50, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x57, 0x69, 0x74, 0x68,
0x54, 0x79, 0x70, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x59, 0x0a, 0x14,
0x66, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x49, 0x50, 0x4c, 0x69, 0x62,
0x72, 0x61, 0x72, 0x79, 0x12, 0x1f, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e,
0x61, 0x62, 0x6c, 0x65, 0x64, 0x49, 0x50, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x45,
0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x49, 0x50, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x80, 0x01, 0x0a, 0x21, 0x66, 0x69, 0x6e, 0x64,
0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x49, 0x50, 0x4c, 0x69, 0x62, 0x72,
0x61, 0x72, 0x69, 0x65, 0x73, 0x57, 0x69, 0x74, 0x68, 0x54, 0x79, 0x70, 0x65, 0x12, 0x2c, 0x2e,
0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65,
0x64, 0x49, 0x50, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x65, 0x73, 0x57, 0x69, 0x74, 0x68,
0x54, 0x79, 0x70, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x70, 0x62,
0x2e, 0x46, 0x69, 0x6e, 0x64, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x49,
0x50, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x65, 0x73, 0x57, 0x69, 0x74, 0x68, 0x54, 0x79,
0x70, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3d, 0x0a, 0x0f, 0x64, 0x65,
0x6c, 0x65, 0x74, 0x65, 0x49, 0x50, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x12, 0x1a, 0x2e,
0x70, 0x62, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x49, 0x50, 0x4c, 0x69, 0x62, 0x72, 0x61,
0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x70, 0x62, 0x2e, 0x52,
0x50, 0x43, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x47, 0x0a, 0x0e, 0x6c, 0x6f, 0x6f,
0x6b, 0x75, 0x70, 0x49, 0x50, 0x52, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x12, 0x19, 0x2e, 0x70, 0x62,
0x2e, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x49, 0x50, 0x52, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x6f, 0x6f, 0x6b,
0x75, 0x70, 0x49, 0x50, 0x52, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
0x20, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64,
0x49, 0x50, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x12, 0x80, 0x01, 0x0a, 0x21, 0x66, 0x69, 0x6e, 0x64, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61,
0x62, 0x6c, 0x65, 0x64, 0x49, 0x50, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x65, 0x73, 0x57,
0x69, 0x74, 0x68, 0x54, 0x79, 0x70, 0x65, 0x12, 0x2c, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e,
0x64, 0x41, 0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x49, 0x50, 0x4c, 0x69, 0x62,
0x72, 0x61, 0x72, 0x69, 0x65, 0x73, 0x57, 0x69, 0x74, 0x68, 0x54, 0x79, 0x70, 0x65, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x41,
0x6c, 0x6c, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x49, 0x50, 0x4c, 0x69, 0x62, 0x72, 0x61,
0x72, 0x69, 0x65, 0x73, 0x57, 0x69, 0x74, 0x68, 0x54, 0x79, 0x70, 0x65, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3d, 0x0a, 0x0f, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x49, 0x50,
0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x12, 0x1a, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x65, 0x6c,
0x65, 0x74, 0x65, 0x49, 0x50, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x53, 0x75, 0x63, 0x63,
0x65, 0x73, 0x73, 0x12, 0x47, 0x0a, 0x0e, 0x6c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x49, 0x50, 0x52,
0x65, 0x67, 0x69, 0x6f, 0x6e, 0x12, 0x19, 0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x6f, 0x6f, 0x6b, 0x75,
0x70, 0x49, 0x50, 0x52, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x1a, 0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x49, 0x50, 0x52, 0x65,
0x67, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4a, 0x0a, 0x0f,
0x6c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x49, 0x50, 0x52, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x73, 0x12,
0x1a, 0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x49, 0x50, 0x52, 0x65, 0x67,
0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x70, 0x62,
0x2e, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x49, 0x50, 0x52, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x73,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -773,7 +897,7 @@ func file_service_ip_library_proto_rawDescGZIP() []byte {
return file_service_ip_library_proto_rawDescData
}
var file_service_ip_library_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
var file_service_ip_library_proto_msgTypes = make([]protoimpl.MessageInfo, 15)
var file_service_ip_library_proto_goTypes = []interface{}{
(*CreateIPLibraryRequest)(nil), // 0: pb.CreateIPLibraryRequest
(*CreateIPLibraryResponse)(nil), // 1: pb.CreateIPLibraryResponse
@@ -786,32 +910,39 @@ var file_service_ip_library_proto_goTypes = []interface{}{
(*DeleteIPLibraryRequest)(nil), // 8: pb.DeleteIPLibraryRequest
(*LookupIPRegionRequest)(nil), // 9: pb.LookupIPRegionRequest
(*LookupIPRegionResponse)(nil), // 10: pb.LookupIPRegionResponse
(*IPRegion)(nil), // 11: pb.IPRegion
(*IPLibrary)(nil), // 12: pb.IPLibrary
(*RPCSuccess)(nil), // 13: pb.RPCSuccess
(*LookupIPRegionsRequest)(nil), // 11: pb.LookupIPRegionsRequest
(*LookupIPRegionsResponse)(nil), // 12: pb.LookupIPRegionsResponse
(*IPRegion)(nil), // 13: pb.IPRegion
nil, // 14: pb.LookupIPRegionsResponse.IpRegionMapEntry
(*IPLibrary)(nil), // 15: pb.IPLibrary
(*RPCSuccess)(nil), // 16: pb.RPCSuccess
}
var file_service_ip_library_proto_depIdxs = []int32{
12, // 0: pb.FindEnabledIPLibraryResponse.ipLibrary:type_name -> pb.IPLibrary
12, // 1: pb.FindLatestIPLibraryWithTypeResponse.ipLibrary:type_name -> pb.IPLibrary
12, // 2: pb.FindAllEnabledIPLibrariesWithTypeResponse.ipLibraries:type_name -> pb.IPLibrary
11, // 3: pb.LookupIPRegionResponse.region:type_name -> pb.IPRegion
0, // 4: pb.IPLibraryService.createIPLibrary:input_type -> pb.CreateIPLibraryRequest
4, // 5: pb.IPLibraryService.findLatestIPLibraryWithType:input_type -> pb.FindLatestIPLibraryWithTypeRequest
2, // 6: pb.IPLibraryService.findEnabledIPLibrary:input_type -> pb.FindEnabledIPLibraryRequest
6, // 7: pb.IPLibraryService.findAllEnabledIPLibrariesWithType:input_type -> pb.FindAllEnabledIPLibrariesWithTypeRequest
8, // 8: pb.IPLibraryService.deleteIPLibrary:input_type -> pb.DeleteIPLibraryRequest
9, // 9: pb.IPLibraryService.lookupIPRegion:input_type -> pb.LookupIPRegionRequest
1, // 10: pb.IPLibraryService.createIPLibrary:output_type -> pb.CreateIPLibraryResponse
5, // 11: pb.IPLibraryService.findLatestIPLibraryWithType:output_type -> pb.FindLatestIPLibraryWithTypeResponse
3, // 12: pb.IPLibraryService.findEnabledIPLibrary:output_type -> pb.FindEnabledIPLibraryResponse
7, // 13: pb.IPLibraryService.findAllEnabledIPLibrariesWithType:output_type -> pb.FindAllEnabledIPLibrariesWithTypeResponse
13, // 14: pb.IPLibraryService.deleteIPLibrary:output_type -> pb.RPCSuccess
10, // 15: pb.IPLibraryService.lookupIPRegion:output_type -> pb.LookupIPRegionResponse
10, // [10:16] is the sub-list for method output_type
4, // [4:10] 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
15, // 0: pb.FindEnabledIPLibraryResponse.ipLibrary:type_name -> pb.IPLibrary
15, // 1: pb.FindLatestIPLibraryWithTypeResponse.ipLibrary:type_name -> pb.IPLibrary
15, // 2: pb.FindAllEnabledIPLibrariesWithTypeResponse.ipLibraries:type_name -> pb.IPLibrary
13, // 3: pb.LookupIPRegionResponse.ipRegion:type_name -> pb.IPRegion
14, // 4: pb.LookupIPRegionsResponse.ipRegionMap:type_name -> pb.LookupIPRegionsResponse.IpRegionMapEntry
13, // 5: pb.LookupIPRegionsResponse.IpRegionMapEntry.value:type_name -> pb.IPRegion
0, // 6: pb.IPLibraryService.createIPLibrary:input_type -> pb.CreateIPLibraryRequest
4, // 7: pb.IPLibraryService.findLatestIPLibraryWithType:input_type -> pb.FindLatestIPLibraryWithTypeRequest
2, // 8: pb.IPLibraryService.findEnabledIPLibrary:input_type -> pb.FindEnabledIPLibraryRequest
6, // 9: pb.IPLibraryService.findAllEnabledIPLibrariesWithType:input_type -> pb.FindAllEnabledIPLibrariesWithTypeRequest
8, // 10: pb.IPLibraryService.deleteIPLibrary:input_type -> pb.DeleteIPLibraryRequest
9, // 11: pb.IPLibraryService.lookupIPRegion:input_type -> pb.LookupIPRegionRequest
11, // 12: pb.IPLibraryService.lookupIPRegions:input_type -> pb.LookupIPRegionsRequest
1, // 13: pb.IPLibraryService.createIPLibrary:output_type -> pb.CreateIPLibraryResponse
5, // 14: pb.IPLibraryService.findLatestIPLibraryWithType:output_type -> pb.FindLatestIPLibraryWithTypeResponse
3, // 15: pb.IPLibraryService.findEnabledIPLibrary:output_type -> pb.FindEnabledIPLibraryResponse
7, // 16: pb.IPLibraryService.findAllEnabledIPLibrariesWithType:output_type -> pb.FindAllEnabledIPLibrariesWithTypeResponse
16, // 17: pb.IPLibraryService.deleteIPLibrary:output_type -> pb.RPCSuccess
10, // 18: pb.IPLibraryService.lookupIPRegion:output_type -> pb.LookupIPRegionResponse
12, // 19: pb.IPLibraryService.lookupIPRegions:output_type -> pb.LookupIPRegionsResponse
13, // [13:20] is the sub-list for method output_type
6, // [6:13] is the sub-list for method input_type
6, // [6:6] is the sub-list for extension type_name
6, // [6:6] is the sub-list for extension extendee
0, // [0:6] is the sub-list for field type_name
}
func init() { file_service_ip_library_proto_init() }
@@ -955,6 +1086,30 @@ func file_service_ip_library_proto_init() {
}
}
file_service_ip_library_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*LookupIPRegionsRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_service_ip_library_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*LookupIPRegionsResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_service_ip_library_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*IPRegion); i {
case 0:
return &v.state
@@ -973,7 +1128,7 @@ func file_service_ip_library_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_service_ip_library_proto_rawDesc,
NumEnums: 0,
NumMessages: 12,
NumMessages: 15,
NumExtensions: 0,
NumServices: 1,
},
@@ -1011,6 +1166,8 @@ type IPLibraryServiceClient interface {
DeleteIPLibrary(ctx context.Context, in *DeleteIPLibraryRequest, opts ...grpc.CallOption) (*RPCSuccess, error)
// 查询某个IP信息
LookupIPRegion(ctx context.Context, in *LookupIPRegionRequest, opts ...grpc.CallOption) (*LookupIPRegionResponse, error)
// 查询一组IP信息
LookupIPRegions(ctx context.Context, in *LookupIPRegionsRequest, opts ...grpc.CallOption) (*LookupIPRegionsResponse, error)
}
type iPLibraryServiceClient struct {
@@ -1075,6 +1232,15 @@ func (c *iPLibraryServiceClient) LookupIPRegion(ctx context.Context, in *LookupI
return out, nil
}
func (c *iPLibraryServiceClient) LookupIPRegions(ctx context.Context, in *LookupIPRegionsRequest, opts ...grpc.CallOption) (*LookupIPRegionsResponse, error) {
out := new(LookupIPRegionsResponse)
err := c.cc.Invoke(ctx, "/pb.IPLibraryService/lookupIPRegions", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// IPLibraryServiceServer is the server API for IPLibraryService service.
type IPLibraryServiceServer interface {
// 创建IP库
@@ -1089,6 +1255,8 @@ type IPLibraryServiceServer interface {
DeleteIPLibrary(context.Context, *DeleteIPLibraryRequest) (*RPCSuccess, error)
// 查询某个IP信息
LookupIPRegion(context.Context, *LookupIPRegionRequest) (*LookupIPRegionResponse, error)
// 查询一组IP信息
LookupIPRegions(context.Context, *LookupIPRegionsRequest) (*LookupIPRegionsResponse, error)
}
// UnimplementedIPLibraryServiceServer can be embedded to have forward compatible implementations.
@@ -1113,6 +1281,9 @@ func (*UnimplementedIPLibraryServiceServer) DeleteIPLibrary(context.Context, *De
func (*UnimplementedIPLibraryServiceServer) LookupIPRegion(context.Context, *LookupIPRegionRequest) (*LookupIPRegionResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method LookupIPRegion not implemented")
}
func (*UnimplementedIPLibraryServiceServer) LookupIPRegions(context.Context, *LookupIPRegionsRequest) (*LookupIPRegionsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method LookupIPRegions not implemented")
}
func RegisterIPLibraryServiceServer(s *grpc.Server, srv IPLibraryServiceServer) {
s.RegisterService(&_IPLibraryService_serviceDesc, srv)
@@ -1226,6 +1397,24 @@ func _IPLibraryService_LookupIPRegion_Handler(srv interface{}, ctx context.Conte
return interceptor(ctx, in, info, handler)
}
func _IPLibraryService_LookupIPRegions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(LookupIPRegionsRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(IPLibraryServiceServer).LookupIPRegions(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/pb.IPLibraryService/LookupIPRegions",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(IPLibraryServiceServer).LookupIPRegions(ctx, req.(*LookupIPRegionsRequest))
}
return interceptor(ctx, in, info, handler)
}
var _IPLibraryService_serviceDesc = grpc.ServiceDesc{
ServiceName: "pb.IPLibraryService",
HandlerType: (*IPLibraryServiceServer)(nil),
@@ -1254,6 +1443,10 @@ var _IPLibraryService_serviceDesc = grpc.ServiceDesc{
MethodName: "lookupIPRegion",
Handler: _IPLibraryService_LookupIPRegion_Handler,
},
{
MethodName: "lookupIPRegions",
Handler: _IPLibraryService_LookupIPRegions_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "service_ip_library.proto",

View File

@@ -25,6 +25,9 @@ service IPLibraryService {
// 查询某个IP信息
rpc lookupIPRegion (LookupIPRegionRequest) returns (LookupIPRegionResponse);
// 查询一组IP信息
rpc lookupIPRegions (LookupIPRegionsRequest) returns (LookupIPRegionsResponse);
}
// 创建IP库
@@ -75,7 +78,16 @@ message LookupIPRegionRequest {
}
message LookupIPRegionResponse {
IPRegion region = 1;
IPRegion ipRegion = 1;
}
// 查询一组IP信息
message LookupIPRegionsRequest {
repeated string ipList = 1;
}
message LookupIPRegionsResponse {
map<string, IPRegion> ipRegionMap = 1;
}
// IP信息
@@ -87,4 +99,5 @@ message IPRegion {
string isp = 5;
int64 countryId = 6;
int64 provinceId = 7;
string summary = 8; // 完整的地区组合
}