@@ -269,6 +269,17 @@ impl Discovery {
269269 self . set_scrollbar_height ( ) ;
270270 }
271271
272+ fn set_active_subnet ( & mut self , intf : & NetworkInterface ) {
273+ let a_ip = intf. ips [ 0 ] . ip ( ) . to_string ( ) ;
274+ let ip: Vec < & str > = a_ip. split ( '.' ) . collect ( ) ;
275+ if ip. len ( ) > 1 {
276+ let new_a_ip = format ! ( "{}.{}.{}.0/24" , ip[ 0 ] , ip[ 1 ] , ip[ 2 ] ) ;
277+ self . input = Input :: default ( ) . with_value ( new_a_ip) ;
278+
279+ self . set_cidr ( self . input . value ( ) . to_string ( ) , false ) ;
280+ }
281+ }
282+
272283 fn set_scrollbar_height ( & mut self ) {
273284 self . scrollbar_state = self
274285 . scrollbar_state
@@ -548,12 +559,8 @@ impl Component for Discovery {
548559 let intf = interface. clone ( ) ;
549560 // -- first time scan after setting of interface
550561 if self . active_interface . is_none ( ) {
551- let a_ip = intf. ips [ 0 ] . ip ( ) . to_string ( ) ;
552- let ip: Vec < & str > = a_ip. split ( '.' ) . collect ( ) ;
553- let new_a_ip = format ! ( "{}.{}.{}.0/24" , ip[ 0 ] , ip[ 1 ] , ip[ 2 ] ) ;
554- self . input = Input :: default ( ) . with_value ( new_a_ip) ;
562+ self . set_active_subnet ( & intf) ;
555563
556- self . set_cidr ( self . input . value ( ) . to_string ( ) , true ) ;
557564 }
558565 self . active_interface = Some ( intf) ;
559566 }
0 commit comments