@@ -9,7 +9,7 @@ use innernet_shared::{
99 prompts, update_hosts_file,
1010 wg:: { DeviceExt , PeerInfoExt } ,
1111 AddCidrOpts , AddDeleteAssociationOpts , AddPeerOpts , Association , AssociationContents , Cidr ,
12- CidrTree , DeleteCidrOpts , EnableDisablePeerOpts , Endpoint , EndpointContents , HostsOpt ,
12+ CidrTree , DeleteCidrOpts , EnableDisablePeerOpts , Endpoint , EndpointContents , HostsOpts ,
1313 InstallOpts , Interface , IoErrorContext , ListenPortOpts , NatOpts , NetworkOpts ,
1414 OverrideEndpointOpts , Peer , RedeemContents , RenameCidrOpts , RenamePeerOpts , ServerCapabilities ,
1515 State , WrappedIoError , REDEEM_TRANSITION_WAIT ,
@@ -82,7 +82,7 @@ enum Command {
8282 invite : PathBuf ,
8383
8484 #[ clap( flatten) ]
85- hosts : HostsOpt ,
85+ hosts : HostsOpts ,
8686
8787 #[ clap( flatten) ]
8888 install_opts : InstallOpts ,
@@ -118,7 +118,7 @@ enum Command {
118118 interval : u64 ,
119119
120120 #[ clap( flatten) ]
121- hosts : HostsOpt ,
121+ hosts : HostsOpts ,
122122
123123 #[ clap( flatten) ]
124124 nat : NatOpts ,
@@ -131,7 +131,7 @@ enum Command {
131131 interface : Interface ,
132132
133133 #[ clap( flatten) ]
134- hosts : HostsOpt ,
134+ hosts : HostsOpts ,
135135
136136 #[ clap( flatten) ]
137137 nat : NatOpts ,
@@ -274,7 +274,7 @@ enum Command {
274274fn install (
275275 opts : & Opts ,
276276 invite : & Path ,
277- hosts_file : Option < PathBuf > ,
277+ hosts_opts : HostsOpts ,
278278 install_opts : InstallOpts ,
279279 nat : & NatOpts ,
280280) -> Result < ( ) , Error > {
@@ -323,7 +323,7 @@ fn install(
323323
324324 let mut fetch_success = false ;
325325 for _ in 0 ..3 {
326- if fetch ( & iface, opts, true , hosts_file . clone ( ) , nat) . is_ok ( ) {
326+ if fetch ( & iface, opts, true , & hosts_opts , nat) . is_ok ( ) {
327327 fetch_success = true ;
328328 break ;
329329 }
@@ -466,7 +466,7 @@ fn up(
466466 interface : Option < Interface > ,
467467 opts : & Opts ,
468468 loop_interval : Option < Duration > ,
469- hosts_path : Option < PathBuf > ,
469+ hosts_opts : HostsOpts ,
470470 nat : & NatOpts ,
471471) -> Result < ( ) , Error > {
472472 loop {
@@ -476,7 +476,7 @@ fn up(
476476 } ;
477477
478478 for iface in interfaces {
479- fetch ( & iface, opts, true , hosts_path . clone ( ) , nat) ?;
479+ fetch ( & iface, opts, true , & hosts_opts , nat) ?;
480480 }
481481
482482 match loop_interval {
@@ -492,7 +492,7 @@ fn fetch(
492492 interface : & InterfaceName ,
493493 opts : & Opts ,
494494 bring_up_interface : bool ,
495- hosts_path : Option < PathBuf > ,
495+ hosts_opts : & HostsOpts ,
496496 nat : & NatOpts ,
497497) -> Result < ( ) , Error > {
498498 let config = InterfaceConfig :: from_interface ( & opts. config_dir , interface) ?;
@@ -577,8 +577,8 @@ fn fetch(
577577 . apply ( interface, opts. network . backend )
578578 . with_str ( interface. to_string ( ) ) ?;
579579
580- if let Some ( path ) = hosts_path {
581- update_hosts_file ( interface, & path , & peers) ?;
580+ if !hosts_opts . no_write_hosts {
581+ update_hosts_file ( interface, hosts_opts , & peers) ?;
582582 }
583583
584584 println ! ( ) ;
@@ -1290,7 +1290,7 @@ fn run(opts: &Opts) -> Result<(), Error> {
12901290 hosts,
12911291 install_opts,
12921292 nat,
1293- } => install ( opts, & invite, hosts. into ( ) , install_opts, & nat) ?,
1293+ } => install ( opts, & invite, hosts, install_opts, & nat) ?,
12941294 Command :: Show {
12951295 short,
12961296 tree,
@@ -1300,7 +1300,7 @@ fn run(opts: &Opts) -> Result<(), Error> {
13001300 interface,
13011301 hosts,
13021302 nat,
1303- } => fetch ( & interface, opts, false , hosts. into ( ) , & nat) ?,
1303+ } => fetch ( & interface, opts, false , & hosts, & nat) ?,
13041304 Command :: Up {
13051305 interface,
13061306 daemon,
@@ -1311,7 +1311,7 @@ fn run(opts: &Opts) -> Result<(), Error> {
13111311 interface,
13121312 opts,
13131313 daemon. then ( || Duration :: from_secs ( interval) ) ,
1314- hosts. into ( ) ,
1314+ hosts,
13151315 & nat,
13161316 ) ?,
13171317 Command :: Down { interface } => wg:: down ( & interface, opts. network . backend ) ?,
0 commit comments