Skip to content

Commit 6733539

Browse files
authored
Merge pull request #245 from Dstack-TEE/gw-info
gw: Add RPC for Gateway Info
2 parents bbcdace + 9dea60b commit 6733539

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

gateway/gateway.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ connect_top_n = 3
6161
localhost_enabled = false
6262
app_address_ns_prefix = "_dstack-app-address"
6363
workers = 32
64+
external_port = 443
6465

6566
[core.proxy.timeouts]
6667
# Timeout for establishing a connection to the target app.

gateway/rpc/proto/gateway_rpc.proto

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,23 @@ message GatewayState {
140140
repeated GatewayNodeInfo nodes = 1;
141141
repeated AppInstanceInfo apps = 2;
142142
}
143+
message InfoResponse {
144+
// The base domain of the ZT-HTTPS
145+
string base_domain = 1;
146+
// The external port of the ZT-HTTPS
147+
uint32 external_port = 2;
148+
}
143149

144150
service Gateway {
151+
145152
// Register a new proxied CVM.
146153
rpc RegisterCvm(RegisterCvmRequest) returns (RegisterCvmResponse) {}
147154
// List all ACME account URIs and the public key history of the certificates for the Content Addressable HTTPS.
148155
rpc AcmeInfo(google.protobuf.Empty) returns (AcmeInfoResponse) {}
149156
// Merge state from other Gateway instances.
150157
rpc UpdateState(GatewayState) returns (google.protobuf.Empty) {}
158+
// Get the gateway info
159+
rpc Info(google.protobuf.Empty) returns (InfoResponse) {}
151160
}
152161

153162
message RenewCertResponse {

gateway/src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ pub struct ProxyConfig {
7070
pub tls_crypto_provider: CryptoProvider,
7171
pub tls_versions: Vec<TlsVersion>,
7272
pub base_domain: String,
73+
pub external_port: u16,
7374
pub listen_addr: Ipv4Addr,
7475
pub listen_port: u16,
7576
pub agent_port: u16,

gateway/src/main_service.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ use certbot::{CertBot, WorkDir};
1313
use cmd_lib::run_cmd as cmd;
1414
use dstack_gateway_rpc::{
1515
gateway_server::{GatewayRpc, GatewayServer},
16-
AcmeInfoResponse, GatewayState, GuestAgentConfig, QuotedPublicKey, RegisterCvmRequest,
17-
RegisterCvmResponse, WireGuardConfig, WireGuardPeer,
16+
AcmeInfoResponse, GatewayState, GuestAgentConfig, InfoResponse, QuotedPublicKey,
17+
RegisterCvmRequest, RegisterCvmResponse, WireGuardConfig, WireGuardPeer,
1818
};
1919
use dstack_guest_agent_rpc::{dstack_guest_client::DstackGuestClient, RawQuoteArgs};
2020
use fs_err as fs;
@@ -780,6 +780,14 @@ impl GatewayRpc for RpcHandler {
780780
.context("failed to update state")?;
781781
Ok(())
782782
}
783+
784+
async fn info(self) -> Result<InfoResponse> {
785+
let state = self.state.lock();
786+
Ok(InfoResponse {
787+
base_domain: state.config.proxy.base_domain.clone(),
788+
external_port: state.config.proxy.external_port as u32,
789+
})
790+
}
783791
}
784792

785793
async fn get_or_generate_quote(

0 commit comments

Comments
 (0)