Skip to content

Commit 79f4777

Browse files
committed
chore: remove headers through guard
1 parent a7d0289 commit 79f4777

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

engine/packages/guard-core/src/proxy_service.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ use crate::{
3535
request_context::RequestContext,
3636
};
3737

38+
const X_RIVET_TARGET: HeaderName = HeaderName::from_static("x-rivet-target");
39+
const X_RIVET_ACTOR: HeaderName = HeaderName::from_static("x-rivet-actor");
40+
const X_RIVET_TOKEN: HeaderName = HeaderName::from_static("x-rivet-token");
3841
pub const X_FORWARDED_FOR: HeaderName = HeaderName::from_static("x-forwarded-for");
3942
pub const X_RIVET_ERROR: HeaderName = HeaderName::from_static("x-rivet-error");
43+
4044
const ROUTE_CACHE_TTL: Duration = Duration::from_secs(60 * 10); // 10 minutes
4145
const PROXY_STATE_CACHE_TTL: Duration = Duration::from_secs(60 * 60); // 1 hour
4246
const WEBSOCKET_CLOSE_LINGER: Duration = Duration::from_millis(100); // Keep TCP connection open briefly after WebSocket close
@@ -1060,6 +1064,7 @@ impl ProxyService {
10601064
}
10611065
}
10621066

1067+
/// Modifies the incoming request before it is proxied.
10631068
fn proxied_request_builder(
10641069
&self,
10651070
req_parts: &hyper::http::request::Parts,
@@ -1089,13 +1094,16 @@ impl ProxyService {
10891094
.method(req_parts.method.clone())
10901095
.uri(url.to_string());
10911096

1092-
// Add proxy headers
1093-
{
1094-
let headers = builder
1095-
.headers_mut()
1096-
.expect("request builder unexpectedly in error state");
1097-
add_proxy_headers_with_addr(headers, &req_parts.headers, self.remote_addr)?;
1098-
}
1097+
// Modify proxy headers
1098+
let headers = builder
1099+
.headers_mut()
1100+
.expect("request builder unexpectedly in error state");
1101+
1102+
headers.remove(X_RIVET_TARGET);
1103+
headers.remove(X_RIVET_ACTOR);
1104+
headers.remove(X_RIVET_TOKEN);
1105+
1106+
add_proxy_headers_with_addr(headers, &req_parts.headers, self.remote_addr)?;
10991107

11001108
Ok(builder)
11011109
}

engine/packages/guard/src/routing/pegboard_gateway.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use crate::{errors, shared_state::SharedState};
1010

1111
const ACTOR_READY_TIMEOUT: Duration = Duration::from_secs(10);
1212
pub const X_RIVET_ACTOR: HeaderName = HeaderName::from_static("x-rivet-actor");
13-
pub const X_RIVET_AMESPACE: HeaderName = HeaderName::from_static("x-rivet-namespace");
1413
const WS_PROTOCOL_ACTOR: &str = "rivet_actor.";
1514

1615
/// Route requests to actor services using path-based routing

engine/packages/universaldb/src/driver/rocksdb/transaction_task.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl TransactionTask {
137137
}
138138
}
139139

140-
fn create_transaction(&self) -> RocksDbTransaction<OptimisticTransactionDB> {
140+
fn create_transaction(&self) -> RocksDbTransaction<'_, OptimisticTransactionDB> {
141141
let write_opts = WriteOptions::default();
142142
let txn_opts = rocksdb::OptimisticTransactionOptions::default();
143143
self.db.transaction_opt(&write_opts, &txn_opts)

0 commit comments

Comments
 (0)