--- orig/goaccess-1.2/src/util.h 2017-03-06 20:08:53.000000000 +0100 +++ goaccess-1.2/src/util.h 2017-05-20 07:24:03.421380283 +0200 @@ -77,6 +77,7 @@ int count_matches (const char *s1, char c); int find_output_type (char **filename, const char *ext, int alloc); int ignore_referer (const char *ref); +int ignore_referer_report (const char *ref); int intlen (int num); int invalid_ipaddr (char *str, int *ipvx); int ip_in_range (const char *ip); --- orig/goaccess-1.2/src/settings.h 2017-03-06 20:08:53.000000000 +0100 +++ goaccess-1.2/src/settings.h 2017-05-20 07:23:16.113122935 +0200 @@ -100,6 +100,7 @@ const char *ignore_ips[MAX_IGNORE_IPS]; /* array of ips to ignore */ const char *ignore_panels[TOTAL_MODULES]; /* array of panels to ignore */ const char *ignore_referers[MAX_IGNORE_REF]; /* referrers to ignore */ + const char *ignore_referers_report[MAX_IGNORE_REF]; /* referrers to count as hit, but ignore referrer data */ const char *ignore_status[MAX_IGNORE_STATUS]; /* status to ignore */ const char *output_formats[MAX_OUTFORMATS]; /* output format, e.g. , HTML */ const char *sort_panels[TOTAL_MODULES]; /* sorting options for each panel */ @@ -184,6 +185,7 @@ int ignore_ip_idx; /* ignored ips index */ int ignore_panel_idx; /* ignored panels index */ int ignore_referer_idx; /* ignored referrers index */ + int ignore_referer_report_idx; /* ignored referrers index */ int ignore_status_idx; /* ignore status index */ int output_format_idx; /* output format index */ int sort_panel_idx; /* sort panel index */ --- orig/goaccess-1.2/src/options.c 2017-03-06 20:08:53.000000000 +0100 +++ goaccess-1.2/src/options.c 2017-05-20 07:25:39.725903937 +0200 @@ -103,6 +103,7 @@ {"ignore-crawlers" , no_argument , 0 , 0 } , {"ignore-panel" , required_argument , 0 , 0 } , {"ignore-referer" , required_argument , 0 , 0 } , + {"ignore-referer-report", required_argument , 0 , 0 } , {"ignore-status" , required_argument , 0 , 0 } , {"invalid-requests" , required_argument , 0 , 0 } , {"json-pretty-print" , no_argument , 0 , 0 } , @@ -245,6 +246,7 @@ " --ignore-panel= - Ignore parsing/displaying the given panel.\n" " --ignore-referer= - Ignore a referer from being counted. Wild cards\n" " are allowed. i.e., *.bing.com\n" + " --ignore-referer-report=- Ignore referer's data, e.g. ref. within same site\n" " --ignore-status= - Ignore parsing the given status code.\n" " --num-tests= - Number of lines to test. >= 0 (10 default)\n" " --process-and-exit - Parse log and exit without outputting data.\n" @@ -519,6 +521,11 @@ set_array_opt (oarg, conf.ignore_referers, &conf.ignore_referer_idx, MAX_IGNORE_REF); + /* ignore referer report (e.g. within same site) */ + if (!strcmp ("ignore-referer-report", name)) + set_array_opt (oarg, conf.ignore_referers_report, &conf.ignore_referer_report_idx, + MAX_IGNORE_REF); + /* ignore status code */ if (!strcmp ("ignore-status", name)) set_array_opt (oarg, conf.ignore_status, &conf.ignore_status_idx, --- orig/goaccess-1.2/src/parser.c 2017-03-06 20:08:53.000000000 +0100 +++ goaccess-1.2/src/parser.c 2017-05-20 07:23:52.545321254 +0200 @@ -1208,7 +1209,18 @@ extract_keyphrase (tkn, &logitem->keyphrase); extract_referer_site (tkn, logitem->site); } - logitem->ref = tkn; + + + if (strcmp (tkn, "-") != 0) + { + if (!ignore_referer_report (logitem->site)){ + logitem->ref = tkn; + } + if (ignore_referer_report (logitem->site)){ + logitem->site[0] = '\0'; + } + + } break; /* user agent */ case 'u': --- orig/goaccess-1.2/src/util.c 2017-03-06 20:08:53.000000000 +0100 +++ goaccess-1.2/src/util.c 2017-05-20 07:26:16.022101720 +0200 @@ -250,6 +250,33 @@ return ignore; } +int +ignore_referer_report (const char *host) +{ + char *needle = NULL; + int i, ignore = 0; + + if (conf.ignore_referer_report_idx == 0) + return 0; + if (host == NULL || *host == '\0') + return 0; + + needle = xstrdup (host); + for (i = 0; i < conf.ignore_referer_report_idx; ++i) { + if (conf.ignore_referers_report[i] == NULL || *conf.ignore_referers_report[i] == '\0') + continue; + + if (wc_match (conf.ignore_referers_report[i], needle)) { + ignore = 1; + goto out; + } + } +out: + free (needle); + + return ignore; +} + /* Determine if the given ip is within a range of IPs. * * On error, or not within the range, 0 is returned