File tree Expand file tree Collapse file tree 2 files changed +31
-6
lines changed
packages/edge/infra/client Expand file tree Collapse file tree 2 files changed +31
-6
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,10 @@ pub struct Runner {
101
101
102
102
pub container_runner_binary_path : Option < PathBuf > ,
103
103
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 > > ,
104
108
}
105
109
106
110
impl Runner {
@@ -127,6 +131,10 @@ impl Runner {
127
131
. clone ( )
128
132
. unwrap_or_else ( || Path :: new ( "/usr/local/bin/rivet-isolate-v8-runner" ) . into ( ) )
129
133
}
134
+
135
+ pub fn custom_hosts ( & self ) -> & [ HostEntry ] {
136
+ self . custom_hosts . as_deref ( ) . unwrap_or ( & [ ] )
137
+ }
130
138
}
131
139
132
140
#[ derive( Clone , Deserialize , JsonSchema , Default ) ]
@@ -292,3 +300,10 @@ pub enum Addresses {
292
300
pub struct Vector {
293
301
pub address : String ,
294
302
}
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 {
242
242
) ;
243
243
244
244
// 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) ;
251
246
252
247
// Write all files in parallel
253
248
tracing:: info!(
@@ -775,6 +770,21 @@ impl Actor {
775
770
}
776
771
}
777
772
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
+
778
788
async fn bind_ports_inner (
779
789
ctx : & Ctx ,
780
790
actor_id : Uuid ,
You can’t perform that action at this time.
0 commit comments