@@ -569,10 +569,14 @@ impl ServerPacketHandler {
569569 ) -> anyhow:: Result < ( ) > {
570570 let source = net_packet. source ( ) ;
571571 let dest = net_packet. destination ( ) ;
572+ let destination = u32:: from ( dest) ;
573+ if destination == context. virtual_ip {
574+ return Ok ( ( ) ) ;
575+ }
572576 if dest. is_broadcast ( ) || dest == context. broadcast {
573577 // 广播
574578 for peer in context. network_info . read ( ) . clients . values ( ) {
575- if !peer. online {
579+ if !peer. online || destination == peer . virtual_ip {
576580 continue ;
577581 }
578582 if let Some ( sender) = & peer. wg_sender {
@@ -581,7 +585,7 @@ impl ServerPacketHandler {
581585 }
582586 }
583587 }
584- } else if let Some ( peer) = context. network_info . read ( ) . clients . get ( & dest . into ( ) ) {
588+ } else if let Some ( peer) = context. network_info . read ( ) . clients . get ( & destination ) {
585589 // 点对点
586590 if peer. online {
587591 if let Some ( sender) = & peer. wg_sender {
@@ -600,11 +604,13 @@ impl ServerPacketHandler {
600604 exclude : & [ Ipv4Addr ] ,
601605 ) -> io:: Result < ( ) > {
602606 let client_secret = net_packet. is_encrypt ( ) ;
607+ let destination = u32:: from ( net_packet. destination ( ) ) ;
603608 for ( ip, client_info) in & context. network_info . read ( ) . clients {
604609 if client_info. online
605- && !exclude . contains ( & ( * ip) . into ( ) )
610+ && destination != * ip
606611 && client_info. client_secret == client_secret
607612 && client_info. wireguard . is_none ( )
613+ && !exclude. contains ( & ( * ip) . into ( ) )
608614 {
609615 if let Some ( sender) = & client_info. tcp_sender {
610616 let _ = sender. try_send ( net_packet. buffer ( ) . to_vec ( ) ) ;
0 commit comments