Skip to content

Commit daaf5ec

Browse files
committed
sniffer thread moved out of task loop
1 parent ec5f32d commit daaf5ec

File tree

5 files changed

+233
-180
lines changed

5 files changed

+233
-180
lines changed

‎net/net.c‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ static struct connection* g_conns;
3333
static size_t g_conn_count = 0;
3434
static size_t g_task_progress = 0;
3535
static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
36+
static size_t g_current = 0;
3637

3738
int bits_2_ipaddr(uint32_t ipaddr_bits, char *ip)
3839
{
@@ -362,7 +363,9 @@ void process_hosts(scan_type_t scan_type)
362363
break;
363364
case PHSCAN_TCP_HALF_OPEN:
364365
set_ip_spoofing(g_spoof_ip);
365-
conn_handler = half_open;
366+
// conn_handler = half_open;
367+
run_tasks(g_conns, g_conn_count);
368+
return;
366369
break;
367370
default:
368371
break;
@@ -589,3 +592,21 @@ void net_cleanup()
589592
free_port_ranges();
590593
}
591594

595+
int set_task_status(struct connection* conns, size_t n, const char* ip, port_t port, int status)
596+
{
597+
struct connection* h;
598+
if (!conns || !ip)
599+
return 1;
600+
601+
for (size_t i = 0; i < n; ++i)
602+
{
603+
h = &conns[i];
604+
if (!strcmp(h->ip, ip) && h->pinfo.portno == port)
605+
{
606+
h->pinfo.status = status;
607+
g_current++;
608+
break;
609+
}
610+
}
611+
return g_current == g_conn_count ? 0 : 1;
612+
}

‎net/net.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ void print_port_ranges();
9797
void get_range_str(char* str);
9898
void free_port_ranges();
9999

100+
int set_task_status(struct connection* conns, size_t n, const char* ip, port_t port, int status);
101+
100102
void net_cleanup();
101103

102104
#endif /* __NET_H */

0 commit comments

Comments
 (0)