diff --git a/Makefile b/Makefile index 659b4926e..3937e0a38 100644 --- a/Makefile +++ b/Makefile @@ -156,7 +156,7 @@ results/$(REGISTRY_BASENAME).deb: dpkg-build.sh $(call ls-files,debian/start-reg tunnel-deb: results/$(TUNNEL_BASENAME).deb results/$(TUNNEL_BASENAME).deb: dpkg-build.sh $(call ls-files,debian/start-tunnel) $(TUNNEL_TARGETS) - PROJECT=start-tunnel PLATFORM=$(ARCH) REQUIRES=debian DEPENDS=wireguard-tools,iptables,network-manager,augeas-tools ./build/os-compat/run-compat.sh ./dpkg-build.sh + PROJECT=start-tunnel PLATFORM=$(ARCH) REQUIRES=debian DEPENDS=wireguard-tools,iptables ./build/os-compat/run-compat.sh ./dpkg-build.sh $(IMAGE_TYPE): results/$(BASENAME).$(IMAGE_TYPE) diff --git a/core/startos/src/context/cli.rs b/core/startos/src/context/cli.rs index 9248db005..ffcb5d8c1 100644 --- a/core/startos/src/context/cli.rs +++ b/core/startos/src/context/cli.rs @@ -234,23 +234,28 @@ impl CliContext { &self, method: &str, params: Value, - ) -> Result + ) -> Result where Self: CallRemote, { >::call_remote(&self, method, params, Empty {}) .await + .map_err(Error::from) + .with_ctx(|e| (e.kind, method)) } pub async fn call_remote_with( &self, method: &str, params: Value, extra: T, - ) -> Result + ) -> Result where Self: CallRemote, { - >::call_remote(&self, method, params, extra).await + >::call_remote(&self, method, params, extra) + .await + .map_err(Error::from) + .with_ctx(|e| (e.kind, method)) } } impl AsRef for CliContext { diff --git a/core/startos/src/net/static_server.rs b/core/startos/src/net/static_server.rs index 7cc089bc3..de78905b8 100644 --- a/core/startos/src/net/static_server.rs +++ b/core/startos/src/net/static_server.rs @@ -21,12 +21,12 @@ use http::header::{ use http::request::Parts as RequestParts; use http::{HeaderValue, Method, StatusCode}; use imbl_value::InternedString; -use include_dir::{Dir, include_dir}; +use include_dir::Dir; use models::PackageId; use new_mime_guess::MimeGuess; use openssl::hash::MessageDigest; use openssl::x509::X509; -use rpc_toolkit::{Context, HttpServer, Server}; +use rpc_toolkit::{Context, HttpServer, ParentHandler, Server}; use tokio::io::{AsyncRead, AsyncReadExt, AsyncSeekExt, BufReader}; use tokio_util::io::ReaderStream; use url::Url; @@ -80,6 +80,7 @@ const EMBEDDED_UI_ROOT: Dir<'_> = else_empty_dir!( pub trait UiContext: Context + AsRef + Clone + Sized { const UI_DIR: &'static Dir<'static>; + fn api() -> ParentHandler; fn middleware(server: Server) -> HttpServer; fn extend_router(self, router: Router) -> Router { router @@ -91,7 +92,9 @@ impl UiContext for RpcContext { feature = "startd" => include_dir::include_dir!("$CARGO_MANIFEST_DIR/../../web/dist/static/ui") ); - + fn api() -> ParentHandler { + main_api() + } fn middleware(server: Server) -> HttpServer { server .middleware(Cors::new()) @@ -155,7 +158,9 @@ impl UiContext for InitContext { feature = "startd" => include_dir::include_dir!("$CARGO_MANIFEST_DIR/../../web/dist/static/ui") ); - + fn api() -> ParentHandler { + main_api() + } fn middleware(server: Server) -> HttpServer { server.middleware(Cors::new()) } @@ -166,7 +171,9 @@ impl UiContext for DiagnosticContext { feature = "startd" => include_dir::include_dir!("$CARGO_MANIFEST_DIR/../../web/dist/static/ui") ); - + fn api() -> ParentHandler { + main_api() + } fn middleware(server: Server) -> HttpServer { server.middleware(Cors::new()) } @@ -177,7 +184,9 @@ impl UiContext for SetupContext { feature = "startd" => include_dir::include_dir!("$CARGO_MANIFEST_DIR/../../web/dist/static/setup-wizard") ); - + fn api() -> ParentHandler { + main_api() + } fn middleware(server: Server) -> HttpServer { server.middleware(Cors::new()) } @@ -188,7 +197,9 @@ impl UiContext for InstallContext { feature = "startd" => include_dir::include_dir!("$CARGO_MANIFEST_DIR/../../web/dist/static/install-wizard") ); - + fn api() -> ParentHandler { + main_api() + } fn middleware(server: Server) -> HttpServer { server.middleware(Cors::new()) } @@ -256,7 +267,7 @@ pub fn ui_router(ctx: C) -> Router { ctx.clone() .extend_router(rpc_router( ctx.clone(), - C::middleware(Server::new(move || ready(Ok(ctx.clone())), main_api())), + C::middleware(Server::new(move || ready(Ok(ctx.clone())), C::api())), )) .fallback(any(|request: Request| async move { serve_ui::(request).unwrap_or_else(server_error) diff --git a/core/startos/src/tunnel/auth.rs b/core/startos/src/tunnel/auth.rs index 19a93d795..8818bfbec 100644 --- a/core/startos/src/tunnel/auth.rs +++ b/core/startos/src/tunnel/auth.rs @@ -251,8 +251,8 @@ pub async fn set_password_cli( .. }: HandlerArgs, ) -> Result<(), Error> { - let password = rpassword::prompt_password("New Password")?; - let confirm = rpassword::prompt_password("Confirm Password")?; + let password = rpassword::prompt_password("New Password: ")?; + let confirm = rpassword::prompt_password("Confirm Password: ")?; if password != confirm { return Err(Error::new( diff --git a/core/startos/src/tunnel/context.rs b/core/startos/src/tunnel/context.rs index 1514f7a62..217c74b8c 100644 --- a/core/startos/src/tunnel/context.rs +++ b/core/startos/src/tunnel/context.rs @@ -13,7 +13,7 @@ use include_dir::Dir; use models::GatewayId; use patch_db::PatchDb; use rpc_toolkit::yajrc::RpcError; -use rpc_toolkit::{CallRemote, Context, Empty}; +use rpc_toolkit::{CallRemote, Context, Empty, ParentHandler}; use serde::{Deserialize, Serialize}; use tokio::process::Command; use tokio::sync::broadcast::Sender; @@ -33,6 +33,7 @@ use crate::net::static_server::UiContext; use crate::prelude::*; use crate::rpc_continuations::{OpenAuthedContinuations, RpcContinuations}; use crate::tunnel::TUNNEL_DEFAULT_LISTEN; +use crate::tunnel::api::tunnel_api; use crate::tunnel::db::{GatewayPort, TunnelDatabase}; use crate::tunnel::wg::WIREGUARD_INTERFACE_NAME; use crate::util::Invoke; @@ -311,7 +312,10 @@ impl UiContext for TunnelContext { feature = "tunnel" => include_dir::include_dir!("$CARGO_MANIFEST_DIR/../../web/dist/static/start-tunnel") ); - + fn api() -> ParentHandler { + tracing::info!("loading tunnel api..."); + tunnel_api() + } fn middleware(server: rpc_toolkit::Server) -> rpc_toolkit::HttpServer { server.middleware(Cors::new()).middleware(Auth::new()) } diff --git a/core/startos/src/tunnel/web.rs b/core/startos/src/tunnel/web.rs index eb58c544a..6be4cab65 100644 --- a/core/startos/src/tunnel/web.rs +++ b/core/startos/src/tunnel/web.rs @@ -313,10 +313,10 @@ pub async fn get_available_ips(ctx: TunnelContext) -> Result, Error> let ips = ctx.net_iface.peek(|interfaces| { interfaces .values() - .filter_map(|info| { + .flat_map(|info| { info.ip_info - .as_ref() - .and_then(|ip_info| ip_info.subnets.iter().next().map(|subnet| subnet.addr())) + .iter() + .flat_map(|ip_info| ip_info.subnets.iter().map(|subnet| subnet.addr())) }) .collect::>() }); @@ -377,8 +377,11 @@ pub async fn init_web(ctx: CliContext) -> Result<(), Error> { .call_remote::("web.enable", json!({})) .await { - Ok(_) => println!("Webserver Initialized"), - Err(e) if e.code == ErrorKind::ParseNetAddress as i32 => { + Ok(_) => { + println!("Webserver Initialized"); + return Ok(()); + } + Err(e) if e.kind == ErrorKind::ParseNetAddress => { println!("A listen address has not been set yet. Setting one up now..."); let available_ips = from_value::>( @@ -431,7 +434,7 @@ pub async fn init_web(ctx: CliContext) -> Result<(), Error> { ) .await?; } - Err(e) if e.code == ErrorKind::OpenSsl as i32 => { + Err(e) if e.kind == ErrorKind::OpenSsl => { println!( "StartTunnel has not been set up with an SSL Certificate yet. Setting one up now..." ); @@ -526,7 +529,7 @@ pub async fn init_web(ctx: CliContext) -> Result<(), Error> { .await?; } } - Err(e) if e.code == ErrorKind::Authorization as i32 => { + Err(e) if e.kind == ErrorKind::Authorization => { println!("A password has not been setup yet. Setting one up now..."); super::auth::set_password_cli(HandlerArgs { diff --git a/debian/start-tunnel/postinst b/debian/start-tunnel/postinst index 7e301b372..542ff8cff 100755 --- a/debian/start-tunnel/postinst +++ b/debian/start-tunnel/postinst @@ -6,12 +6,4 @@ if [ -n "$DPKG_MAINTSCRIPT_PACKAGE" ]; then SYSTEMCTL=deb-systemd-helper fi -augtool << EOI -set /augeas/load/Ini/lens IniFile.lns_loose -set /augeas/load/Ini/incl /etc/NetworkManager/NetworkManager.conf -load -set /files/etc/NetworkManager/NetworkManager.conf/section[.="ifupdown"]/managed true -save -EOI - $SYSTEMCTL enable start-tunneld.service diff --git a/sdk/base/lib/osBindings/SignerInfo.ts b/sdk/base/lib/osBindings/SignerInfo.ts index 7e7aa2588..76cbdafce 100644 --- a/sdk/base/lib/osBindings/SignerInfo.ts +++ b/sdk/base/lib/osBindings/SignerInfo.ts @@ -1,9 +1,3 @@ // 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 { ContactInfo } from "./ContactInfo" -export type SignerInfo = { - name: string - contact: Array - keys: Array -} +export type SignerInfo = { name: string } diff --git a/web/angular.json b/web/angular.json index bb7ed158b..2930be646 100644 --- a/web/angular.json +++ b/web/angular.json @@ -378,7 +378,7 @@ { "type": "initial", "maximumWarning": "500kB", - "maximumError": "1MB" + "maximumError": "5MB" }, { "type": "anyComponentStyle",