diff options
author | Vadim Kochan <vadim4j@gmail.com> | 2015-10-27 11:43:29 +0100 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2015-10-27 11:43:29 +0100 |
commit | 7b24d95cffcf889c59b5e6706cddb53b26b6aa69 (patch) | |
tree | a89b09d3412ac6658be81ea5df9e0b7648a60d62 | |
parent | 830ba03c8a52c5a158e94cba463a3ccaf0e6b62f (diff) |
flowtop: Add command-line option to disable GeoIP lookup
Add option -G,--no-geoip which allows to disable GeoIP lookup.
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
[tk: Minor wording tweaks]
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
-rw-r--r-- | flowtop.8 | 4 | ||||
-rw-r--r-- | flowtop.c | 19 |
2 files changed, 18 insertions, 5 deletions
@@ -107,6 +107,10 @@ Display SCTP flows. Don't perform hostname lookup. Only numeric addresses will be shown for flow endpoints. .PP +.SS -G, --no-geoip +Don't perform GeoIP lookup. No geographical information will be shown for flow +endpoints. +.PP .SS -s, --show-src Also show source information of the flow, not only destination information. .PP @@ -112,8 +112,9 @@ static struct sysctl_params_ctx sysctl = { -1, -1 }; static unsigned int interval = 1; static bool resolve_dns = true; +static bool resolve_geoip = true; -static const char *short_options = "vhTUsDIS46ut:n"; +static const char *short_options = "vhTUsDIS46ut:nG"; static const struct option long_options[] = { {"ipv4", no_argument, NULL, '4'}, {"ipv6", no_argument, NULL, '6'}, @@ -123,6 +124,7 @@ static const struct option long_options[] = { {"icmp", no_argument, NULL, 'I'}, {"sctp", no_argument, NULL, 'S'}, {"no-dns", no_argument, NULL, 'n'}, + {"no-geoip", no_argument, NULL, 'G'}, {"show-src", no_argument, NULL, 's'}, {"update", no_argument, NULL, 'u'}, {"interval", required_argument, NULL, 't'}, @@ -698,8 +700,10 @@ flow_entry_geo_country_lookup_generic(struct flow_entry *n, static void flow_entry_get_extended_geo(struct flow_entry *n, enum flow_entry_direction dir) { - flow_entry_geo_city_lookup_generic(n, dir); - flow_entry_geo_country_lookup_generic(n, dir); + if (resolve_geoip) { + flow_entry_geo_city_lookup_generic(n, dir); + flow_entry_geo_country_lookup_generic(n, dir); + } } static void flow_entry_get_extended_revdns(struct flow_entry *n, @@ -1542,6 +1546,9 @@ int main(int argc, char **argv) case 'n': resolve_dns = false; break; + case 'G': + resolve_geoip = false; + break; case 'h': help(); break; @@ -1572,7 +1579,8 @@ int main(int argc, char **argv) conntrack_acct_enable(); conntrack_tstamp_enable(); - init_geoip(1); + if (resolve_geoip) + init_geoip(1); ret = pthread_create(&tid, NULL, collector, NULL); if (ret < 0) @@ -1580,7 +1588,8 @@ int main(int argc, char **argv) presenter(); - destroy_geoip(); + if (resolve_geoip) + destroy_geoip(); restore_sysctl(&sysctl); |