Rename config settings for consistency.

This commit is contained in:
Christian Deacon
2024-06-13 20:33:09 -04:00
parent a80458efff
commit f480f06c4b
4 changed files with 21 additions and 22 deletions

View File

@@ -159,7 +159,7 @@ int readcfg(struct config *cfg)
// Get auto update time.
int updatetime;
if (config_lookup_int(&conf, "updatetime", &updatetime) == CONFIG_TRUE)
if (config_lookup_int(&conf, "update_time", &updatetime) == CONFIG_TRUE)
{
cfg->updatetime = updatetime;
}
@@ -175,7 +175,7 @@ int readcfg(struct config *cfg)
// Get no stats.
int nostats;
if (config_lookup_bool(&conf, "nostats", &nostats) == CONFIG_TRUE)
if (config_lookup_bool(&conf, "no_stats", &nostats) == CONFIG_TRUE)
{
cfg->nostats = nostats;
}
@@ -230,7 +230,7 @@ int readcfg(struct config *cfg)
// Source IP (not required).
const char *sip;
if (config_setting_lookup_string(filter, "srcip", &sip))
if (config_setting_lookup_string(filter, "src_ip", &sip))
{
cfg->filters[i].srcip = inet_addr(sip);
}
@@ -238,7 +238,7 @@ int readcfg(struct config *cfg)
// Destination IP (not required).
const char *dip;
if (config_setting_lookup_string(filter, "dstip", &dip))
if (config_setting_lookup_string(filter, "dst_ip", &dip))
{
cfg->filters[i].dstip = inet_addr(dip);
}
@@ -246,7 +246,7 @@ int readcfg(struct config *cfg)
// Source IP (IPv6) (not required).
const char *sip6;
if (config_setting_lookup_string(filter, "srcip6", &sip6))
if (config_setting_lookup_string(filter, "src_ip6", &sip6))
{
struct in6_addr in;
@@ -261,7 +261,7 @@ int readcfg(struct config *cfg)
// Destination IP (IPv6) (not required).
const char *dip6;
if (config_setting_lookup_string(filter, "dstip6", &dip6))
if (config_setting_lookup_string(filter, "dst_ip6", &dip6))
{
struct in6_addr in;
@@ -339,7 +339,7 @@ int readcfg(struct config *cfg)
// Block time (default 1).
long long blocktime;
if (config_setting_lookup_int64(filter, "blocktime", &blocktime))
if (config_setting_lookup_int64(filter, "block_time", &blocktime))
{
cfg->filters[i].blocktime = blocktime;
}

View File

@@ -472,9 +472,10 @@ int main(int argc, char *argv[])
// Create last updated variable.
time_t lastupdatecheck = time(NULL);
time_t statslastupdated = time(NULL);
time_t lastupdated = time(NULL);
unsigned int sleep_time = cfg.stdout_update_time * 1000;
while (cont)
{
// Get current time.
@@ -510,7 +511,7 @@ int main(int argc, char *argv[])
}
// Update stats.
if ((curTime - statslastupdated) > 2 && !cfg.nostats)
if (!cfg.nostats)
{
__u32 key = 0;
struct stats stats[MAX_CPUS];
@@ -546,11 +547,9 @@ int main(int argc, char *argv[])
fflush(stdout);
fprintf(stdout, "\rAllowed: %llu | Dropped: %llu | Passed: %llu", allowed, dropped, passed);
statslastupdated = time(NULL);
}
usleep(500);
usleep(sleep_time);
}
// Detach XDP program.