Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Add inherit_network and allow_ip_name_lookup to C API (#13145)

Igor Stepanenkoa123c8c23f0e
diff --git a/crates/c-api/include/wasi.h b/crates/c-api/include/wasi.h
index 5f341dee67..2e87d90743 100644
--- a/crates/c-api/include/wasi.h
+++ b/crates/c-api/include/wasi.h
@@ -50,6 +50,23 @@ WASI_DECLARE_OWN(config)
*/
WASI_API_EXTERN own wasi_config_t *wasi_config_new();
+/**
+ * \brief Allow all network addresses accessible to the host.
+ *
+ * This method will inherit all network addresses meaning that any address
+ * can be bound by the guest or connected to by the guest using any
+ * protocol.
+ */
+WASI_API_EXTERN void wasi_config_inherit_network(wasi_config_t *config);
+
+/**
+ * \brief Allow usage of `wasi:sockets/ip-name-lookup`
+ *
+ * By default this is disabled.
+ */
+WASI_API_EXTERN void wasi_config_allow_ip_name_lookup(wasi_config_t *config,
+ bool enable);
+
/**
* \brief Sets the argv list for this configuration object.
*
diff --git a/crates/c-api/src/wasi.rs b/crates/c-api/src/wasi.rs
index a5ddf9599a..e5045ff581 100644
--- a/crates/c-api/src/wasi.rs
+++ b/crates/c-api/src/wasi.rs
@@ -50,6 +50,19 @@ pub extern "C" fn wasi_config_new() -> Box<wasi_config_t> {
})
}
+#[unsafe(no_mangle)]
+pub unsafe extern "C" fn wasi_config_inherit_network(config: &mut wasi_config_t) {
+ config.builder.inherit_network();
+}
+
+#[unsafe(no_mangle)]
+pub unsafe extern "C" fn wasi_config_allow_ip_name_lookup(
+ config: &mut wasi_config_t,
+ enable: bool,
+) {
+ config.builder.allow_ip_name_lookup(enable);
+}
+
#[unsafe(no_mangle)]
pub unsafe extern "C" fn wasi_config_set_argv(
config: &mut wasi_config_t,
diff --git a/crates/jit-debug/gdbjit.c b/crates/jit-debug/gdbjit.c
index b9f1d43e44..d1b2f626ec 100644
--- a/crates/jit-debug/gdbjit.c
+++ b/crates/jit-debug/gdbjit.c
@@ -17,7 +17,7 @@ __declspec(dllexport)
// `asm` statement.
__attribute__((weak, noinline))
#endif
- void __jit_debug_register_code() {
+void __jit_debug_register_code() {
#ifndef CFG_TARGET_OS_windows
__asm__("");
#endif