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