Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Unreleased

- Rename 'session' to 'sandbox' since that is the preferred term in public documentation. ([#617](https://github.com/fastly/Viceroy/pull/617))

## 0.17.0 (2026-04-27)

- Add stub implementations for resvpnproxy hostcalls. ([#596](https://github.com/fastly/Viceroy/pull/596))
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/integration/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ mod memory;
mod profiling;
mod request;
mod response;
mod reusable_sessions;
mod reusable_sandboxes;
mod secret_store;
mod sending_response;
mod shielding;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::viceroy_test;
use hyper::{Request, StatusCode};

viceroy_test!(check_hostcalls_implemented, |is_component| {
let test = Test::using_fixture("reusable-sessions.wasm")
let test = Test::using_fixture("reusable-sandboxes.wasm")
.adapt_component(is_component)
.via_hyper();

Expand All @@ -25,7 +25,7 @@ viceroy_test!(check_hostcalls_implemented, |is_component| {
});

viceroy_test!(check_crash_causes_5xx, |is_component| {
let test = Test::using_fixture("reusable-sessions.wasm")
let test = Test::using_fixture("reusable-sandboxes.wasm")
.adapt_component(is_component)
.via_hyper();

Expand Down
4 changes: 2 additions & 2 deletions src/async_io.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use {
crate::{
error::Error,
session::Session,
sandbox::Sandbox,
wiggle_abi::{fastly_async_io::FastlyAsyncIo, types::AsyncItemHandle},
},
futures::{FutureExt, TryFutureExt},
Expand All @@ -10,7 +10,7 @@ use {
wiggle::{GuestMemory, GuestPtr},
};

impl FastlyAsyncIo for Session {
impl FastlyAsyncIo for Sandbox {
async fn select(
&mut self,
memory: &mut GuestMemory<'_>,
Expand Down
2 changes: 1 addition & 1 deletion src/collecting_body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::{
/// - Streaming in a body, from an `insert`/`replace`-style request, implemented via StreamingBody
/// - Storage of that body in the cache
/// - Streaming out of the body, from a `lookup`/`TransactionInsertBuilder:execute_and_stream_back`
/// request, from the same or a different session
/// request, from the same or a different sandbox
///
/// CollectingBody provides a place for this to happen. It accepts a `Body` as a source of data,
/// e.g. one from a `StreamingBody` or an origin response; stores the data for future retrieval;
Expand Down
4 changes: 2 additions & 2 deletions src/component/adapter/http_req.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use {
fastly::compute::http_downstream::Host as HttpDownstream,
fastly::compute::{http_req, types},
},
crate::linking::{ComponentCtx, SessionView},
crate::linking::{ComponentCtx, SandboxView},
wasmtime::component::Resource,
};

Expand All @@ -15,7 +15,7 @@ trait DsView {
}
impl DsView for ComponentCtx {
fn ds_req_handle(&self) -> Resource<http_req::Request> {
self.session().downstream_request().into()
self.sandbox().downstream_request().into()
}
}

Expand Down
70 changes: 35 additions & 35 deletions src/component/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use {
crate::component::bindings::fastly::compute::{backend, http_types, types},
crate::config::{Backend, ClientCertInfo},
crate::error::Error,
crate::sandbox::Sandbox,
crate::secret_store::SecretLookup,
crate::session::Session,
crate::wiggle_abi::SecretStoreError,
http::HeaderValue,
http::Uri,
Expand All @@ -12,7 +12,7 @@ use {
};

pub(crate) async fn register_dynamic_backend(
session: &mut Session,
sandbox: &mut Sandbox,
table: &mut ResourceTable,
prefix: String,
target: String,
Expand Down Expand Up @@ -98,7 +98,7 @@ pub(crate) async fn register_dynamic_backend(
};

let client_cert = if let Some((client_cert, client_key)) = options.client_cert {
let key_lookup = session
let key_lookup = sandbox
.secret_lookup(client_key)
.ok_or(Error::SecretStoreError(
SecretStoreError::InvalidSecretHandle(client_key),
Expand All @@ -107,7 +107,7 @@ pub(crate) async fn register_dynamic_backend(
SecretLookup::Standard {
store_name,
secret_name,
} => session
} => sandbox
.secret_stores()
.get_store(store_name)
.ok_or(Error::SecretStoreError(
Expand Down Expand Up @@ -147,7 +147,7 @@ pub(crate) async fn register_dynamic_backend(
health: crate::config::BackendHealth::Unknown,
};

if !session.add_backend(name, new_backend) {
if !sandbox.add_backend(name, new_backend) {
return Err(Error::BackendNameRegistryError(name.to_string()).into());
}

Expand All @@ -156,51 +156,51 @@ pub(crate) async fn register_dynamic_backend(
Ok(res)
}

pub(crate) fn exists(session: &mut Session, backend: &str) -> bool {
session.backend(backend).is_some()
pub(crate) fn exists(sandbox: &mut Sandbox, backend: &str) -> bool {
sandbox.backend(backend).is_some()
}

pub(crate) fn is_healthy(
session: &mut Session,
sandbox: &mut Sandbox,
backend: &str,
) -> Result<backend::BackendHealth, types::Error> {
let backend = session.backend(backend).ok_or(Error::InvalidArgument)?;
let backend = sandbox.backend(backend).ok_or(Error::InvalidArgument)?;
match &backend.health {
crate::config::BackendHealth::Unknown => Ok(backend::BackendHealth::Unknown),
crate::config::BackendHealth::Healthy => Ok(backend::BackendHealth::Healthy),
crate::config::BackendHealth::Unhealthy => Ok(backend::BackendHealth::Unhealthy),
}
}

pub(crate) fn is_dynamic(session: &mut Session, backend: &str) -> Result<bool, types::Error> {
if session.dynamic_backend(backend).is_some() {
pub(crate) fn is_dynamic(sandbox: &mut Sandbox, backend: &str) -> Result<bool, types::Error> {
if sandbox.dynamic_backend(backend).is_some() {
Ok(true)
} else if session.backend(backend).is_some() {
} else if sandbox.backend(backend).is_some() {
Ok(false)
} else {
Err(Error::InvalidArgument.into())
}
}

pub(crate) fn get_host(
session: &mut Session,
sandbox: &mut Sandbox,
backend: &str,
_max_len: u64,
) -> Result<String, types::Error> {
// just doing this to get a different error if the backend doesn't exist
let _ = session.backend(backend).ok_or(Error::InvalidArgument)?;
let _ = sandbox.backend(backend).ok_or(Error::InvalidArgument)?;
Err(Error::Unsupported {
msg: "`get-host` is not actually supported in Viceroy",
}
.into())
}

pub(crate) fn get_override_host(
session: &mut Session,
sandbox: &mut Sandbox,
backend: &str,
max_len: u64,
) -> Result<Option<Vec<u8>>, types::Error> {
let backend = session.backend(backend).ok_or(Error::InvalidArgument)?;
let backend = sandbox.backend(backend).ok_or(Error::InvalidArgument)?;
if let Some(host) = backend.override_host.as_ref() {
let host = host.to_str()?;

Expand All @@ -218,8 +218,8 @@ pub(crate) fn get_override_host(
}
}

pub(crate) fn get_port(session: &mut Session, backend: &str) -> Result<u16, types::Error> {
let backend = session.backend(backend).ok_or(Error::InvalidArgument)?;
pub(crate) fn get_port(sandbox: &mut Sandbox, backend: &str) -> Result<u16, types::Error> {
let backend = sandbox.backend(backend).ok_or(Error::InvalidArgument)?;
match backend.uri.port_u16() {
Some(port) => Ok(port),
None => {
Expand All @@ -233,52 +233,52 @@ pub(crate) fn get_port(session: &mut Session, backend: &str) -> Result<u16, type
}

pub(crate) fn get_connect_timeout_ms(
session: &mut Session,
sandbox: &mut Sandbox,
backend: &str,
) -> Result<u32, types::Error> {
// just doing this to get a different error if the backend doesn't exist
let _ = session.backend(backend).ok_or(Error::InvalidArgument)?;
let _ = sandbox.backend(backend).ok_or(Error::InvalidArgument)?;
Err(Error::Unsupported {
msg: "connection timing is not actually supported in Viceroy",
}
.into())
}

pub(crate) fn get_first_byte_timeout_ms(
session: &mut Session,
sandbox: &mut Sandbox,
backend: &str,
) -> Result<u32, types::Error> {
// just doing this to get a different error if the backend doesn't exist
let _ = session.backend(backend).ok_or(Error::InvalidArgument)?;
let _ = sandbox.backend(backend).ok_or(Error::InvalidArgument)?;
Err(Error::Unsupported {
msg: "connection timing is not actually supported in Viceroy",
}
.into())
}

pub(crate) fn get_between_bytes_timeout_ms(
session: &mut Session,
sandbox: &mut Sandbox,
backend: &str,
) -> Result<u32, types::Error> {
// just doing this to get a different error if the backend doesn't exist
let _ = session.backend(backend).ok_or(Error::InvalidArgument)?;
let _ = sandbox.backend(backend).ok_or(Error::InvalidArgument)?;
Err(Error::Unsupported {
msg: "connection timing is not actually supported in Viceroy",
}
.into())
}

pub(crate) fn is_tls(session: &mut Session, backend: &str) -> Result<bool, types::Error> {
let backend = session.backend(backend).ok_or(Error::InvalidArgument)?;
pub(crate) fn is_tls(sandbox: &mut Sandbox, backend: &str) -> Result<bool, types::Error> {
let backend = sandbox.backend(backend).ok_or(Error::InvalidArgument)?;
Ok(backend.uri.scheme() == Some(&http::uri::Scheme::HTTPS))
}

pub(crate) fn get_tls_min_version(
session: &mut Session,
sandbox: &mut Sandbox,
backend: &str,
) -> Result<Option<http_types::TlsVersion>, types::Error> {
// just doing this to get a different error if the backend doesn't exist
let _ = session.backend(backend).ok_or(Error::InvalidArgument)?;
let _ = sandbox.backend(backend).ok_or(Error::InvalidArgument)?;
// health checks are not enabled in Viceroy :(
Err(Error::Unsupported {
msg: "tls version flags are not supported in Viceroy",
Expand All @@ -287,11 +287,11 @@ pub(crate) fn get_tls_min_version(
}

pub(crate) fn get_tls_max_version(
session: &mut Session,
sandbox: &mut Sandbox,
backend: &str,
) -> Result<Option<http_types::TlsVersion>, types::Error> {
// just doing this to get a different error if the backend doesn't exist
let _ = session.backend(backend).ok_or(Error::InvalidArgument)?;
let _ = sandbox.backend(backend).ok_or(Error::InvalidArgument)?;
// health checks are not enabled in Viceroy :(
Err(Error::Unsupported {
msg: "tls version flags are not supported in Viceroy",
Expand All @@ -300,7 +300,7 @@ pub(crate) fn get_tls_max_version(
}

pub(crate) fn get_http_keepalive_time(
_session: &mut Session,
_sandbox: &mut Sandbox,
_backend: &str,
) -> Result<backend::TimeoutMs, types::Error> {
Err(Error::Unsupported {
Expand All @@ -310,7 +310,7 @@ pub(crate) fn get_http_keepalive_time(
}

pub(crate) fn get_tcp_keepalive_enable(
_session: &mut Session,
_sandbox: &mut Sandbox,
_backend: &str,
) -> Result<bool, types::Error> {
Err(Error::Unsupported {
Expand All @@ -320,7 +320,7 @@ pub(crate) fn get_tcp_keepalive_enable(
}

pub(crate) fn get_tcp_keepalive_interval(
_session: &mut Session,
_sandbox: &mut Sandbox,
_backend: &str,
) -> Result<backend::TimeoutSecs, types::Error> {
Err(Error::Unsupported {
Expand All @@ -330,7 +330,7 @@ pub(crate) fn get_tcp_keepalive_interval(
}

pub(crate) fn get_tcp_keepalive_probes(
_session: &mut Session,
_sandbox: &mut Sandbox,
_backend: &str,
) -> Result<backend::ProbeCount, types::Error> {
Err(Error::Unsupported {
Expand All @@ -340,7 +340,7 @@ pub(crate) fn get_tcp_keepalive_probes(
}

pub(crate) fn get_tcp_keepalive_time(
_session: &mut Session,
_sandbox: &mut Sandbox,
_backend: &str,
) -> Result<backend::TimeoutSecs, types::Error> {
Err(Error::Unsupported {
Expand Down
8 changes: 4 additions & 4 deletions src/component/compute/acl.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::component::bindings::fastly::compute::{acl, http_body, types};
use crate::linking::{ComponentCtx, SessionView};
use crate::linking::{ComponentCtx, SandboxView};
use std::net::IpAddr;
use wasmtime::component::Resource;

Expand All @@ -8,7 +8,7 @@ impl acl::Host for ComponentCtx {}
impl acl::HostAcl for ComponentCtx {
fn open(&mut self, acl_name: String) -> Result<Resource<acl::Acl>, types::OpenError> {
let handle = self
.session_mut()
.sandbox_mut()
.acl_handle_by_name(&acl_name)
.ok_or(types::OpenError::NotFound)?;
Ok(handle.into())
Expand All @@ -19,15 +19,15 @@ impl acl::HostAcl for ComponentCtx {
acl_handle: Resource<acl::Acl>,
ip_addr: acl::IpAddress,
) -> Result<Option<Resource<http_body::Body>>, acl::AclError> {
let acl = self.session().acl_by_handle(acl_handle.into()).unwrap();
let acl = self.sandbox().acl_by_handle(acl_handle.into()).unwrap();

let ip: IpAddr = ip_addr.into();

match acl.lookup(ip) {
Some(entry) => {
let body =
serde_json::to_vec_pretty(&entry).map_err(|_| acl::AclError::GenericError)?;
let body_handle = self.session_mut().insert_body(body.into());
let body_handle = self.sandbox_mut().insert_body(body.into());
Ok(Some(body_handle.into()))
}
None => Ok(None),
Expand Down
Loading
Loading