returns lan address on setup completion, qualifies embassy urls with … (#696)

* returns lan address on setup completion, qualifies embassy urls with protocols

* move hostname sync to post-setup, calculate hostname directly
This commit is contained in:
Keagan McClelland
2021-10-18 16:35:26 -06:00
committed by Aiden McClelland
parent 09d4736044
commit 0f9c20f5f8
2 changed files with 12 additions and 3 deletions

View File

@@ -24,7 +24,6 @@ fn status_fn(_: i32) -> StatusCode {
#[instrument] #[instrument]
async fn init(cfg_path: Option<&str>) -> Result<(), Error> { async fn init(cfg_path: Option<&str>) -> Result<(), Error> {
// return Err(eyre!("Test failure").with_kind(embassy::ErrorKind::Unknown));
let cfg = RpcContextConfig::load(cfg_path).await?; let cfg = RpcContextConfig::load(cfg_path).await?;
embassy::disk::util::mount("LABEL=EMBASSY", "/embassy-os").await?; embassy::disk::util::mount("LABEL=EMBASSY", "/embassy-os").await?;
if tokio::fs::metadata("/embassy-os/disk.guid").await.is_err() { if tokio::fs::metadata("/embassy-os/disk.guid").await.is_err() {

View File

@@ -79,6 +79,13 @@ pub async fn recovery_status(
ctx.recovery_status.read().await.clone().transpose() ctx.recovery_status.read().await.clone().transpose()
} }
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct SetupResult {
tor_address: String,
lan_address: String,
}
#[command(rpc_only)] #[command(rpc_only)]
pub async fn execute( pub async fn execute(
#[context] ctx: SetupContext, #[context] ctx: SetupContext,
@@ -86,7 +93,7 @@ pub async fn execute(
#[arg(rename = "embassy-password")] embassy_password: String, #[arg(rename = "embassy-password")] embassy_password: String,
#[arg(rename = "recovery-drive")] recovery_drive: Option<DiskInfo>, #[arg(rename = "recovery-drive")] recovery_drive: Option<DiskInfo>,
#[arg(rename = "recovery-password")] recovery_password: Option<String>, #[arg(rename = "recovery-password")] recovery_password: Option<String>,
) -> Result<String, Error> { ) -> Result<SetupResult, Error> {
match execute_inner( match execute_inner(
ctx, ctx,
embassy_logicalname, embassy_logicalname,
@@ -98,7 +105,10 @@ pub async fn execute(
{ {
Ok(a) => { Ok(a) => {
tracing::info!("Setup Successful! Tor Address: {}", a); tracing::info!("Setup Successful! Tor Address: {}", a);
Ok(a) Ok(SetupResult {
tor_address: format!("http://{}", a),
lan_address: format!("https://embassy-{}.local", crate::hostname::get_id().await?),
})
} }
Err(e) => { Err(e) => {
tracing::error!("Error Setting Up Embassy: {}", e); tracing::error!("Error Setting Up Embassy: {}", e);