File tree Expand file tree Collapse file tree
packages/edge/infra/client Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -101,6 +101,10 @@ pub struct Runner {
101101
102102 pub container_runner_binary_path : Option < PathBuf > ,
103103 pub isolate_runner_binary_path : Option < PathBuf > ,
104+
105+ /// Custom host entries to append to /etc/hosts in actor containers.
106+ #[ serde( default ) ]
107+ pub custom_hosts : Option < Vec < HostEntry > > ,
104108}
105109
106110impl Runner {
@@ -127,6 +131,10 @@ impl Runner {
127131 . clone ( )
128132 . unwrap_or_else ( || Path :: new ( "/usr/local/bin/rivet-isolate-v8-runner" ) . into ( ) )
129133 }
134+
135+ pub fn custom_hosts ( & self ) -> & [ HostEntry ] {
136+ self . custom_hosts . as_deref ( ) . unwrap_or ( & [ ] )
137+ }
130138}
131139
132140#[ derive( Clone , Deserialize , JsonSchema , Default ) ]
@@ -292,3 +300,10 @@ pub enum Addresses {
292300pub struct Vector {
293301 pub address : String ,
294302}
303+
304+ #[ derive( Clone , Deserialize , JsonSchema ) ]
305+ #[ serde( rename_all = "snake_case" , deny_unknown_fields) ]
306+ pub struct HostEntry {
307+ pub ip : String ,
308+ pub hostname : String ,
309+ }
Original file line number Diff line number Diff line change @@ -242,12 +242,7 @@ impl Actor {
242242 ) ;
243243
244244 // hosts file content
245- let hosts_content = indoc ! (
246- "
247- 127.0.0.1 localhost
248- ::1 localhost ip6-localhost ip6-loopback
249- "
250- ) ;
245+ let hosts_content = build_hosts_content ( ctx) ;
251246
252247 // Write all files in parallel
253248 tracing:: info!(
@@ -775,6 +770,21 @@ impl Actor {
775770 }
776771}
777772
773+ fn build_hosts_content ( ctx : & Ctx ) -> String {
774+ let mut content = indoc ! (
775+ "
776+ 127.0.0.1 localhost
777+ ::1 localhost ip6-localhost ip6-loopback
778+ "
779+ ) . to_string ( ) ;
780+
781+ for host_entry in ctx. config ( ) . runner . custom_hosts ( ) {
782+ content. push_str ( & format ! ( "{}\t {}\n " , host_entry. ip, host_entry. hostname) ) ;
783+ }
784+
785+ content
786+ }
787+
778788async fn bind_ports_inner (
779789 ctx : & Ctx ,
780790 actor_id : Uuid ,
You can’t perform that action at this time.
0 commit comments