Skip to content

Commit

Permalink
remove incoming_history and outgoing_history
Browse files Browse the repository at this point in the history
These counters are not used - maybe they will be needed in the future again.
  • Loading branch information
mwarning committed Oct 29, 2018
1 parent 9ab405e commit afd3dcf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 0 additions & 2 deletions src/client_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,7 @@ void client_reset(t_client *client)
{
// Reset traffic counters
client->counters.incoming = 0;
client->counters.incoming_history = 0;
client->counters.outgoing = 0;
client->counters.outgoing_history = 0;
client->counters.last_updated = time(NULL);

// Reset seesion time
Expand Down
2 changes: 0 additions & 2 deletions src/client_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
typedef struct _t_counters {
unsigned long long incoming; /**< @brief Incoming data total */
unsigned long long outgoing; /**< @brief Outgoing data total */
unsigned long long incoming_history; /**< @brief Incoming data before nodogsplash restarted, always 0 atm. */
unsigned long long outgoing_history; /**< @brief Outgoing data before nodogsplash restarted, always 0 atm. */
time_t last_updated; /**< @brief Last update of the counters */
} t_counters;

Expand Down
8 changes: 4 additions & 4 deletions src/fw_iptables.c
Original file line number Diff line number Diff line change
Expand Up @@ -1022,8 +1022,8 @@ iptables_fw_counters_update(void)
debug(LOG_DEBUG, "Read outgoing traffic for %s: Bytes=%llu", ip, counter);
LOCK_CLIENT_LIST();
if ((p1 = client_list_find_by_ip(ip))) {
if ((p1->counters.outgoing - p1->counters.outgoing_history) < counter) {
p1->counters.outgoing = p1->counters.outgoing_history + counter;
if (p1->counters.outgoing < counter) {
p1->counters.outgoing = counter;
p1->counters.last_updated = time(NULL);
debug(LOG_DEBUG, "%s - Updated counter.outgoing to %llu bytes. Updated last_updated to %d", ip, counter, p1->counters.last_updated);
}
Expand Down Expand Up @@ -1061,8 +1061,8 @@ iptables_fw_counters_update(void)
debug(LOG_DEBUG, "Read incoming traffic for %s: Bytes=%llu", ip, counter);
LOCK_CLIENT_LIST();
if ((p1 = client_list_find_by_ip(ip))) {
if ((p1->counters.incoming - p1->counters.incoming_history) < counter) {
p1->counters.incoming = p1->counters.incoming_history + counter;
if (p1->counters.incoming < counter) {
p1->counters.incoming = counter;
debug(LOG_DEBUG, "%s - Updated counter.incoming to %llu bytes", ip, counter);
}
} else {
Expand Down

0 comments on commit afd3dcf

Please sign in to comment.