Skip to content

Commit

Permalink
Remove filter_{duplicates,unsuccessful} variables (zmap#674)
Browse files Browse the repository at this point in the history
This is now covered by default mode.

Fixes zmap#670

zmap#674
  • Loading branch information
dadrian authored Aug 3, 2021
1 parent 8a7d64e commit 4df66c5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 23 deletions.
19 changes: 7 additions & 12 deletions src/recv.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ void handle_packet(uint32_t buflen, const u_char *bytes, const struct timespec t
fieldset_t *o = NULL;
// we need to translate the data provided by the probe module
// into a fieldset that can be used by the output module
if (!is_success && zconf.filter_unsuccessful) {
if (!is_success && zconf.default_mode) {
goto cleanup;
}
if (is_repeat && zconf.filter_duplicates) {
if (is_repeat && zconf.default_mode) {
goto cleanup;
}
if (!evaluate_expression(zconf.filter.expression, fs)) {
Expand Down Expand Up @@ -150,22 +150,17 @@ int recv_run(pthread_mutex_t *recv_ready_mutex)
}
// initialize paged bitmap
seen = pbm_init();
if (zconf.filter_duplicates) {
if (zconf.default_mode) {
log_debug("recv",
"duplicate responses will be excluded from output");
} else {
log_debug("recv",
"duplicate responses will be included in output");
}
if (zconf.filter_unsuccessful) {
log_debug(
"recv",
"unsuccessful responses will be excluded from output");
"unsuccessful responses will be excluded from output");
} else {
log_debug("recv",
"unsuccessful responses will be included in output");
"duplicate responses will be passed to the output module");
log_debug("recv",
"unsuccessful responses will be passed to the output module");
}

pthread_mutex_lock(recv_ready_mutex);
zconf.recv_ready = 1;
pthread_mutex_unlock(recv_ready_mutex);
Expand Down
2 changes: 0 additions & 2 deletions src/state.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ struct state_conf zconf = {.log_level = LOG_INFO,
.dryrun = 0,
.quiet = 0,
.syslog = 1,
.filter_duplicates = 0,
.filter_unsuccessful = 0,
.max_sendto_failures = -1,
.min_hitrate = 0.0,
.metadata_file = NULL,
Expand Down
2 changes: 0 additions & 2 deletions src/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ struct state_conf {
int quiet;
int ignore_invalid_hosts;
int syslog;
int filter_duplicates;
int filter_unsuccessful;
int recv_ready;
int num_retries;
uint64_t total_allowed;
Expand Down
7 changes: 2 additions & 5 deletions src/summary.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,8 @@ void json_metadata(FILE *file)

json_object_object_add(obj, "syslog",
json_object_new_int(zconf.syslog));
json_object_object_add(obj, "filter_duplicates",
json_object_new_int(zconf.filter_duplicates));
json_object_object_add(obj, "filter_unsuccessful",
json_object_new_int(zconf.filter_unsuccessful));

json_object_object_add(obj, "default_mode",
json_object_new_int(zconf.default_mode));
json_object_object_add(obj, "pcap_recv",
json_object_new_int(zrecv.pcap_recv));
json_object_object_add(obj, "pcap_drop",
Expand Down
2 changes: 0 additions & 2 deletions src/zmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,6 @@ int main(int argc, char *argv[])
}
// default filtering behavior is to drop unsuccessful and duplicates
if (zconf.default_mode) {
zconf.filter_duplicates = 1;
zconf.filter_unsuccessful = 1;
log_debug(
"filter",
"No output filter specified. Will use default: exclude duplicates and unssuccessful");
Expand Down

0 comments on commit 4df66c5

Please sign in to comment.