@@ -65,6 +65,9 @@ pub struct Options {
6565 /// Disable the dev server for static files.
6666 #[ clap( long) ]
6767 pub no_dev_server : bool ,
68+ /// Force prompting for an IP to use to connect to the dev server on mobile.
69+ #[ clap( long) ]
70+ pub force_ip_prompt : bool ,
6871}
6972
7073pub fn command ( options : Options ) -> Result < ( ) > {
@@ -86,10 +89,10 @@ fn command_internal(mut options: Options) -> Result<()> {
8689 } )
8790}
8891
89- pub fn local_ip_address ( ) -> & ' static IpAddr {
92+ pub fn local_ip_address ( force : bool ) -> & ' static IpAddr {
9093 static LOCAL_IP : OnceCell < IpAddr > = OnceCell :: new ( ) ;
9194 LOCAL_IP . get_or_init ( || {
92- let ip = local_ip_address :: local_ip ( ) . unwrap_or_else ( |_ | {
95+ let prompt_for_ip = | | {
9396 let addresses: Vec < IpAddr > = local_ip_address:: list_afinet_netifas ( )
9497 . expect ( "failed to list networks" )
9598 . into_iter ( )
@@ -117,10 +120,14 @@ pub fn local_ip_address() -> &'static IpAddr {
117120 * addresses. get ( selected) . unwrap ( )
118121 }
119122 }
120- } ) ;
123+ } ;
121124
125+ let ip = if force {
126+ prompt_for_ip ( )
127+ } else {
128+ local_ip_address:: local_ip ( ) . unwrap_or_else ( |_| prompt_for_ip ( ) )
129+ } ;
122130 log:: info!( "Using {ip} to access the development server." ) ;
123-
124131 ip
125132 } )
126133}
@@ -175,7 +182,7 @@ pub fn setup(options: &mut Options, mobile: bool) -> Result<AppInterface> {
175182 if let Some ( mut before_dev) = script {
176183 if before_dev. contains ( "$HOST" ) {
177184 if mobile {
178- let local_ip_address = local_ip_address ( ) . to_string ( ) ;
185+ let local_ip_address = local_ip_address ( options . force_ip_prompt ) . to_string ( ) ;
179186 before_dev = before_dev. replace ( "$HOST" , & local_ip_address) ;
180187 if let AppUrl :: Url ( WindowUrl :: External ( url) ) = & mut dev_path {
181188 url. set_host ( Some ( & local_ip_address) ) ?;
@@ -293,7 +300,7 @@ pub fn setup(options: &mut Options, mobile: bool) -> Result<AppInterface> {
293300 use crate :: helpers:: web_dev_server:: start_dev_server;
294301 if path. exists ( ) {
295302 let ip = if mobile {
296- * local_ip_address ( )
303+ * local_ip_address ( options . force_ip_prompt )
297304 } else {
298305 Ipv4Addr :: new ( 127 , 0 , 0 , 1 ) . into ( )
299306 } ;
0 commit comments