X-Git-Url: https://git.harvie.cz/?a=blobdiff_plain;f=prometheus.c;h=4cc02a02543b8c2c23c1070fcb09a3b6807362da;hb=364980f04f445e5040f7fe5c6a5c499ac9e86d5b;hp=87c5f18a92487053b1d56a04ca658ce7174a7799;hpb=75e8c6ab4e96499b902961d41fb90fe58df88c8b;p=svn%2FPrometheus-QoS%2F.git
diff --git a/prometheus.c b/prometheus.c
index 87c5f18..4cc02a0 100644
--- a/prometheus.c
+++ b/prometheus.c
@@ -2,12 +2,12 @@
/* Prometheus QoS - you can "steal fire" from your ISP */
/* "fair-per-IP" quality of service (QoS) utility */
/* requires Linux 2.4.x or 2.6.x with HTB support */
-/* Copyright(C) 2005-2019 Michael Polak, Arachne Aerospace */
+/* Copyright(C) 2005-2020 Michael Polak, Arachne Aerospace */
/* iptables-restore support Copyright(C) 2007-2008 ludva */
/* Credit: CZFree.Net,Martin Devera,Netdave,Aquarius,Gandalf */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-/* Modified by: xChaos, 20190912
+/* Modified by: xChaos, 20200107
ludva, 20080415
Prometheus QoS is free software; you can redistribute it and/or
@@ -29,7 +29,7 @@
#include "cll1-0.6.2.h"
#include "ipstruct.h"
-const char *version = "0.9.0-c";
+const char *version = "1.0.0-a";
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* Versions: 0.9.0 is development release, 1.0 will be "stable" */
@@ -40,7 +40,7 @@ const char *version = "0.9.0-c";
/* Warning: unofficial Github mirror is not supported by author! */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-const char *stats_html_signature = "Statistics generated by Prometheus QoS version %s
GPL+Copyright(C)2005-2019 Michael Polak, Arachne Labs\n";
+const char *stats_html_signature = "Statistics generated by Prometheus QoS version %s
GPL+Copyright(C)2005-2020 Michael Polak, Arachne Labs\n";
#define STRLEN 512
#undef DEBUG
@@ -63,6 +63,7 @@ char *upstreamfile = "/etc/prometheus/upstream.interfaces"; /* list of interf
char *downstreamfile = "/etc/prometheus/downstream.interfaces"; /* list of interfaces to manage */
char *qosfreefile = "/etc/prometheus/qosfree.interfaces"; /* list of interfaces to manage */
char *iptablesfile = "/var/spool/prometheus.iptables"; /* temporary file for iptables-restore*/
+char *iptablesdump = "/var/spool/prometheus.iptables-dump"; /* temporary file for iptables -L -v -x -n -t mangle */
char *ip6tablesfile = "/var/spool/prometheus.ip6tables"; /* temporary file for ip6tables-restore*/
char *credit = "/var/lib/misc/prometheus.credit"; /* credit log file */
char *classmap = "/var/lib/misc/prometheus.classes"; /* credit log file */
@@ -290,6 +291,7 @@ void get_config(char *config_filename)
option("ip6tables-save",ip6tablessave);
option("ip6tables-restore",ip6tablesrestore);
option("iptables-in-filename",iptablesfile);
+ option("iptables-dump-filename",iptablesdump);
option("ip6tables-in-filename",ip6tablesfile);
option("hosts",hosts);
option("downstream-interfaces-list-filename",downstreamfile);
@@ -640,14 +642,34 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
printf("Parsing class defintion file %s ...\n", hosts);
/*-----------------------------------------------------------------*/
parse_hosts(hosts);
-/*
- //this was pretty dumb idea anyway...
- if(just_networks)
+
+#ifdef MONITORINGTRHU_CTU
+//special hack only to generate certain required CSV statistics for www.ctu.cz (regulation body)
+//not required for everyday use, requires special syntax sugar in hosts file, see parsehosts.c
+ for_each(technology, technologies)
{
- analyse_topology("/usr/sbin/traceroute -n -m 10 -w 2 %s.%d");
- exit(-1);
- }
-*/
+ char *filename;
+ FILE *f;
+ string(filename, strlen(log_dir) + strlen(technology->filename) + 5);
+ strcpy(filename, log_dir);
+ strcat(filename, technology->filename);
+ strcat(filename, ".csv");
+ /*-----------------------------------------------------------------*/
+ printf("Writing report file %s ...\n", filename);
+ /*-----------------------------------------------------------------*/
+ f = fopen(filename, "w");
+ if(f)
+ {
+ for_each(ip, ips) if(eq(technology->filename, ip->technology_str))
+ {
+ fprintf(f,"%d,%s,%d\n", ip->lmsid, ip->ruian_id_str, ip->max);
+ }
+ fclose(f);
+ }
+ else
+ perror(filename);
+ }
+#endif
/*-----------------------------------------------------------------*/
puts("Resolving shared connections ...");
@@ -772,7 +794,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
{
for_each(interface, interfaces)
{
- sprintf(str,"-A %s -m set --match-set %s %s -o %s -j ACCEPT", interface->chain, qos_free_dst_ipset, (interface->is_upstream?"src":"dst"), interface->name);
+ sprintf(str,"-A %s -m set --match-set %s %s -o %s -j ACCEPT", interface->chain, qos_free_dst_ipset, (interface->is_upstream?"dst":"src"), interface->name);
iptables_save_line(str, IPv4);
}
}
@@ -781,7 +803,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
{
for_each(interface, interfaces)
{
- sprintf(str,"-A %s -m set --match-set %s %s -o %s -j ACCEPT", interface->chain, qos_free_src_ipset, (interface->is_upstream?"dst":"src"), interface->name);
+ sprintf(str,"-A %s -m set --match-set %s %s -o %s -j ACCEPT", interface->chain, qos_free_src_ipset, (interface->is_upstream?"src":"dst"), interface->name);
iptables_save_line(str, IPv4);
}
}
@@ -1220,6 +1242,7 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version);
printf("Writing statistics into HTML page %s ...\n", html);
/*-----------------------------------------------------------------*/
write_htmlandlogs(html, d, total, just_preview);
+ printf("\n");
}
if(just_preview)