@@ -65,7 +65,9 @@ async fn list_interfaces() -> Result<()> {
6565}
6666
6767async fn tcp_syn ( arg : TcpSynArg ) -> Result < ( ) > {
68- let pool = ThreadPoolBuilder :: new ( ) . num_threads ( arg. thread ) . build ( ) ?;
68+ if arg. rate <= arg. timeout {
69+ bail ! ( "rate must be greater than timeout" ) ;
70+ }
6971
7072 let dest_ips = arg
7173 . dest_nets
@@ -101,6 +103,7 @@ async fn tcp_syn(arg: TcpSynArg) -> Result<()> {
101103 ) ;
102104
103105 let ( progress, progress_tx) = Progress :: new ( count) ;
106+ let pool = ThreadPoolBuilder :: new ( ) . num_threads ( arg. thread ) . build ( ) ?;
104107
105108 let scanner = tcp_syn:: Scanner {
106109 pool : & pool,
@@ -109,11 +112,10 @@ async fn tcp_syn(arg: TcpSynArg) -> Result<()> {
109112 dest_ports : arg. dest_ports ,
110113 src_ip,
111114 src_port : rand:: random ( ) ,
112- timeout : Duration :: from_secs ( 2 ) ,
113- wait_idle : arg. wait_idle ,
114- send_buffer_size : arg. send_buffer_size ,
115- send_progress_tx : None ,
116- recv_progress_tx : Some ( progress_tx) ,
115+ timeout : Some ( Duration :: from_secs ( arg. timeout ) ) ,
116+ wait : Some ( Duration :: from_secs_f64 ( 1.0 / arg. rate as f64 ) ) ,
117+ send_progress_tx : Some ( progress_tx) ,
118+ recv_progress_tx : None ,
117119 } ;
118120
119121 tokio:: spawn ( progress. run ( ) ) ;
@@ -125,8 +127,10 @@ async fn tcp_syn(arg: TcpSynArg) -> Result<()> {
125127 . filter ( |( _, result) | !result. opened . is_empty ( ) )
126128 {
127129 info ! (
128- "{}: opened: {:?}, unknown: {:?}" ,
129- ip, result. opened, result. unknown
130+ "{}: opened: {:?}, number of unknown: {}" ,
131+ ip,
132+ result. opened,
133+ result. unknown. len( )
130134 ) ;
131135 }
132136 }
@@ -137,8 +141,10 @@ async fn tcp_syn(arg: TcpSynArg) -> Result<()> {
137141 . filter ( |( _, result) | !result. opened . is_empty ( ) )
138142 {
139143 info ! (
140- "{}: opened: {:?}, unknown: {:?}" ,
141- ip, result. opened, result. unknown
144+ "{}: opened: {:?}, number of unknown: {}" ,
145+ ip,
146+ result. opened,
147+ result. unknown. len( )
142148 ) ;
143149 }
144150 }
@@ -149,8 +155,10 @@ async fn tcp_syn(arg: TcpSynArg) -> Result<()> {
149155 . filter ( |( _, result) | !result. opened . is_empty ( ) )
150156 {
151157 info ! (
152- "{}: opened: {:?}, unknown: {:?}" ,
153- ip, result. opened, result. unknown
158+ "{}: opened: {:?}, number of unknown: {}" ,
159+ ip,
160+ result. opened,
161+ result. unknown. len( )
154162 ) ;
155163 }
156164 }
0 commit comments