Skip to content

Commit 4cb900d

Browse files
committed
Added district, asn, and as fields.
1 parent 95e7272 commit 4cb900d

File tree

8 files changed

+179
-88
lines changed

8 files changed

+179
-88
lines changed

Developers_Guide.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ When IP2Location_clear_memory() function is called, and if any other process(es)
7272
After calling IP2Location_clear_memory(), the next call to IP2Location_set_lookup_mode() with IP2LOCATION_SHARED_MEMORY option will result in a new shared memory and will not reuse the old one if one exists and used by any other process. Please refer shm_open and shm_unlink man pages for more info.
7373

7474

75-
Version 8.5.1 07/14/2022
75+
Version 8.6.0 06/02/2023

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AC_PREREQ(2.59)
2-
AC_INIT([IP2Loc], [8.5.1], [[email protected]])
2+
AC_INIT([IP2Loc], [8.6.0], [[email protected]])
33
AM_INIT_AUTOMAKE([ subdir-objects ])
44

55
AM_CONFIG_HEADER([config.h])

contrib/IP2Location.spec

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
%define version 8.5.1
1+
%define version 8.6.0
22

33
Name: IP2Location
44
Summary: C library for mapping IP address to geolocation information
@@ -122,6 +122,9 @@ install -p data/IPV6-COUNTRY.BIN %{buildroot}%{_datadir}/%{name}/IPV6-COUNTRY.SA
122122

123123

124124
%changelog
125+
* Thu Jun 02 2023 IP2Location <[email protected]> - 8.6.0
126+
- added district, asn, and as fields
127+
125128
* Thu Jul 14 2022 IP2Location <[email protected]> - 8.5.1
126129
- fixed wrong offset for memory modes
127130

contrib/IP2Location.spec.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ install -p data/IPV6-COUNTRY.BIN %{buildroot}%{_datadir}/%{name}/IPV6-COUNTRY.SA
122122

123123

124124
%changelog
125+
* Thu Jun 02 2023 IP2Location <[email protected]> - 8.6.0
126+
- added district, asn, and as fields
127+
125128
* Thu Jul 14 2022 IP2Location <[email protected]> - 8.5.1
126129
- fixed wrong offset for memory modes
127130

ip2location.1

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ip2location \- query IP address information from local IP2Location BIN data file
44

55
.SH SYNOPSIS
66
ip2location \-\-data-file [IP2LOCATION BIN DATA PATH] \-\-ip [IP ADDRESS] [OPTIONS]
7-
7+
88
.SH DESCRIPTION
99
.PP
1010
ip2location read the IP address, IPv4 or IPv6 address format, and get the information from IP2Location BIN data file for display.
@@ -31,7 +31,7 @@ Query an IP address and display the country_short result
3131
.TP
3232
ip2location \-\-data-file [IP2LOCATION BIN DATA PATH] \-\-ip [IP ADDRESS] \-\-field country_code,city_name \-\no-heading \-\-format TAB
3333
Query an IP address and display the country_short and city result
34-
34+
3535
.SH OPTIONS
3636
\-b, \-\-bin-version
3737
Print the IP2Location BIN database version.
@@ -42,25 +42,25 @@ Query an IP address and display the country_short and city result
4242
\-i, \-\-input-file
4343
Specify an input file with IP address list.
4444

45-
\-p, \-\-ip
45+
\-p, \-\-ip
4646
Specify an IP address query (Supported IPv4 and IPv6 address).
4747

48-
\-o, \-\-output-file
48+
\-o, \-\-output-file
4949
Specify output file for query results.
5050

51-
\-f, \-\-format
51+
\-f, \-\-format
5252
Specify output format. Supported formats are:
5353
\- CSV (default)
5454
\- TAB
5555
\- XML
56-
57-
\-h, \-?, \-\-help
56+
57+
\-h, \-?, \-\-help
5858
Display this help file
5959

60-
\-v, \-\-version
60+
\-v, \-\-version
6161
Display the version number
6262

