-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
38e3ebd
commit 96a17b3
Showing
46 changed files
with
1,151 additions
and
69 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use api_helper::{anchor::WatchIndexQuery, ctx::Ctx}; | ||
use rivet_api::models; | ||
use rivet_operation::prelude::*; | ||
|
||
use crate::auth::Auth; | ||
|
||
// MARK: GET /tunnel/tls | ||
pub async fn tls( | ||
ctx: Ctx<Auth>, | ||
_watch_index: WatchIndexQuery, | ||
) -> GlobalResult<models::ProvisionTunnelGetTlsResponse> { | ||
ctx.auth().server()?; | ||
|
||
let tunnel_tls_res = ctx.op(cluster::ops::tunnel::tls_get::Input {}).await?; | ||
|
||
let tls_config = &ctx.config().server()?.tls()?; | ||
let ca_cert_pem = tls_config.root_ca_cert_pem.read(); | ||
|
||
Ok(models::ProvisionTunnelGetTlsResponse { | ||
cert_pem: tunnel_tls_res.cert_pem.clone(), | ||
root_ca_cert_pem: ca_cert_pem.clone(), | ||
private_key_pem: tunnel_tls_res.private_key_pem.clone(), | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
7 changes: 7 additions & 0 deletions
7
packages/services/cluster/db/cluster/migrations/20250107005643_add_tunnel_tls.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CREATE TABLE tunnel_tls ( | ||
_id INT PRIMARY KEY, -- Solely to allow ON CONFLICT, there should only be 1 row in this table | ||
cert_pem TEXT, | ||
private_key_pem TEXT, | ||
state INT NOT NULL, -- cluster::types::TlsState | ||
expire_ts INT NOT NULL | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ pub mod get_for_game; | |
pub mod list; | ||
pub mod resolve_for_name_id; | ||
pub mod server; | ||
pub mod tunnel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod tls_get; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use chirp_workflow::prelude::*; | ||
|
||
use crate::types::TlsState; | ||
|
||
#[derive(Debug)] | ||
pub struct Input {} | ||
|
||
#[derive(Debug)] | ||
pub struct Output { | ||
pub cert_pem: String, | ||
pub private_key_pem: String, | ||
} | ||
|
||
#[operation] | ||
pub async fn cluster_datacenter_tls_get(ctx: &OperationCtx, input: &Input) -> GlobalResult<Output> { | ||
let row = sql_fetch_optional!( | ||
[ctx, (String, String)] | ||
" | ||
SELECT cert_pem, private_key_pem | ||
FROM db_cluster.tunnel_tls | ||
WHERE state != $1 | ||
", | ||
TlsState::Creating as i64, | ||
) | ||
.await?; | ||
let (cert_pem, private_key_pem) = unwrap!(row, "tunnel tls not created yet"); | ||
|
||
Ok(Output { | ||
cert_pem, | ||
private_key_pem, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.