From 139fc8a0a7c49580783fb3c4b8050761e8bf021a Mon Sep 17 00:00:00 2001 From: xchaos Date: Fri, 13 Oct 2017 14:46:31 +0000 Subject: [PATCH] do not write empty logs when started git-svn-id: https://dev.arachne.cz/repos/prometheus/trunk@261 251d49ef-1d17-4917-a970-b30cf55b089b --- htmlandlogs.c | 3 ++- parseiptables.c | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/htmlandlogs.c b/htmlandlogs.c index b6f9cb6..bff5cb3 100644 --- a/htmlandlogs.c +++ b/htmlandlogs.c @@ -22,6 +22,7 @@ extern int found_lmsid; extern char *lms_url; extern char *log_dir; extern char *ip6prefix; +extern int traffic_detected; const char *tr_odd_even(void); /* implemented in prometheus.c, shared with parselogs.c */ @@ -402,7 +403,7 @@ style=\"cursor: pointer;\">+%d]", insert(sum,sums,order_by,i); } - if(!just_preview) + if(!just_preview && traffic_detected) { append_log(ip); for_each(sharedip,ips) if(eq(ip->name, sharedip->sharing)) diff --git a/parseiptables.c b/parseiptables.c index 8544df7..5a2043f 100644 --- a/parseiptables.c +++ b/parseiptables.c @@ -13,12 +13,15 @@ extern int free_min; extern int free_max; extern int include_upload; +int traffic_detected = 0; + /* ===================== traffic analyser - uses iptables ================ */ void get_traffic_statistics(const char *whichiptables, int ipv6) { char *str,*cmd; - int downloadflag=0; + int downloadflag = 0; + traffic_detected = 0; textfile(Pipe,str) *line,*lines=NULL; string(str,STRLEN); @@ -78,6 +81,10 @@ void get_traffic_statistics(const char *whichiptables, int ipv6) else { sscanf(ptr,"%Lu",&traffic); + if(traffic) + { + traffic_detected = 1; + } traffic += (1<<19); traffic >>= 20; } -- 2.30.2