@@ -205,6 +205,7 @@ impl Adapter {
205205
206206 // Wait for the syn ack
207207 self . states . insert ( host_port, state) ;
208+ let start_time = std:: time:: Instant :: now ( ) ;
208209 loop {
209210 self . process_tcp_packet ( ) . await ?;
210211 if let Some ( s) = self . states . get ( & host_port) {
@@ -216,6 +217,12 @@ impl Adapter {
216217 return Err ( std:: io:: Error :: new ( e, "failed to connect" ) ) ;
217218 }
218219 ConnectionStatus :: WaitingForSyn => {
220+ if start_time. elapsed ( ) > std:: time:: Duration :: from_secs ( 5 ) {
221+ return Err ( std:: io:: Error :: new (
222+ std:: io:: ErrorKind :: TimedOut ,
223+ "didn't syn in time" ,
224+ ) ) ;
225+ }
219226 continue ;
220227 }
221228 }
@@ -526,7 +533,7 @@ impl Adapter {
526533 self . write_buffer_flush ( ) . await ?;
527534 Ok ( loop {
528535 // try the data we already have
529- match Ipv6Packet :: parse ( & self . read_buf [ ..self . bytes_in_buf ] ) {
536+ match Ipv6Packet :: parse ( & self . read_buf [ ..self . bytes_in_buf ] , & self . pcap ) {
530537 IpParseError :: Ok {
531538 packet,
532539 bytes_consumed,
@@ -559,8 +566,15 @@ impl Adapter {
559566 }
560567
561568 pub ( crate ) async fn process_tcp_packet ( & mut self ) -> Result < ( ) , std:: io:: Error > {
562- let ip_packet = self . read_ip_packet ( ) . await ?;
563- self . process_tcp_packet_from_payload ( & ip_packet) . await
569+ tokio:: select! {
570+ ip_packet = self . read_ip_packet( ) => {
571+ let ip_packet = ip_packet?;
572+ self . process_tcp_packet_from_payload( & ip_packet) . await
573+ }
574+ _ = tokio:: time:: sleep( std:: time:: Duration :: from_secs( 15 ) ) => {
575+ Ok ( ( ) )
576+ }
577+ }
564578 }
565579
566580 pub ( crate ) async fn process_tcp_packet_from_payload (
0 commit comments