63-
\-e, \-\-field
63+
\-e, \-\-field
6464
Specify the field to be displayed. Supported values are:
6565
\- ip
6666
\- country_code
@@ -83,16 +83,19 @@ Query an IP address and display the country_short and city result
8383
\- mobile_brand
8484
\- elevation
8585
\- usage_type
86-
\- address_type
87-
\- category
88-
89-
\-n, \-\no-heading
86+
\- address_type
87+
\- category
88+
\- district
89+
\- asn
90+
\- as
91+
92+
\-n, \-\no-heading
9093
Suppress the heading display.
91-
94+
9295
.SH [AUTHORS]
93-
This tool was created by IP2Location (http://www.ip2location.com).
94-
96+
This tool was created by IP2Location (https://www.ip2location.com).
97+
9598
.SH [COPYRIGHT AND LICENSE]
96-
Copyright 2001\-2021 IP2Location.com
99+
Copyright 2001\-2023 IP2Location.com
97100

98101
This tool is licensed under MIT.

ip2location.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ static void print_usage(const char *argv0)
8181
" category\n"
8282
" The domain category is based on IAB Tech Lab Content Taxonomy.\n"
8383
"\n"
84+
" district\n"
85+
" District or county name.\n"
86+
"\n"
87+
" as_number\n"
88+
" Autonomous system number (ASN).\n"
89+
"\n"
90+
" as_name\n"
91+
" Autonomous system (AS) name.\n"
92+
"\n"
8493
" -f, --format\n"
8594
" Output format. Supported format:\n"
8695
" - csv (default)\n"
@@ -108,7 +117,7 @@ static void print_usage(const char *argv0)
108117

109118
static void print_version()
110119
{
111-
printf("IP2Location version 8.0.0\n");
120+
printf("IP2Location version 8.6.0\n");
112121
}
113122

114123
static void print_footer(FILE *fout, const char *field, const char *format)
@@ -173,6 +182,9 @@ static void print_header(FILE *fout, const char *field, const char *format)
173182
WRITE_HEADER("usage_type");
174183
WRITE_HEADER("address_type");
175184
WRITE_HEADER("category");
185+
WRITE_HEADER("district");
186+
WRITE_HEADER("as_number");
187+
WRITE_HEADER("as_name");
176188

177189
if (*end == ',') {
178190
start = end + 1;
@@ -263,6 +275,9 @@ static void print_record(FILE *fout, const char *field, IP2LocationRecord *recor
263275
WRITE_FIELD("usage_type", record->usagetype);
264276
WRITE_FIELD("address_type", record->address_type);
265277
WRITE_FIELD("category", record->category);
278+
WRITE_FIELD("district", record->district);
279+
WRITE_FIELD("as_number", record->asn);
280+
WRITE_FIELD("as_name", record->as);
266281

267282
if (*end == ',') {
268283
start = end + 1;
@@ -293,7 +308,7 @@ int main(int argc, char *argv[])
293308
IP2LocationRecord *record = NULL;
294309
FILE *fout = stdout;
295310

296-
field = "ip,country_code,country_name,region_name,city_name,isp,latitude,longitude,domain,zip_code,time_zone,net_speed,idd_code,area_code,weather_station_code,weather_station_name,mcc,mnc,mobile_brand,elevation,usage_type,address_type,category";
311+
field = "ip,country_code,country_name,region_name,city_name,isp,latitude,longitude,domain,zip_code,time_zone,net_speed,idd_code,area_code,weather_station_code,weather_station_name,mcc,mnc,mobile_brand,elevation,usage_type,address_type,category,district,as_number,as_name";
297312

298313
for (i = 1; i < argc; i++) {
299314
const char *argvi = argv[i];
@@ -344,7 +359,7 @@ int main(int argc, char *argv[])
344359
fprintf(stderr, "Datafile is absent\n");
345360
exit(-1);
346361
}
347-
362+
348363
obj = IP2Location_open((char *)data_file);
349364
if (obj == NULL) {
350365
fprintf(stderr, "Failed to open BIN database %s\n", data_file);
@@ -403,7 +418,7 @@ int main(int argc, char *argv[])
403418
if (!no_heading) {
404419
print_footer(fout, field, format);
405420
}
406-
421+
407422
IP2Location_close(obj);
408423

409424
return 0;

0 commit comments

Comments
 (0)