mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-01 04:53:40 +00:00
outbound gateway support (#3120)
* Multiple (#3111) * fix alerts i18n, fix status display, better, remove usb media, hide shutdown for install complete * trigger chnage detection for localize pipe and round out implementing localize pipe for consistency even though not needed * Fix PackageInfoShort to handle LocaleString on releaseNotes (#3112) * Fix PackageInfoShort to handle LocaleString on releaseNotes * fix: filter by target_version in get_matching_models and pass otherVersions from install * chore: add exver documentation for ai agents * frontend plus some be types --------- Co-authored-by: Aiden McClelland <3732071+dr-bonez@users.noreply.github.com>
This commit is contained in:
@@ -754,13 +754,14 @@ async fn watch_ip(
|
||||
|
||||
write_to.send_if_modified(
|
||||
|m: &mut OrdMap<GatewayId, NetworkInterfaceInfo>| {
|
||||
let (name, public, secure, prev_wan_ip) = m
|
||||
let (name, public, secure, gateway_type, prev_wan_ip) = m
|
||||
.get(&iface)
|
||||
.map_or((None, None, None, None), |i| {
|
||||
.map_or((None, None, None, None, None), |i| {
|
||||
(
|
||||
i.name.clone(),
|
||||
i.public,
|
||||
i.secure,
|
||||
i.gateway_type,
|
||||
i.ip_info
|
||||
.as_ref()
|
||||
.and_then(|i| i.wan_ip),
|
||||
@@ -775,6 +776,7 @@ async fn watch_ip(
|
||||
public,
|
||||
secure,
|
||||
ip_info: Some(ip_info.clone()),
|
||||
gateway_type,
|
||||
},
|
||||
)
|
||||
.filter(|old| &old.ip_info == &Some(ip_info))
|
||||
|
||||
@@ -8,7 +8,7 @@ use ts_rs::TS;
|
||||
|
||||
use crate::GatewayId;
|
||||
use crate::context::{CliContext, RpcContext};
|
||||
use crate::db::model::public::{NetworkInterfaceInfo, NetworkInterfaceType};
|
||||
use crate::db::model::public::{GatewayType, NetworkInterfaceInfo, NetworkInterfaceType};
|
||||
use crate::net::host::all_hosts;
|
||||
use crate::prelude::*;
|
||||
use crate::util::Invoke;
|
||||
@@ -32,14 +32,19 @@ pub fn tunnel_api<C: Context>() -> ParentHandler<C> {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, Parser, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export)]
|
||||
pub struct AddTunnelParams {
|
||||
#[arg(help = "help.arg.tunnel-name")]
|
||||
name: InternedString,
|
||||
#[arg(help = "help.arg.wireguard-config")]
|
||||
config: String,
|
||||
#[arg(help = "help.arg.is-public")]
|
||||
public: bool,
|
||||
#[arg(help = "help.arg.gateway-type")]
|
||||
#[serde(default, rename = "type")]
|
||||
gateway_type: Option<GatewayType>,
|
||||
#[arg(help = "help.arg.set-as-default-outbound")]
|
||||
#[serde(default)]
|
||||
set_as_default_outbound: bool,
|
||||
}
|
||||
|
||||
fn sanitize_config(config: &str) -> String {
|
||||
@@ -64,7 +69,8 @@ pub async fn add_tunnel(
|
||||
AddTunnelParams {
|
||||
name,
|
||||
config,
|
||||
public,
|
||||
gateway_type,
|
||||
set_as_default_outbound,
|
||||
}: AddTunnelParams,
|
||||
) -> Result<GatewayId, Error> {
|
||||
let ifaces = ctx.net_controller.net_iface.watcher.subscribe();
|
||||
@@ -76,9 +82,10 @@ pub async fn add_tunnel(
|
||||
iface.clone(),
|
||||
NetworkInterfaceInfo {
|
||||
name: Some(name),
|
||||
public: Some(public),
|
||||
public: None,
|
||||
secure: None,
|
||||
ip_info: None,
|
||||
gateway_type,
|
||||
},
|
||||
);
|
||||
return true;
|
||||
@@ -120,6 +127,19 @@ pub async fn add_tunnel(
|
||||
|
||||
sub.recv().await;
|
||||
|
||||
if set_as_default_outbound {
|
||||
ctx.db
|
||||
.mutate(|db| {
|
||||
db.as_public_mut()
|
||||
.as_server_info_mut()
|
||||
.as_network_mut()
|
||||
.as_default_outbound_mut()
|
||||
.ser(&Some(iface.clone()))
|
||||
})
|
||||
.await
|
||||
.result?;
|
||||
}
|
||||
|
||||
Ok(iface)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user