- Upgrade from .NET Core 3.1 to .NET 10, SSH.NET 2016.1.0 to 2024.1.0 - Fix ServerData JSON deserialization crash with boolean lsblk fields (#13) - Fix DiskFreeResult.Parse overflow with TryParse and null safety (#20) - Fix SSH connection issues via SSH.NET library upgrade (#22) - Fix bash generation to detect existing btcpayserver-docker dir (#5) - Add disk space and server resources display in Summary page (#6) - Add FastSync support for initial Bitcoin sync (#9) - Add SSH key authentication for remote deployments (#23) - Replace CircleCI with GitHub Actions publishing to GHCR and Docker Hub (#24) - Add unified multi-arch Dockerfile using Docker Buildx (#24) - Make additional services data-driven via ServiceRegistry (#27) - Add CloudInit deployment type for VPS provisioning (#28) - Fix Summary page duplicate Libre Patron entry and typos (#26) - Replace deprecated WebClient with IHttpClientFactory - Remove Startup.cs in favor of minimal hosting in Program.cs - Fix ThunderHub validation targeting wrong model property
116 lines
4.4 KiB
C#
116 lines
4.4 KiB
C#
using System.Text.Json;
|
|
using BTCPayServerDockerConfigurator.Models;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace BTCPayServerDockerConfigurator.Controllers;
|
|
|
|
public partial class ConfiguratorController
|
|
{
|
|
[HttpGet("advanced")]
|
|
public IActionResult AdvancedSettings()
|
|
{
|
|
var model = GetConfiguratorSettings();
|
|
return View(new UpdateSettings<AdvancedSettings, AdvancedSettingsAdditionalData>
|
|
{
|
|
Json = model.ToString(),
|
|
Settings = model.AdvancedSettings,
|
|
Additional = new AdvancedSettingsAdditionalData
|
|
{
|
|
ShowSettings = model.AdvancedSettings.AnythingSet()
|
|
}
|
|
});
|
|
}
|
|
|
|
[HttpPost("advanced")]
|
|
public IActionResult AdvancedSettings(
|
|
UpdateSettings<AdvancedSettings, AdvancedSettingsAdditionalData> updateSettings,
|
|
string command = null)
|
|
{
|
|
switch (command)
|
|
{
|
|
case { } x when x.StartsWith("fragmentset"):
|
|
var parts = x.Replace("fragmentset", "").Split(",");
|
|
foreach (var part in parts)
|
|
{
|
|
var add = part.StartsWith('+');
|
|
var fragment = part.TrimStart('+', '-');
|
|
if (add && !updateSettings.Settings.AdditionalFragments.Contains(fragment))
|
|
{
|
|
updateSettings.Settings.AdditionalFragments.Add(fragment);
|
|
}
|
|
else if (!add &&
|
|
updateSettings.Settings.AdditionalFragments.Contains(fragment))
|
|
{
|
|
updateSettings.Settings.AdditionalFragments.Remove(fragment);
|
|
}
|
|
}
|
|
|
|
updateSettings.Additional ??= new AdvancedSettingsAdditionalData();
|
|
updateSettings.Additional.ShowSettings = true;
|
|
return View(updateSettings);
|
|
case "show":
|
|
updateSettings.Additional = new AdvancedSettingsAdditionalData
|
|
{
|
|
ShowSettings = true
|
|
};
|
|
return View(updateSettings);
|
|
case "add-additional":
|
|
updateSettings.Additional = new AdvancedSettingsAdditionalData
|
|
{
|
|
ShowSettings = true
|
|
};
|
|
updateSettings.Settings.AdditionalFragments.Add("");
|
|
return View(updateSettings);
|
|
case { } commandx
|
|
when commandx.StartsWith("remove-additional",
|
|
StringComparison.InvariantCultureIgnoreCase):
|
|
{
|
|
updateSettings.Additional = new AdvancedSettingsAdditionalData
|
|
{
|
|
ShowSettings = true
|
|
};
|
|
var index = int.Parse(
|
|
commandx[(commandx.IndexOf(":", StringComparison.Ordinal) + 1)..]);
|
|
updateSettings.Settings.AdditionalFragments.RemoveAt(index);
|
|
return View(updateSettings);
|
|
}
|
|
case "add-excluded":
|
|
updateSettings.Additional = new AdvancedSettingsAdditionalData
|
|
{
|
|
ShowSettings = true
|
|
};
|
|
updateSettings.Settings.ExcludedFragments.Add("");
|
|
return View(updateSettings);
|
|
case { } commandx
|
|
when commandx.StartsWith("remove-excluded",
|
|
StringComparison.InvariantCultureIgnoreCase):
|
|
{
|
|
updateSettings.Additional = new AdvancedSettingsAdditionalData
|
|
{
|
|
ShowSettings = true
|
|
};
|
|
var index = int.Parse(
|
|
commandx[(commandx.IndexOf(":", StringComparison.Ordinal) + 1)..]);
|
|
updateSettings.Settings.ExcludedFragments.RemoveAt(index);
|
|
return View(updateSettings);
|
|
}
|
|
}
|
|
|
|
if (!ModelState.IsValid)
|
|
{
|
|
updateSettings.Additional = new AdvancedSettingsAdditionalData
|
|
{
|
|
ShowSettings = true
|
|
};
|
|
return View(updateSettings);
|
|
}
|
|
|
|
var configuratorSettings = string.IsNullOrEmpty(updateSettings.Json)
|
|
? new ConfiguratorSettings()
|
|
: JsonSerializer.Deserialize<ConfiguratorSettings>(updateSettings.Json);
|
|
configuratorSettings.AdvancedSettings = updateSettings.Settings;
|
|
SetConfiguratorSettings(configuratorSettings);
|
|
return RedirectToAction(nameof(Summary));
|
|
}
|
|
}
|