@@ -7,7 +7,7 @@ use std::{path::Path, time::Duration};
77use anyhow:: { anyhow, Context , Result } ;
88use app:: App ;
99use clap:: { Args as ClapArgs , Parser , Subcommand } ;
10- use config:: Config ;
10+ use config:: { Config , NetdConfig } ;
1111use dstack_api_auth:: { Authenticator , HttpAuthConfig , HttpAuthFairing } ;
1212use guest_api_service:: GuestApiHandler ;
1313use host_api_service:: HostApiHandler ;
@@ -194,23 +194,28 @@ async fn main() -> Result<()> {
194194 }
195195
196196 let figment = config:: load_config_figment ( args. config . as_deref ( ) ) ;
197- let mut config = Config :: extract_or_default ( & figment) ?. abs_path ( ) ?;
198- config. cvm . instance_id = netd:: instance_id ( & config. cvm . instance_id , config. run_path . as_path ( ) ) ;
199- if let Some ( socket) = args. netd_socket . as_deref ( ) {
200- config. netd . socket = socket. into ( ) ;
201- }
202-
203197 if let Some ( Command :: Netd ( netd_args) ) = & args. command {
198+ let mut netd_config: NetdConfig = figment
199+ . extract_inner ( "netd" )
200+ . context ( "failed to load [netd] configuration" ) ?;
201+ if let Some ( socket) = args. netd_socket . as_deref ( ) {
202+ netd_config. socket = socket. into ( ) ;
203+ }
204204 if let Some ( socket) = netd_args. socket . as_deref ( ) {
205- config . netd . socket = socket. into ( ) ;
205+ netd_config . socket = socket. into ( ) ;
206206 }
207- config
208- . netd
207+ netd_config
209208 . allowed_uids
210209 . extend ( netd_args. allow_uids . iter ( ) . copied ( ) ) ;
211- config. netd . allowed_uids . sort_unstable ( ) ;
212- config. netd . allowed_uids . dedup ( ) ;
213- return netd:: serve ( config. netd ) . await ;
210+ netd_config. allowed_uids . sort_unstable ( ) ;
211+ netd_config. allowed_uids . dedup ( ) ;
212+ return netd:: serve ( netd_config) . await ;
213+ }
214+
215+ let mut config = Config :: extract_or_default ( & figment) ?. abs_path ( ) ?;
216+ config. cvm . instance_id = netd:: instance_id ( & config. cvm . instance_id , config. run_path . as_path ( ) ) ;
217+ if let Some ( socket) = args. netd_socket . as_deref ( ) {
218+ config. netd . socket = socket. into ( ) ;
214219 }
215220
216221 // Preserve the existing startup validation. The broader static checks are
0 commit comments