From c485edfa120c23ecb63b311bcf2f4c074bb00a43 Mon Sep 17 00:00:00 2001 From: Aiden McClelland Date: Thu, 12 Mar 2026 13:38:01 -0600 Subject: [PATCH] feat: tunnel TS exports, port forward labels, and db migrations - Add TS derive and type annotations to all tunnel API param structs - Export tunnel bindings to a tunnel/ subdirectory with index generation - Change port forward label from String to Option - Add TunnelDatabase::init() with default subnet creation - Add tunnel migration framework with m_00_port_forward_entry migration to convert legacy string-only port forwards to the new entry format --- Makefile | 4 ++ core/src/tunnel/api.rs | 48 +++++++++++++------ core/src/tunnel/context.rs | 25 ++++------ core/src/tunnel/db.rs | 48 +++++++++++++++++-- .../migrations/m_00_port_forward_entry.rs | 20 ++++++++ core/src/tunnel/migrations/mod.rs | 34 +++++++++++++ core/src/tunnel/mod.rs | 1 + .../lib/osBindings/AddPackageSignerParams.ts | 2 +- sdk/base/lib/osBindings/ServerInfo.ts | 2 +- sdk/base/lib/osBindings/index.ts | 1 + .../lib/osBindings/tunnel/AddDeviceParams.ts | 7 +++ .../lib/osBindings/tunnel/AddKeyParams.ts | 4 ++ .../osBindings/tunnel/AddPortForwardParams.ts | 7 +++ .../lib/osBindings/tunnel/AddSubnetParams.ts | 3 ++ sdk/base/lib/osBindings/tunnel/GatewayId.ts | 3 ++ sdk/base/lib/osBindings/tunnel/GatewayType.ts | 3 ++ sdk/base/lib/osBindings/tunnel/IpInfo.ts | 13 +++++ .../osBindings/tunnel/ListDevicesParams.ts | 3 ++ .../osBindings/tunnel/NetworkInterfaceInfo.ts | 10 ++++ .../osBindings/tunnel/NetworkInterfaceType.ts | 8 ++++ .../lib/osBindings/tunnel/PortForwardEntry.ts | 7 +++ .../lib/osBindings/tunnel/PortForwards.ts | 3 +- .../osBindings/tunnel/RemoveDeviceParams.ts | 3 ++ .../lib/osBindings/tunnel/RemoveKeyParams.ts | 4 ++ .../tunnel/RemovePortForwardParams.ts | 3 ++ .../osBindings/tunnel/SetPasswordParams.ts | 3 ++ .../tunnel/SetPortForwardEnabledParams.ts | 3 ++ .../lib/osBindings/tunnel/ShowConfigParams.ts | 7 +++ .../lib/osBindings/tunnel/SubnetParams.ts | 3 ++ .../lib/osBindings/tunnel/TunnelDatabase.ts | 4 +- .../tunnel/UpdatePortForwardLabelParams.ts | 6 +++ sdk/base/lib/osBindings/tunnel/index.ts | 35 ++++++++++++++ 32 files changed, 288 insertions(+), 39 deletions(-) create mode 100644 core/src/tunnel/migrations/m_00_port_forward_entry.rs create mode 100644 core/src/tunnel/migrations/mod.rs create mode 100644 sdk/base/lib/osBindings/tunnel/AddDeviceParams.ts create mode 100644 sdk/base/lib/osBindings/tunnel/AddKeyParams.ts create mode 100644 sdk/base/lib/osBindings/tunnel/AddPortForwardParams.ts create mode 100644 sdk/base/lib/osBindings/tunnel/AddSubnetParams.ts create mode 100644 sdk/base/lib/osBindings/tunnel/GatewayId.ts create mode 100644 sdk/base/lib/osBindings/tunnel/GatewayType.ts create mode 100644 sdk/base/lib/osBindings/tunnel/IpInfo.ts create mode 100644 sdk/base/lib/osBindings/tunnel/ListDevicesParams.ts create mode 100644 sdk/base/lib/osBindings/tunnel/NetworkInterfaceInfo.ts create mode 100644 sdk/base/lib/osBindings/tunnel/NetworkInterfaceType.ts create mode 100644 sdk/base/lib/osBindings/tunnel/PortForwardEntry.ts create mode 100644 sdk/base/lib/osBindings/tunnel/RemoveDeviceParams.ts create mode 100644 sdk/base/lib/osBindings/tunnel/RemoveKeyParams.ts create mode 100644 sdk/base/lib/osBindings/tunnel/RemovePortForwardParams.ts create mode 100644 sdk/base/lib/osBindings/tunnel/SetPasswordParams.ts create mode 100644 sdk/base/lib/osBindings/tunnel/SetPortForwardEnabledParams.ts create mode 100644 sdk/base/lib/osBindings/tunnel/ShowConfigParams.ts create mode 100644 sdk/base/lib/osBindings/tunnel/SubnetParams.ts create mode 100644 sdk/base/lib/osBindings/tunnel/UpdatePortForwardLabelParams.ts create mode 100644 sdk/base/lib/osBindings/tunnel/index.ts diff --git a/Makefile b/Makefile index 07aabb16f..d04824d67 100644 --- a/Makefile +++ b/Makefile @@ -283,6 +283,10 @@ core/bindings/index.ts: $(call ls-files, core) $(ENVIRONMENT_FILE) rm -rf core/bindings ./core/build/build-ts.sh ls core/bindings/*.ts | sed 's/core\/bindings\/\([^.]*\)\.ts/export { \1 } from ".\/\1";/g' | grep -v '"./index"' | tee core/bindings/index.ts + if [ -d core/bindings/tunnel ]; then \ + ls core/bindings/tunnel/*.ts | sed 's/core\/bindings\/tunnel\/\([^.]*\)\.ts/export { \1 } from ".\/\1";/g' | grep -v '"./index"' > core/bindings/tunnel/index.ts; \ + echo 'export * as Tunnel from "./tunnel";' >> core/bindings/index.ts; \ + fi npm --prefix sdk/base exec -- prettier --config=./sdk/base/package.json -w './core/bindings/**/*.ts' touch core/bindings/index.ts diff --git a/core/src/tunnel/api.rs b/core/src/tunnel/api.rs index 523dc3900..51fff1714 100644 --- a/core/src/tunnel/api.rs +++ b/core/src/tunnel/api.rs @@ -5,6 +5,7 @@ use imbl_value::InternedString; use ipnet::Ipv4Net; use rpc_toolkit::{Context, Empty, HandlerArgs, HandlerExt, ParentHandler, from_fn_async}; use serde::{Deserialize, Serialize}; +use ts_rs::TS; use crate::context::CliContext; use crate::db::model::public::NetworkInterfaceType; @@ -90,9 +91,10 @@ pub fn tunnel_api() -> ParentHandler { ) } -#[derive(Deserialize, Serialize, Parser)] +#[derive(Deserialize, Serialize, Parser, TS)] #[serde(rename_all = "camelCase")] pub struct SubnetParams { + #[ts(type = "string")] subnet: Ipv4Net, } @@ -168,7 +170,7 @@ pub fn device_api() -> ParentHandler { ) } -#[derive(Deserialize, Serialize, Parser)] +#[derive(Deserialize, Serialize, Parser, TS)] #[serde(rename_all = "camelCase")] pub struct AddSubnetParams { name: InternedString, @@ -293,11 +295,13 @@ pub async fn remove_subnet( Ok(()) } -#[derive(Deserialize, Serialize, Parser)] +#[derive(Deserialize, Serialize, Parser, TS)] #[serde(rename_all = "camelCase")] pub struct AddDeviceParams { + #[ts(type = "string")] subnet: Ipv4Net, name: InternedString, + #[ts(type = "string | null")] ip: Option, } @@ -354,10 +358,12 @@ pub async fn add_device( server.sync().await } -#[derive(Deserialize, Serialize, Parser)] +#[derive(Deserialize, Serialize, Parser, TS)] #[serde(rename_all = "camelCase")] pub struct RemoveDeviceParams { + #[ts(type = "string")] subnet: Ipv4Net, + #[ts(type = "string")] ip: Ipv4Addr, } @@ -383,9 +389,10 @@ pub async fn remove_device( ctx.gc_forwards(&keep).await } -#[derive(Deserialize, Serialize, Parser)] +#[derive(Deserialize, Serialize, Parser, TS)] #[serde(rename_all = "camelCase")] pub struct ListDevicesParams { + #[ts(type = "string")] subnet: Ipv4Net, } @@ -403,14 +410,18 @@ pub async fn list_devices( .de() } -#[derive(Deserialize, Serialize, Parser)] +#[derive(Deserialize, Serialize, Parser, TS)] #[serde(rename_all = "camelCase")] pub struct ShowConfigParams { + #[ts(type = "string")] subnet: Ipv4Net, + #[ts(type = "string")] ip: Ipv4Addr, + #[ts(type = "string | null")] wan_addr: Option, #[serde(rename = "__ConnectInfo_local_addr")] #[arg(skip)] + #[ts(skip)] local_addr: Option, } @@ -465,13 +476,15 @@ pub async fn show_config( .to_string()) } -#[derive(Deserialize, Serialize, Parser)] +#[derive(Deserialize, Serialize, Parser, TS)] #[serde(rename_all = "camelCase")] pub struct AddPortForwardParams { + #[ts(type = "string")] source: SocketAddrV4, + #[ts(type = "string")] target: SocketAddrV4, #[arg(long)] - label: String, + label: Option, } pub async fn add_forward( @@ -505,7 +518,11 @@ pub async fn add_forward( m.insert(source, rc); }); - let entry = PortForwardEntry { target, label, enabled: true }; + let entry = PortForwardEntry { + target, + label, + enabled: true, + }; ctx.db .mutate(|db| { @@ -528,9 +545,10 @@ pub async fn add_forward( Ok(()) } -#[derive(Deserialize, Serialize, Parser)] +#[derive(Deserialize, Serialize, Parser, TS)] #[serde(rename_all = "camelCase")] pub struct RemovePortForwardParams { + #[ts(type = "string")] source: SocketAddrV4, } @@ -549,11 +567,12 @@ pub async fn remove_forward( Ok(()) } -#[derive(Deserialize, Serialize, Parser)] +#[derive(Deserialize, Serialize, Parser, TS)] #[serde(rename_all = "camelCase")] pub struct UpdatePortForwardLabelParams { + #[ts(type = "string")] source: SocketAddrV4, - label: String, + label: Option, } pub async fn update_forward_label( @@ -569,7 +588,7 @@ pub async fn update_forward_label( ErrorKind::NotFound, ) })?; - entry.label = label.clone(); + entry.label = label; Ok(()) }) }) @@ -577,9 +596,10 @@ pub async fn update_forward_label( .result } -#[derive(Deserialize, Serialize, Parser)] +#[derive(Deserialize, Serialize, Parser, TS)] #[serde(rename_all = "camelCase")] pub struct SetPortForwardEnabledParams { + #[ts(type = "string")] source: SocketAddrV4, enabled: bool, } diff --git a/core/src/tunnel/context.rs b/core/src/tunnel/context.rs index 769f62787..1cb23c49e 100644 --- a/core/src/tunnel/context.rs +++ b/core/src/tunnel/context.rs @@ -10,8 +10,8 @@ use http::HeaderMap; use imbl::OrdMap; use imbl_value::InternedString; use include_dir::Dir; -use ipnet::Ipv4Net; use patch_db::PatchDb; +use patch_db::json_ptr::ROOT; use rpc_toolkit::yajrc::RpcError; use rpc_toolkit::{CallRemote, Context, Empty, ParentHandler}; use serde::{Deserialize, Serialize}; @@ -34,7 +34,8 @@ use crate::rpc_continuations::{OpenAuthedContinuations, RpcContinuations}; use crate::tunnel::TUNNEL_DEFAULT_LISTEN; use crate::tunnel::api::tunnel_api; use crate::tunnel::db::TunnelDatabase; -use crate::tunnel::wg::{WIREGUARD_INTERFACE_NAME, WgSubnetConfig}; +use crate::tunnel::migrations::run_migrations; +use crate::tunnel::wg::WIREGUARD_INTERFACE_NAME; use crate::util::collections::OrdMapIterMut; use crate::util::io::read_file_to_string; use crate::util::sync::{SyncMutex, Watch}; @@ -98,21 +99,11 @@ impl TunnelContext { tokio::fs::create_dir_all(&datadir).await?; } let db_path = datadir.join("tunnel.db"); - let db = TypedPatchDb::::load_or_init( - PatchDb::open(&db_path).await?, - || async { - let mut db = TunnelDatabase::default(); - db.wg.subnets.0.insert( - Ipv4Net::new_assert([10, 59, rand::random(), 1].into(), 24), - WgSubnetConfig { - name: "Default Subnet".into(), - ..Default::default() - }, - ); - Ok(db) - }, - ) - .await?; + let db = TypedPatchDb::::load_unchecked(PatchDb::open(&db_path).await?); + if db.dump(&ROOT).await.value.is_null() { + db.put(&ROOT, &TunnelDatabase::init()).await?; + } + db.mutate(|db| run_migrations(db)).await.result?; let listen = config.tunnel_listen.unwrap_or(TUNNEL_DEFAULT_LISTEN); let ip_info = crate::net::utils::load_ip_info().await?; let net_iface = db diff --git a/core/src/tunnel/db.rs b/core/src/tunnel/db.rs index b18c01abf..46197ce84 100644 --- a/core/src/tunnel/db.rs +++ b/core/src/tunnel/db.rs @@ -7,6 +7,7 @@ use axum::extract::ws; use clap::Parser; use imbl::{HashMap, OrdMap}; use imbl_value::InternedString; +use ipnet::Ipv4Net; use itertools::Itertools; use patch_db::Dump; use patch_db::json_ptr::{JsonPointer, ROOT}; @@ -25,25 +26,49 @@ use crate::rpc_continuations::{Guid, RpcContinuation}; use crate::sign::AnyVerifyingKey; use crate::tunnel::auth::SignerInfo; use crate::tunnel::context::TunnelContext; +use crate::tunnel::migrations; use crate::tunnel::web::WebserverInfo; -use crate::tunnel::wg::WgServer; +use crate::tunnel::wg::{WgServer, WgSubnetConfig}; use crate::util::serde::{HandlerExtSerde, apply_expr}; #[derive(Default, Deserialize, Serialize, HasModel, TS)] #[serde(rename_all = "camelCase")] #[model = "Model"] pub struct TunnelDatabase { + #[serde(default)] + #[ts(skip)] + pub migrations: BTreeSet, pub webserver: WebserverInfo, pub sessions: Sessions, pub password: Option, #[ts(as = "std::collections::HashMap::")] pub auth_pubkeys: HashMap, - #[ts(as = "std::collections::BTreeMap::")] + #[ts(as = "std::collections::BTreeMap::")] pub gateways: OrdMap, pub wg: WgServer, pub port_forwards: PortForwards, } +impl TunnelDatabase { + pub fn init() -> Self { + let mut db = Self { + migrations: migrations::MIGRATIONS + .iter() + .map(|m| m.name().into()) + .collect(), + ..Default::default() + }; + db.wg.subnets.0.insert( + Ipv4Net::new_assert([10, 59, rand::random(), 1].into(), 24), + WgSubnetConfig { + name: "Default Subnet".into(), + ..Default::default() + }, + ); + db + } +} + impl Model { pub fn gc_forwards(&mut self) -> Result, Error> { let mut keep_sources = BTreeSet::new(); @@ -67,15 +92,30 @@ impl Model { #[test] fn export_bindings_tunnel_db() { + use crate::tunnel::api::*; + use crate::tunnel::auth::{AddKeyParams, RemoveKeyParams, SetPasswordParams}; + TunnelDatabase::export_all_to("bindings/tunnel").unwrap(); + SubnetParams::export_all_to("bindings/tunnel").unwrap(); + AddSubnetParams::export_all_to("bindings/tunnel").unwrap(); + AddDeviceParams::export_all_to("bindings/tunnel").unwrap(); + RemoveDeviceParams::export_all_to("bindings/tunnel").unwrap(); + ListDevicesParams::export_all_to("bindings/tunnel").unwrap(); + ShowConfigParams::export_all_to("bindings/tunnel").unwrap(); + AddPortForwardParams::export_all_to("bindings/tunnel").unwrap(); + RemovePortForwardParams::export_all_to("bindings/tunnel").unwrap(); + UpdatePortForwardLabelParams::export_all_to("bindings/tunnel").unwrap(); + SetPortForwardEnabledParams::export_all_to("bindings/tunnel").unwrap(); + AddKeyParams::export_all_to("bindings/tunnel").unwrap(); + RemoveKeyParams::export_all_to("bindings/tunnel").unwrap(); + SetPasswordParams::export_all_to("bindings/tunnel").unwrap(); } #[derive(Clone, Debug, Deserialize, Serialize, TS)] #[serde(rename_all = "camelCase")] pub struct PortForwardEntry { pub target: SocketAddrV4, - #[serde(default)] - pub label: String, + pub label: Option, #[serde(default = "default_true")] pub enabled: bool, } diff --git a/core/src/tunnel/migrations/m_00_port_forward_entry.rs b/core/src/tunnel/migrations/m_00_port_forward_entry.rs new file mode 100644 index 000000000..32603ea9d --- /dev/null +++ b/core/src/tunnel/migrations/m_00_port_forward_entry.rs @@ -0,0 +1,20 @@ +use imbl_value::json; + +use super::TunnelMigration; +use crate::prelude::*; + +pub struct PortForwardEntry; +impl TunnelMigration for PortForwardEntry { + fn action(&self, db: &mut Value) -> Result<(), Error> { + for (_, value) in db["portForwards"].as_object_mut().unwrap().iter_mut() { + if value.is_string() { + *value = json!({ + "target": value.clone(), + "label": null, + "enabled": true, + }); + } + } + Ok(()) + } +} diff --git a/core/src/tunnel/migrations/mod.rs b/core/src/tunnel/migrations/mod.rs new file mode 100644 index 000000000..79c60403c --- /dev/null +++ b/core/src/tunnel/migrations/mod.rs @@ -0,0 +1,34 @@ +use patch_db::ModelExt; + +use crate::prelude::*; +use crate::tunnel::db::TunnelDatabase; + +mod m_00_port_forward_entry; + +pub trait TunnelMigration { + fn name(&self) -> &'static str { + let val = std::any::type_name_of_val(self); + val.rsplit_once("::").map_or(val, |v| v.1) + } + fn action(&self, db: &mut Value) -> Result<(), Error>; +} + +pub const MIGRATIONS: &[&dyn TunnelMigration] = &[ + &m_00_port_forward_entry::PortForwardEntry, +]; + +#[instrument(skip_all)] +pub fn run_migrations(db: &mut Model) -> Result<(), Error> { + let mut migrations = db.as_migrations().de().unwrap_or_default(); + for migration in MIGRATIONS { + let name = migration.name(); + if !migrations.contains(name) { + migration.action(ModelExt::as_value_mut(db))?; + migrations.insert(name.into()); + } + } + let mut db_deser = db.de()?; + db_deser.migrations = migrations; + db.ser(&db_deser)?; + Ok(()) +} diff --git a/core/src/tunnel/mod.rs b/core/src/tunnel/mod.rs index 5d69de7c0..ffb3f89b5 100644 --- a/core/src/tunnel/mod.rs +++ b/core/src/tunnel/mod.rs @@ -9,6 +9,7 @@ pub mod api; pub mod auth; pub mod context; pub mod db; +pub(crate) mod migrations; pub mod update; pub mod web; pub mod wg; diff --git a/sdk/base/lib/osBindings/AddPackageSignerParams.ts b/sdk/base/lib/osBindings/AddPackageSignerParams.ts index e9a7788ff..6baebf0c8 100644 --- a/sdk/base/lib/osBindings/AddPackageSignerParams.ts +++ b/sdk/base/lib/osBindings/AddPackageSignerParams.ts @@ -6,5 +6,5 @@ export type AddPackageSignerParams = { id: PackageId signer: Guid versions: string | null - merge?: boolean + merge: boolean } diff --git a/sdk/base/lib/osBindings/ServerInfo.ts b/sdk/base/lib/osBindings/ServerInfo.ts index a0eb98e0a..540110109 100644 --- a/sdk/base/lib/osBindings/ServerInfo.ts +++ b/sdk/base/lib/osBindings/ServerInfo.ts @@ -26,7 +26,7 @@ export type ServerInfo = { zram: boolean governor: Governor | null smtp: SmtpValue | null - ifconfigUrl: string + echoipUrls: string[] ram: number devices: Array kiosk: boolean | null diff --git a/sdk/base/lib/osBindings/index.ts b/sdk/base/lib/osBindings/index.ts index 3df8c985f..25e45f0f0 100644 --- a/sdk/base/lib/osBindings/index.ts +++ b/sdk/base/lib/osBindings/index.ts @@ -306,3 +306,4 @@ export { WifiInfo } from './WifiInfo' export { WifiListInfo } from './WifiListInfo' export { WifiListOut } from './WifiListOut' export { WifiSsidParams } from './WifiSsidParams' +export * as Tunnel from './tunnel' diff --git a/sdk/base/lib/osBindings/tunnel/AddDeviceParams.ts b/sdk/base/lib/osBindings/tunnel/AddDeviceParams.ts new file mode 100644 index 000000000..c5ff2738d --- /dev/null +++ b/sdk/base/lib/osBindings/tunnel/AddDeviceParams.ts @@ -0,0 +1,7 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type AddDeviceParams = { + subnet: string + name: string + ip: string | null +} diff --git a/sdk/base/lib/osBindings/tunnel/AddKeyParams.ts b/sdk/base/lib/osBindings/tunnel/AddKeyParams.ts new file mode 100644 index 000000000..5bb62746d --- /dev/null +++ b/sdk/base/lib/osBindings/tunnel/AddKeyParams.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { AnyVerifyingKey } from './AnyVerifyingKey' + +export type AddKeyParams = { name: string; key: AnyVerifyingKey } diff --git a/sdk/base/lib/osBindings/tunnel/AddPortForwardParams.ts b/sdk/base/lib/osBindings/tunnel/AddPortForwardParams.ts new file mode 100644 index 000000000..ea50dca51 --- /dev/null +++ b/sdk/base/lib/osBindings/tunnel/AddPortForwardParams.ts @@ -0,0 +1,7 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type AddPortForwardParams = { + source: string + target: string + label: string | null +} diff --git a/sdk/base/lib/osBindings/tunnel/AddSubnetParams.ts b/sdk/base/lib/osBindings/tunnel/AddSubnetParams.ts new file mode 100644 index 000000000..8790ad8a4 --- /dev/null +++ b/sdk/base/lib/osBindings/tunnel/AddSubnetParams.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type AddSubnetParams = { name: string } diff --git a/sdk/base/lib/osBindings/tunnel/GatewayId.ts b/sdk/base/lib/osBindings/tunnel/GatewayId.ts new file mode 100644 index 000000000..1b0cc9b38 --- /dev/null +++ b/sdk/base/lib/osBindings/tunnel/GatewayId.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type GatewayId = string diff --git a/sdk/base/lib/osBindings/tunnel/GatewayType.ts b/sdk/base/lib/osBindings/tunnel/GatewayType.ts new file mode 100644 index 000000000..aa7a2d6ed --- /dev/null +++ b/sdk/base/lib/osBindings/tunnel/GatewayType.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type GatewayType = 'inbound-outbound' | 'outbound-only' diff --git a/sdk/base/lib/osBindings/tunnel/IpInfo.ts b/sdk/base/lib/osBindings/tunnel/IpInfo.ts new file mode 100644 index 000000000..8cc7e206e --- /dev/null +++ b/sdk/base/lib/osBindings/tunnel/IpInfo.ts @@ -0,0 +1,13 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { NetworkInterfaceType } from './NetworkInterfaceType' + +export type IpInfo = { + name: string + scopeId: number + deviceType: NetworkInterfaceType | null + subnets: string[] + lanIp: string[] + wanIp: string | null + ntpServers: string[] + dnsServers: string[] +} diff --git a/sdk/base/lib/osBindings/tunnel/ListDevicesParams.ts b/sdk/base/lib/osBindings/tunnel/ListDevicesParams.ts new file mode 100644 index 000000000..2e2c17085 --- /dev/null +++ b/sdk/base/lib/osBindings/tunnel/ListDevicesParams.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type ListDevicesParams = { subnet: string } diff --git a/sdk/base/lib/osBindings/tunnel/NetworkInterfaceInfo.ts b/sdk/base/lib/osBindings/tunnel/NetworkInterfaceInfo.ts new file mode 100644 index 000000000..a57f3c1e9 --- /dev/null +++ b/sdk/base/lib/osBindings/tunnel/NetworkInterfaceInfo.ts @@ -0,0 +1,10 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { GatewayType } from './GatewayType' +import type { IpInfo } from './IpInfo' + +export type NetworkInterfaceInfo = { + name: string | null + secure: boolean | null + ipInfo: IpInfo | null + type: GatewayType | null +} diff --git a/sdk/base/lib/osBindings/tunnel/NetworkInterfaceType.ts b/sdk/base/lib/osBindings/tunnel/NetworkInterfaceType.ts new file mode 100644 index 000000000..6c0d9c363 --- /dev/null +++ b/sdk/base/lib/osBindings/tunnel/NetworkInterfaceType.ts @@ -0,0 +1,8 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type NetworkInterfaceType = + | 'ethernet' + | 'wireless' + | 'bridge' + | 'wireguard' + | 'loopback' diff --git a/sdk/base/lib/osBindings/tunnel/PortForwardEntry.ts b/sdk/base/lib/osBindings/tunnel/PortForwardEntry.ts new file mode 100644 index 000000000..1619d3f40 --- /dev/null +++ b/sdk/base/lib/osBindings/tunnel/PortForwardEntry.ts @@ -0,0 +1,7 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type PortForwardEntry = { + target: string + label: string | null + enabled: boolean +} diff --git a/sdk/base/lib/osBindings/tunnel/PortForwards.ts b/sdk/base/lib/osBindings/tunnel/PortForwards.ts index aa9991452..f2d249dd7 100644 --- a/sdk/base/lib/osBindings/tunnel/PortForwards.ts +++ b/sdk/base/lib/osBindings/tunnel/PortForwards.ts @@ -1,3 +1,4 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { PortForwardEntry } from './PortForwardEntry' -export type PortForwards = { [key: string]: string } +export type PortForwards = { [key: string]: PortForwardEntry } diff --git a/sdk/base/lib/osBindings/tunnel/RemoveDeviceParams.ts b/sdk/base/lib/osBindings/tunnel/RemoveDeviceParams.ts new file mode 100644 index 000000000..5fb6bb42c --- /dev/null +++ b/sdk/base/lib/osBindings/tunnel/RemoveDeviceParams.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type RemoveDeviceParams = { subnet: string; ip: string } diff --git a/sdk/base/lib/osBindings/tunnel/RemoveKeyParams.ts b/sdk/base/lib/osBindings/tunnel/RemoveKeyParams.ts new file mode 100644 index 000000000..cb1cf9049 --- /dev/null +++ b/sdk/base/lib/osBindings/tunnel/RemoveKeyParams.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { AnyVerifyingKey } from './AnyVerifyingKey' + +export type RemoveKeyParams = { key: AnyVerifyingKey } diff --git a/sdk/base/lib/osBindings/tunnel/RemovePortForwardParams.ts b/sdk/base/lib/osBindings/tunnel/RemovePortForwardParams.ts new file mode 100644 index 000000000..2e85f5e77 --- /dev/null +++ b/sdk/base/lib/osBindings/tunnel/RemovePortForwardParams.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type RemovePortForwardParams = { source: string } diff --git a/sdk/base/lib/osBindings/tunnel/SetPasswordParams.ts b/sdk/base/lib/osBindings/tunnel/SetPasswordParams.ts new file mode 100644 index 000000000..f92cb8e7a --- /dev/null +++ b/sdk/base/lib/osBindings/tunnel/SetPasswordParams.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type SetPasswordParams = { password: string } diff --git a/sdk/base/lib/osBindings/tunnel/SetPortForwardEnabledParams.ts b/sdk/base/lib/osBindings/tunnel/SetPortForwardEnabledParams.ts new file mode 100644 index 000000000..51f923436 --- /dev/null +++ b/sdk/base/lib/osBindings/tunnel/SetPortForwardEnabledParams.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type SetPortForwardEnabledParams = { source: string; enabled: boolean } diff --git a/sdk/base/lib/osBindings/tunnel/ShowConfigParams.ts b/sdk/base/lib/osBindings/tunnel/ShowConfigParams.ts new file mode 100644 index 000000000..3f7eecf25 --- /dev/null +++ b/sdk/base/lib/osBindings/tunnel/ShowConfigParams.ts @@ -0,0 +1,7 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type ShowConfigParams = { + subnet: string + ip: string + wanAddr: string | null +} diff --git a/sdk/base/lib/osBindings/tunnel/SubnetParams.ts b/sdk/base/lib/osBindings/tunnel/SubnetParams.ts new file mode 100644 index 000000000..72981f8ae --- /dev/null +++ b/sdk/base/lib/osBindings/tunnel/SubnetParams.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type SubnetParams = { subnet: string } diff --git a/sdk/base/lib/osBindings/tunnel/TunnelDatabase.ts b/sdk/base/lib/osBindings/tunnel/TunnelDatabase.ts index 2f484b5b7..74b8eacd9 100644 --- a/sdk/base/lib/osBindings/tunnel/TunnelDatabase.ts +++ b/sdk/base/lib/osBindings/tunnel/TunnelDatabase.ts @@ -1,5 +1,7 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. import type { AnyVerifyingKey } from './AnyVerifyingKey' +import type { GatewayId } from './GatewayId' +import type { NetworkInterfaceInfo } from './NetworkInterfaceInfo' import type { PortForwards } from './PortForwards' import type { Sessions } from './Sessions' import type { SignerInfo } from './SignerInfo' @@ -11,7 +13,7 @@ export type TunnelDatabase = { sessions: Sessions password: string | null authPubkeys: { [key: AnyVerifyingKey]: SignerInfo } - gateways: { [key: AnyVerifyingKey]: SignerInfo } + gateways: { [key: GatewayId]: NetworkInterfaceInfo } wg: WgServer portForwards: PortForwards } diff --git a/sdk/base/lib/osBindings/tunnel/UpdatePortForwardLabelParams.ts b/sdk/base/lib/osBindings/tunnel/UpdatePortForwardLabelParams.ts new file mode 100644 index 000000000..1697a1250 --- /dev/null +++ b/sdk/base/lib/osBindings/tunnel/UpdatePortForwardLabelParams.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type UpdatePortForwardLabelParams = { + source: string + label: string | null +} diff --git a/sdk/base/lib/osBindings/tunnel/index.ts b/sdk/base/lib/osBindings/tunnel/index.ts new file mode 100644 index 000000000..7c92639bb --- /dev/null +++ b/sdk/base/lib/osBindings/tunnel/index.ts @@ -0,0 +1,35 @@ +export { AddDeviceParams } from './AddDeviceParams' +export { AddKeyParams } from './AddKeyParams' +export { AddPortForwardParams } from './AddPortForwardParams' +export { AddSubnetParams } from './AddSubnetParams' +export { AnyVerifyingKey } from './AnyVerifyingKey' +export { Base64 } from './Base64' +export { GatewayId } from './GatewayId' +export { GatewayType } from './GatewayType' +export { IpInfo } from './IpInfo' +export { ListDevicesParams } from './ListDevicesParams' +export { NetworkInterfaceInfo } from './NetworkInterfaceInfo' +export { NetworkInterfaceType } from './NetworkInterfaceType' +export { Pem } from './Pem' +export { PortForwardEntry } from './PortForwardEntry' +export { PortForwards } from './PortForwards' +export { RemoveDeviceParams } from './RemoveDeviceParams' +export { RemoveKeyParams } from './RemoveKeyParams' +export { RemovePortForwardParams } from './RemovePortForwardParams' +export { Sessions } from './Sessions' +export { Session } from './Session' +export { SetPasswordParams } from './SetPasswordParams' +export { SetPortForwardEnabledParams } from './SetPortForwardEnabledParams' +export { ShowConfigParams } from './ShowConfigParams' +export { SignerInfo } from './SignerInfo' +export { SubnetParams } from './SubnetParams' +export { TunnelCertData } from './TunnelCertData' +export { TunnelDatabase } from './TunnelDatabase' +export { TunnelUpdateResult } from './TunnelUpdateResult' +export { UpdatePortForwardLabelParams } from './UpdatePortForwardLabelParams' +export { WebserverInfo } from './WebserverInfo' +export { WgConfig } from './WgConfig' +export { WgServer } from './WgServer' +export { WgSubnetClients } from './WgSubnetClients' +export { WgSubnetConfig } from './WgSubnetConfig' +export { WgSubnetMap } from './WgSubnetMap'