fix: better response handling for prints
This commit is contained in:
@ -22,6 +22,7 @@ typedef enum {
|
||||
};
|
||||
|
||||
struct response {
|
||||
uint16_t port;
|
||||
e_state states[SCAN_ALL];
|
||||
char *service;
|
||||
};
|
||||
|
@ -25,6 +25,7 @@ static int scan_host(char *host, const struct option_lst *options)
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("%s\n", ip_addr);
|
||||
struct response responses[1024] = {0};
|
||||
if (create_threads(options, ip_addr, responses) < 0)
|
||||
return 1;
|
||||
@ -35,7 +36,7 @@ static int scan_host(char *host, const struct option_lst *options)
|
||||
const e_scantype type = SCAN_SYN;
|
||||
if (responses[i].states[type] == CLOSED)
|
||||
continue;
|
||||
printf("%d (%s): ", i + 1,
|
||||
printf("%d (%s): ", responses[i].port,
|
||||
responses[i].service ? responses[i].service
|
||||
: "undefined");
|
||||
if (responses[i].service)
|
||||
|
@ -41,6 +41,7 @@ void *routine(void *p_data)
|
||||
port <= thread_data->port_end; port++) {
|
||||
scan_data.port = port;
|
||||
scan_data.response = &thread_data->responses[port - 1];
|
||||
scan_data.response->port = port;
|
||||
if (scan(&scan_data)) {
|
||||
free(p_data);
|
||||
return NULL;
|
||||
|
Reference in New Issue
Block a user