mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-11 19:04:35 +00:00
add continent to ip service
This commit is contained in:
@@ -7,9 +7,10 @@
|
|||||||
},
|
},
|
||||||
"response": {
|
"response": {
|
||||||
"ip": "93.148.214.31",
|
"ip": "93.148.214.31",
|
||||||
"asn": "30722",
|
"asn": 30722,
|
||||||
"city": "Reggiolo",
|
"city": "Reggiolo",
|
||||||
"country": "Italy",
|
"country": "Italy",
|
||||||
|
"continent": "Europe",
|
||||||
"latitude": 44.9201,
|
"latitude": 44.9201,
|
||||||
"longitude": 10.8075,
|
"longitude": 10.8075,
|
||||||
"timezone": "Europe/Rome"
|
"timezone": "Europe/Rome"
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ func (i *Ip) Lookup(ctx context.Context, req *pb.LookupRequest, rsp *pb.LookupRe
|
|||||||
return errors.InternalServerError("ip.lookup", "failed to lookup ip")
|
return errors.InternalServerError("ip.lookup", "failed to lookup ip")
|
||||||
}
|
}
|
||||||
// set asp
|
// set asp
|
||||||
rsp.Asn = int64(asn.AutonomousSystemNumber)
|
rsp.Asn = int32(asn.AutonomousSystemNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
info, err := i.CityReader.City(ip)
|
info, err := i.CityReader.City(ip)
|
||||||
@@ -46,6 +46,8 @@ func (i *Ip) Lookup(ctx context.Context, req *pb.LookupRequest, rsp *pb.LookupRe
|
|||||||
rsp.City = info.City.Names["en"]
|
rsp.City = info.City.Names["en"]
|
||||||
// set countr
|
// set countr
|
||||||
rsp.Country = info.Country.Names["en"]
|
rsp.Country = info.Country.Names["en"]
|
||||||
|
// set continent
|
||||||
|
rsp.Continent = info.Continent.Names["en"]
|
||||||
// latitude/longitude
|
// latitude/longitude
|
||||||
rsp.Latitude = info.Location.Latitude
|
rsp.Latitude = info.Location.Latitude
|
||||||
rsp.Longitude = info.Location.Longitude
|
rsp.Longitude = info.Location.Longitude
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ type LookupRequest struct {
|
|||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
// IP to lookup
|
||||||
Ip string `protobuf:"bytes,1,opt,name=ip,proto3" json:"ip,omitempty"`
|
Ip string `protobuf:"bytes,1,opt,name=ip,proto3" json:"ip,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,13 +74,22 @@ type LookupResponse struct {
|
|||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
Ip string `protobuf:"bytes,1,opt,name=ip,proto3" json:"ip,omitempty"`
|
// IP of the query
|
||||||
Asn int64 `protobuf:"varint,2,opt,name=asn,proto3" json:"asn,omitempty"`
|
Ip string `protobuf:"bytes,1,opt,name=ip,proto3" json:"ip,omitempty"`
|
||||||
City string `protobuf:"bytes,3,opt,name=city,proto3" json:"city,omitempty"`
|
// Autonomous system number
|
||||||
Country string `protobuf:"bytes,4,opt,name=country,proto3" json:"country,omitempty"`
|
Asn int32 `protobuf:"varint,2,opt,name=asn,proto3" json:"asn,omitempty"`
|
||||||
Latitude float64 `protobuf:"fixed64,5,opt,name=latitude,proto3" json:"latitude,omitempty"`
|
// Name of the city
|
||||||
Longitude float64 `protobuf:"fixed64,6,opt,name=longitude,proto3" json:"longitude,omitempty"`
|
City string `protobuf:"bytes,3,opt,name=city,proto3" json:"city,omitempty"`
|
||||||
Timezone string `protobuf:"bytes,7,opt,name=timezone,proto3" json:"timezone,omitempty"`
|
// Name of the country
|
||||||
|
Country string `protobuf:"bytes,4,opt,name=country,proto3" json:"country,omitempty"`
|
||||||
|
// Name of the continent
|
||||||
|
Continent string `protobuf:"bytes,5,opt,name=continent,proto3" json:"continent,omitempty"`
|
||||||
|
// Latitude e.g 52.523219
|
||||||
|
Latitude float64 `protobuf:"fixed64,6,opt,name=latitude,proto3" json:"latitude,omitempty"`
|
||||||
|
// Longitude e.g 13.428555
|
||||||
|
Longitude float64 `protobuf:"fixed64,7,opt,name=longitude,proto3" json:"longitude,omitempty"`
|
||||||
|
// Timezone e.g Europe/Rome
|
||||||
|
Timezone string `protobuf:"bytes,8,opt,name=timezone,proto3" json:"timezone,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *LookupResponse) Reset() {
|
func (x *LookupResponse) Reset() {
|
||||||
@@ -121,7 +131,7 @@ func (x *LookupResponse) GetIp() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *LookupResponse) GetAsn() int64 {
|
func (x *LookupResponse) GetAsn() int32 {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Asn
|
return x.Asn
|
||||||
}
|
}
|
||||||
@@ -142,6 +152,13 @@ func (x *LookupResponse) GetCountry() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *LookupResponse) GetContinent() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Continent
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func (x *LookupResponse) GetLatitude() float64 {
|
func (x *LookupResponse) GetLatitude() float64 {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Latitude
|
return x.Latitude
|
||||||
@@ -169,23 +186,25 @@ var file_proto_ip_proto_rawDesc = []byte{
|
|||||||
0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x69, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x69, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||||
0x12, 0x02, 0x69, 0x70, 0x22, 0x1f, 0x0a, 0x0d, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65,
|
0x12, 0x02, 0x69, 0x70, 0x22, 0x1f, 0x0a, 0x0d, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65,
|
||||||
0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28,
|
0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||||
0x09, 0x52, 0x02, 0x69, 0x70, 0x22, 0xb6, 0x01, 0x0a, 0x0e, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70,
|
0x09, 0x52, 0x02, 0x69, 0x70, 0x22, 0xd4, 0x01, 0x0a, 0x0e, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70,
|
||||||
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x01,
|
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x01,
|
||||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x73, 0x6e, 0x18,
|
0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x73, 0x6e, 0x18,
|
||||||
0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x61, 0x73, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x69,
|
0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x61, 0x73, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x69,
|
||||||
0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x69, 0x74, 0x79, 0x12, 0x18,
|
0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x69, 0x74, 0x79, 0x12, 0x18,
|
||||||
0x0a, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52,
|
0x0a, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||||
0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x6c, 0x61, 0x74, 0x69,
|
0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6f, 0x6e, 0x74,
|
||||||
0x74, 0x75, 0x64, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x01, 0x52, 0x08, 0x6c, 0x61, 0x74, 0x69,
|
0x69, 0x6e, 0x65, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x6f, 0x6e,
|
||||||
0x74, 0x75, 0x64, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6c, 0x6f, 0x6e, 0x67, 0x69, 0x74, 0x75, 0x64,
|
0x74, 0x69, 0x6e, 0x65, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x6c, 0x61, 0x74, 0x69, 0x74, 0x75,
|
||||||
0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x01, 0x52, 0x09, 0x6c, 0x6f, 0x6e, 0x67, 0x69, 0x74, 0x75,
|
0x64, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x01, 0x52, 0x08, 0x6c, 0x61, 0x74, 0x69, 0x74, 0x75,
|
||||||
0x64, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x69, 0x6d, 0x65, 0x7a, 0x6f, 0x6e, 0x65, 0x18, 0x07,
|
0x64, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6c, 0x6f, 0x6e, 0x67, 0x69, 0x74, 0x75, 0x64, 0x65, 0x18,
|
||||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x69, 0x6d, 0x65, 0x7a, 0x6f, 0x6e, 0x65, 0x32, 0x37,
|
0x07, 0x20, 0x01, 0x28, 0x01, 0x52, 0x09, 0x6c, 0x6f, 0x6e, 0x67, 0x69, 0x74, 0x75, 0x64, 0x65,
|
||||||
0x0a, 0x02, 0x49, 0x70, 0x12, 0x31, 0x0a, 0x06, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x12, 0x11,
|
0x12, 0x1a, 0x0a, 0x08, 0x74, 0x69, 0x6d, 0x65, 0x7a, 0x6f, 0x6e, 0x65, 0x18, 0x08, 0x20, 0x01,
|
||||||
0x2e, 0x69, 0x70, 0x2e, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
|
0x28, 0x09, 0x52, 0x08, 0x74, 0x69, 0x6d, 0x65, 0x7a, 0x6f, 0x6e, 0x65, 0x32, 0x37, 0x0a, 0x02,
|
||||||
0x74, 0x1a, 0x12, 0x2e, 0x69, 0x70, 0x2e, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x73,
|
0x49, 0x70, 0x12, 0x31, 0x0a, 0x06, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x12, 0x11, 0x2e, 0x69,
|
||||||
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x0c, 0x5a, 0x0a, 0x2e, 0x2f, 0x70, 0x72, 0x6f,
|
0x70, 0x2e, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
|
||||||
0x74, 0x6f, 0x3b, 0x69, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x12, 0x2e, 0x69, 0x70, 0x2e, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f,
|
||||||
|
0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x0c, 0x5a, 0x0a, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||||
|
0x3b, 0x69, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -18,16 +18,18 @@ message LookupResponse {
|
|||||||
// IP of the query
|
// IP of the query
|
||||||
string ip = 1;
|
string ip = 1;
|
||||||
// Autonomous system number
|
// Autonomous system number
|
||||||
int64 asn = 2;
|
int32 asn = 2;
|
||||||
// Name of the city
|
// Name of the city
|
||||||
string city = 3;
|
string city = 3;
|
||||||
// Name of the country
|
// Name of the country
|
||||||
string country = 4;
|
string country = 4;
|
||||||
|
// Name of the continent
|
||||||
|
string continent = 5;
|
||||||
// Latitude e.g 52.523219
|
// Latitude e.g 52.523219
|
||||||
double latitude = 5;
|
double latitude = 6;
|
||||||
// Longitude e.g 13.428555
|
// Longitude e.g 13.428555
|
||||||
double longitude = 6;
|
double longitude = 7;
|
||||||
// Timezone e.g Europe/Rome
|
// Timezone e.g Europe/Rome
|
||||||
string timezone = 7;
|
string timezone = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user