diff --git a/csharp/App/Backend/Controller.cs b/csharp/App/Backend/Controller.cs index d75ef9da9..524cad118 100644 --- a/csharp/App/Backend/Controller.cs +++ b/csharp/App/Backend/Controller.cs @@ -404,7 +404,7 @@ public class Controller : ControllerBase { var session = Db.GetSession(authToken); - // var installationToUpdate = Db.GetInstallationById(installationId); + //var installationToUpdate = Db.GetInstallationById(installationId); return await session.SendInstallationConfig(installationId, config) ? Ok() diff --git a/csharp/App/Backend/DataTypes/Methods/ExoCmd.cs b/csharp/App/Backend/DataTypes/Methods/ExoCmd.cs index 8da04c6a9..b28f64142 100644 --- a/csharp/App/Backend/DataTypes/Methods/ExoCmd.cs +++ b/csharp/App/Backend/DataTypes/Methods/ExoCmd.cs @@ -249,4 +249,34 @@ public static class ExoCmd return await s3Region.PutBucket(installation.BucketName()) != null; } + public static async Task SendConfig(this Installation installation, String config) + { + + // This looks hacky but here we grab the vpn-Ip of the installation by its installation Name (e.g. Salimax0001) + // From the vpn server (here salidomo, but we use the vpn home ip for future-proofing) + // using var client = new HttpClient(); + // var webRequest = client.GetAsync("10.2.0.1/vpnstatus.txt"); + // var text = webRequest.ToString(); + // var lines = text!.Split(new [] { Environment.NewLine }, StringSplitOptions.None); + // var vpnIp = lines.First(l => l.Contains(installation.InstallationName)).Split(",")[1]; + // + // // Writing the config to a file and then sending that file with rsync sounds inefficient + // // We should find a better solution... + // // TODO The VPN server should do this not the backend!!! + // await File.WriteAllTextAsync("./config.json", config); + // var result = await Cli.Wrap("rsync") + // .WithArguments("./config.json") + // .AppendArgument($@"root@{vpnIp}:/salimax") + // .ExecuteAsync(); + + // return result.ExitCode == 200; + + + var s3Region = new S3Region($"https://{installation.S3Region}.{installation.S3Provider}", S3Creds!); + var url = s3Region.Bucket(installation.BucketName()).Path("config.json"); + return await url.PutObject(config); + + + } + } \ No newline at end of file diff --git a/csharp/App/Backend/DataTypes/Methods/Installation.cs b/csharp/App/Backend/DataTypes/Methods/Installation.cs index f61a5446a..4b2342f85 100644 --- a/csharp/App/Backend/DataTypes/Methods/Installation.cs +++ b/csharp/App/Backend/DataTypes/Methods/Installation.cs @@ -46,29 +46,6 @@ public static class InstallationMethods // TODO We dont do this here return true; } - - public static async Task SendConfig(this Installation installation, String config) - { - - // This looks hacky but here we grab the vpn-Ip of the installation by its installation Name (e.g. Salimax0001) - // From the vpn server (here salidomo, but we use the vpn home ip for future-proofing) - using var client = new HttpClient(); - var webRequest = client.GetAsync("10.2.0.1/vpnstatus.txt"); - var text = webRequest.ToString(); - var lines = text!.Split(new [] { Environment.NewLine }, StringSplitOptions.None); - var vpnIp = lines.First(l => l.Contains(installation.InstallationName)).Split(",")[1]; - - // Writing the config to a file and then sending that file with rsync sounds inefficient - // We should find a better solution... - // TODO The VPN server should do this not the backend!!! - await File.WriteAllTextAsync("./config.json", config); - var result = await Cli.Wrap("rsync") - .WithArguments("./config.json") - .AppendArgument($@"root@{vpnIp}:/salimax") - .ExecuteAsync(); - - return result.ExitCode == 200; - } public static IEnumerable UsersWithAccess(this Installation installation) {