You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Meant to be used to automate setting up a new defguard instance.
739
-
/// Does not handle assigning device IPs, since no device should exist at this point.
739
+
/// If the network ID has been specified, it will be assumed that the user wants to update the existing network or create a new one with a predefined ID.
740
+
/// This is mainly used for deployment purposes where the network ID must be known beforehand.
741
+
///
742
+
/// If there is no ID specified, the function will only create the network if no other network exists.
743
+
/// In other words, multiple networks can be created, but only if the ID is predefined for each network.
740
744
pubasyncfninit_vpn_location(
741
745
pool:&PgPool,
742
746
args:&InitVpnLocationArgs,
743
747
) -> Result<String, anyhow::Error>{
744
-
// check if a VPN location exists already
745
-
let networks = WireguardNetwork::all(pool).await?;
746
-
if !networks.is_empty(){
747
-
returnErr(anyhow!(
748
-
"Failed to initialize first VPN location. A location already exists."
749
-
));
748
+
// The ID is predefined
749
+
let network = ifletSome(location_id) = args.id{
750
+
letmut transaction = pool.begin().await?;
751
+
// If the network already exists, update it, assuming that's the user's intent.
0 commit comments