From: Frédéric Marchal Date: Sun, 19 Jun 2011 19:33:48 +0000 (+0000) Subject: Alias the host names in the redirector report X-Git-Tag: v2.3.2~51 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0a6722a182b22737e37c71047130c015cefd39bf;p=thirdparty%2Fsarg.git Alias the host names in the redirector report The scheme is removed from the URL even for a custom report format and the URL is always truncated to keep only the host name. The full URL was always reported for a custom log format. In addition, the reported host name is replaced by the alias if one is defined. There is no grouping of the identical host names as the report list one access per line along with the access time so there is no grouping any way. --- diff --git a/log.c b/log.c index a0eedf1..e4d6cd0 100644 --- a/log.c +++ b/log.c @@ -1571,7 +1571,6 @@ int main(int argc,char *argv[]) free_download(); free_excludecodes(); free_exclude(); - free_hostalias(); if(debug) { int totalcount=0; @@ -1692,6 +1691,7 @@ int main(int argc,char *argv[]) unlinkdir(tmp,0); } + free_hostalias(); userinfo_free(); if(userfile) free(userfile); diff --git a/squidguard_log.c b/squidguard_log.c index cc602b7..e461418 100644 --- a/squidguard_log.c +++ b/squidguard_log.c @@ -38,14 +38,14 @@ static void read_log(const char *wentp, FILE *fp_ou,int dfrom,int duntil) char leks[5], sep[2], res[MAXLEN]; char hour[15]; char source[128], list[128]; - char url[MAX_URL_LEN]; + char full_url[MAX_URL_LEN]; + const char *url; char user[MAX_USER_LEN]; char ip[45]; long long int lmon, lday, lyear; int mon, day, year; int idata=0; int i; - char *str; bool id_is_ip; struct getwordstruct gwarea; struct getwordstruct gwarea1; @@ -116,7 +116,7 @@ static void read_log(const char *wentp, FILE *fp_ou,int dfrom,int duntil) list[0]='\0'; ip[0]='\0'; user[0]='\0'; - url[0]='\0'; + full_url[0]='\0'; while(strcmp(leks,"end") != 0) { if (getword(leks,sizeof(leks),&gwarea1,'#')<0) { debuga(_("Invalid \"redirector_log_format\" option in your sarg.conf (missing # at end of tag)\n")); @@ -168,11 +168,11 @@ static void read_log(const char *wentp, FILE *fp_ou,int dfrom,int duntil) } strcpy(user,res); } else if(strcmp(leks,"url") == 0) { - if (strlen(res)>=sizeof(url)) { + if (strlen(res)>=sizeof(full_url)) { debuga(_("URL too long in redirector log file %s\n"),wentp); exit(EXIT_FAILURE); } - strcpy(url,res); + strcpy(full_url,res); } } } @@ -197,7 +197,7 @@ static void read_log(const char *wentp, FILE *fp_ou,int dfrom,int duntil) debuga(_("Invalid redirected list in file %s\n"),wentp); exit(EXIT_FAILURE); } - if (getword_skip(MAXLEN,&gwarea,' ')<0 || getword_limit(url,sizeof(url),&gwarea,' ')<0) { + if (getword_skip(MAXLEN,&gwarea,' ')<0 || getword_limit(full_url,sizeof(full_url),&gwarea,' ')<0) { debuga(_("Invalid URL in file %s\n"),wentp); exit(EXIT_FAILURE); } @@ -209,23 +209,8 @@ static void read_log(const char *wentp, FILE *fp_ou,int dfrom,int duntil) debuga(_("Invalid user in file %s\n"),wentp); exit(EXIT_FAILURE); } - /* - The URL may be "http://url:port/data" if the method is GET or simply "url:port/" if the method is CONNECT. - The following code removes the protocol:// if it is detected and always truncates the URL after the domain name. - It will fail if the URL doesn't start with the protocol and contains two consecutive / in the path (i.e. - the URL is not normalized). - */ - str=strchr(url,'/'); - if (str) { - if (str[1]=='/') { - str+=2; - for (i=0 ; *str && *str!='/' ; i++) url[i]=*str++; - url[i]='\0'; - } else { - *str='\0'; - } - } } + url=process_url(full_url,false); //sprintf(warea,"%04d%02d%02d",year,mon,day);