Added option -G,--no-geoip to disable GeoIP lookup.

Signed-off-by: Vadim Kochan <vadi...@gmail.com>
---
 flowtop.8 |  3 +++
 flowtop.c | 17 ++++++++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/flowtop.8 b/flowtop.8
index 8feb1c0..3f3f0f1 100644
--- a/flowtop.8
+++ b/flowtop.8
@@ -120,6 +120,9 @@ Flow info refresh interval in seconds, default is 1s.
 .SS -n, --no-dns
 Do not perform hostname lookup
 .PP
+.SS -G, --no-geoip
+Do not perform country & city lookup by GeoIP
+.PP
 .SS -v, --version
 Show version information and exit.
 .PP
diff --git a/flowtop.c b/flowtop.c
index 5848264..c5e3cc9 100644
--- a/flowtop.c
+++ b/flowtop.c
@@ -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'},
@@ -126,6 +127,7 @@ static const struct option long_options[] = {
        {"update",      no_argument,            NULL, 'u'},
        {"interval",    required_argument,      NULL, 't'},
        {"no-dns",      no_argument,            NULL, 'n'},
+       {"no-geoip",    no_argument,            NULL, 'G'},
        {"version",     no_argument,            NULL, 'v'},
        {"help",        no_argument,            NULL, 'h'},
        {NULL, 0, NULL, 0}
@@ -260,6 +262,7 @@ static void help(void)
             "  -u|--update            Update GeoIP databases\n"
             "  -t|--interval <time>   Refresh time in seconds (default 1s)\n"
             "  -n|--no-dns            Do not perform hostname lookup\n"
+            "  -G|--no-geoip          Do not perform country & city lookup by 
GeoIP\n"
             "  -v|--version           Print version and exit\n"
             "  -h|--help              Print this help and exit\n\n"
             "Examples:\n"
@@ -698,6 +701,9 @@ 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)
 {
+       if (!resolve_geoip)
+               return;
+
        flow_entry_geo_city_lookup_generic(n, dir);
        flow_entry_geo_country_lookup_generic(n, dir);
 }
@@ -1542,6 +1548,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 +1581,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 +1590,8 @@ int main(int argc, char **argv)
 
        presenter();
 
-       destroy_geoip();
+       if (resolve_geoip)
+               destroy_geoip();
 
        restore_sysctl(&sysctl);
 
-- 
2.6.1

-- 
You received this message because you are subscribed to the Google Groups 
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to netsniff-ng+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to