mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
@@ -1,6 +1,8 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { HostId } from "./HostId";
|
||||
|
||||
export type GetServicePortForwardParams = {
|
||||
packageId: string | null;
|
||||
internalPort: number;
|
||||
hostId: HostId;
|
||||
};
|
||||
|
||||
@@ -24,7 +24,7 @@ export type ServerInfo = {
|
||||
torAddress: string;
|
||||
ipInfo: { [key: string]: IpInfo };
|
||||
statusInfo: ServerStatus;
|
||||
wifi: WifiInfo;
|
||||
wifi: WifiInfo | null;
|
||||
unreadNotificationCount: number;
|
||||
passwordHash: string;
|
||||
pubkey: string;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type WifiInfo = {
|
||||
interface: string;
|
||||
ssids: Array<string>;
|
||||
selected: string | null;
|
||||
connected: string | null;
|
||||
|
||||
@@ -96,7 +96,11 @@ pub async fn recover_full_embassy(
|
||||
.with_kind(ErrorKind::PasswordHashGeneration)?;
|
||||
|
||||
let db = ctx.db().await?;
|
||||
db.put(&ROOT, &Database::init(&os_backup.account)?).await?;
|
||||
db.put(
|
||||
&ROOT,
|
||||
&Database::init(&os_backup.account, ctx.config.wifi_interface.clone())?,
|
||||
)
|
||||
.await?;
|
||||
drop(db);
|
||||
|
||||
init(&ctx.config).await?;
|
||||
|
||||
@@ -324,7 +324,7 @@ pub struct UiParams {
|
||||
// #[command(display(display_serializable))]
|
||||
#[instrument(skip_all)]
|
||||
pub async fn ui(ctx: RpcContext, UiParams { pointer, value, .. }: UiParams) -> Result<(), Error> {
|
||||
let ptr = "/ui"
|
||||
let ptr = "/public/ui"
|
||||
.parse::<JsonPointer>()
|
||||
.with_kind(ErrorKind::Database)?
|
||||
+ &pointer;
|
||||
|
||||
@@ -2,7 +2,6 @@ use std::collections::BTreeMap;
|
||||
|
||||
use patch_db::HasModel;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use ts_rs::TS;
|
||||
|
||||
use crate::account::AccountInfo;
|
||||
use crate::auth::Sessions;
|
||||
@@ -28,9 +27,9 @@ pub struct Database {
|
||||
pub private: Private,
|
||||
}
|
||||
impl Database {
|
||||
pub fn init(account: &AccountInfo) -> Result<Self, Error> {
|
||||
pub fn init(account: &AccountInfo, wifi_interface: Option<String>) -> Result<Self, Error> {
|
||||
Ok(Self {
|
||||
public: Public::init(account)?,
|
||||
public: Public::init(account, wifi_interface)?,
|
||||
private: Private {
|
||||
key_store: KeyStore::new(account)?,
|
||||
password: account.password.clone(),
|
||||
|
||||
@@ -35,7 +35,7 @@ pub struct Public {
|
||||
pub ui: Value,
|
||||
}
|
||||
impl Public {
|
||||
pub fn init(account: &AccountInfo) -> Result<Self, Error> {
|
||||
pub fn init(account: &AccountInfo, wifi_interface: Option<String>) -> Result<Self, Error> {
|
||||
let lan_address = account.hostname.lan_address().parse().unwrap();
|
||||
Ok(Self {
|
||||
server_info: ServerInfo {
|
||||
@@ -60,11 +60,12 @@ impl Public {
|
||||
shutting_down: false,
|
||||
restarting: false,
|
||||
},
|
||||
wifi: WifiInfo {
|
||||
wifi: wifi_interface.map(|interface| WifiInfo {
|
||||
interface,
|
||||
ssids: Vec::new(),
|
||||
connected: None,
|
||||
selected: None,
|
||||
},
|
||||
}),
|
||||
unread_notification_count: 0,
|
||||
password_hash: account.password.clone(),
|
||||
pubkey: ssh_key::PublicKey::from(&account.ssh_key)
|
||||
@@ -131,7 +132,7 @@ pub struct ServerInfo {
|
||||
pub ip_info: BTreeMap<String, IpInfo>,
|
||||
#[serde(default)]
|
||||
pub status_info: ServerStatus,
|
||||
pub wifi: WifiInfo,
|
||||
pub wifi: Option<WifiInfo>,
|
||||
#[ts(type = "number")]
|
||||
pub unread_notification_count: u64,
|
||||
pub password_hash: String,
|
||||
@@ -206,6 +207,7 @@ pub struct UpdateProgress {
|
||||
#[model = "Model<Self>"]
|
||||
#[ts(export)]
|
||||
pub struct WifiInfo {
|
||||
pub interface: String,
|
||||
pub ssids: Vec<String>,
|
||||
pub selected: Option<String>,
|
||||
pub connected: Option<String>,
|
||||
|
||||
@@ -111,7 +111,7 @@ impl VHostServer {
|
||||
_thread: tokio::spawn(async move {
|
||||
loop {
|
||||
match listener.accept().await {
|
||||
Ok((stream, sock_addr)) => {
|
||||
Ok((stream, _)) => {
|
||||
let stream =
|
||||
Box::pin(TimeoutStream::new(stream, Duration::from_secs(300)));
|
||||
let mut stream = BackTrackingReader::new(stream);
|
||||
@@ -195,9 +195,22 @@ impl VHostServer {
|
||||
.as_ref()
|
||||
.into_iter()
|
||||
.map(InternedString::intern)
|
||||
.chain(std::iter::once(InternedString::from_display(
|
||||
&sock_addr.ip(),
|
||||
)))
|
||||
.chain(
|
||||
db.peek()
|
||||
.await
|
||||
.into_public()
|
||||
.into_server_info()
|
||||
.into_ip_info()
|
||||
.into_entries()?
|
||||
.into_iter()
|
||||
.flat_map(|(_, ips)| [
|
||||
ips.as_ipv4().de().map(|ip| ip.map(IpAddr::V4)),
|
||||
ips.as_ipv6().de().map(|ip| ip.map(IpAddr::V6))
|
||||
])
|
||||
.filter_map(|a| a.transpose())
|
||||
.map(|a| a.map(|ip| InternedString::from_display(&ip)))
|
||||
.collect::<Result<Vec<_>, _>>()?,
|
||||
)
|
||||
.collect();
|
||||
let key = db
|
||||
.mutate(|v| {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use clap::Parser;
|
||||
use imbl_value::Value;
|
||||
use imbl_value::{json, Value};
|
||||
use models::PackageId;
|
||||
use rpc_toolkit::command;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -24,7 +24,10 @@ pub async fn properties(
|
||||
PropertiesParam { id }: PropertiesParam,
|
||||
) -> Result<Value, Error> {
|
||||
match &*ctx.services.get(&id).await {
|
||||
Some(service) => service.properties().await,
|
||||
Some(service) => Ok(json!({
|
||||
"version": 2,
|
||||
"data": service.properties().await?
|
||||
})),
|
||||
None => Err(Error::new(
|
||||
eyre!("Could not find a service with id {id}"),
|
||||
ErrorKind::NotFound,
|
||||
|
||||
@@ -19,7 +19,7 @@ fn current_version() -> Version {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, HasModel)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
#[model = "Model<Self>"]
|
||||
pub struct Manifest {
|
||||
#[serde(default = "current_version")]
|
||||
@@ -54,7 +54,7 @@ pub struct Manifest {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
#[serde(tag = "type")]
|
||||
pub enum DependencyRequirement {
|
||||
OptIn { how: String },
|
||||
@@ -68,7 +68,7 @@ impl DependencyRequirement {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, HasModel)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
#[model = "Model<Self>"]
|
||||
pub struct DepInfo {
|
||||
pub version: VersionRange,
|
||||
@@ -77,7 +77,7 @@ pub struct DepInfo {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct Assets {
|
||||
#[serde(default)]
|
||||
pub license: Option<PathBuf>,
|
||||
|
||||
@@ -419,7 +419,11 @@ async fn fresh_setup(
|
||||
) -> Result<(Hostname, OnionAddressV3, X509), Error> {
|
||||
let account = AccountInfo::new(start_os_password, root_ca_start_time().await?)?;
|
||||
let db = ctx.db().await?;
|
||||
db.put(&ROOT, &Database::init(&account)?).await?;
|
||||
db.put(
|
||||
&ROOT,
|
||||
&Database::init(&account, ctx.config.wifi_interface.clone())?,
|
||||
)
|
||||
.await?;
|
||||
drop(db);
|
||||
init(&ctx.config).await?;
|
||||
Ok((
|
||||
|
||||
@@ -76,6 +76,7 @@ export const mockPatchData: DataModel = {
|
||||
zram: true,
|
||||
governor: 'performance',
|
||||
wifi: {
|
||||
interface: 'wlan0',
|
||||
ssids: [],
|
||||
selected: null,
|
||||
connected: null,
|
||||
|
||||
Reference in New Issue
Block a user