- 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
89 lines
3.1 KiB
C#
89 lines
3.1 KiB
C#
using System.Text.Json;
|
|
using BTCPayServerDockerConfigurator.Models;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace BTCPayServerDockerConfigurator.Controllers;
|
|
|
|
public partial class ConfiguratorController
|
|
{
|
|
[HttpGet("domain")]
|
|
public IActionResult DomainSettings()
|
|
{
|
|
var model = GetConfiguratorSettings() ?? new ConfiguratorSettings();
|
|
|
|
return View(new UpdateSettings<DomainSettings, AdditionalDataStub>
|
|
{
|
|
Json = JsonSerializer.Serialize(model),
|
|
Settings = model.DomainSettings,
|
|
});
|
|
}
|
|
|
|
[HttpPost("domain")]
|
|
public async Task<IActionResult> DomainSettings(
|
|
UpdateSettings<DomainSettings, AdditionalDataStub> updateSettings,
|
|
string command = null)
|
|
{
|
|
switch (command)
|
|
{
|
|
case "add-domain":
|
|
if (!string.IsNullOrEmpty(updateSettings.Settings.Domain))
|
|
{
|
|
updateSettings.Settings.AdditionalDomains.Add("");
|
|
}
|
|
|
|
return View(updateSettings);
|
|
case { } commandx
|
|
when commandx.StartsWith("remove-domain",
|
|
StringComparison.InvariantCultureIgnoreCase):
|
|
{
|
|
var index = int.Parse(
|
|
commandx[(commandx.IndexOf(":", StringComparison.Ordinal) + 1)..]);
|
|
updateSettings.Settings.AdditionalDomains.RemoveAt(index);
|
|
return View(updateSettings);
|
|
}
|
|
}
|
|
|
|
if (updateSettings.Settings.AdditionalDomains.Any() &&
|
|
string.IsNullOrEmpty(updateSettings.Settings.Domain))
|
|
{
|
|
ModelState.AddModelError(
|
|
nameof(updateSettings.Settings) + "." + nameof(updateSettings.Settings.Domain),
|
|
"You cannot set additional domains when there is no primary domain set!");
|
|
}
|
|
|
|
var configuratorSettings = string.IsNullOrEmpty(updateSettings.Json)
|
|
? new ConfiguratorSettings()
|
|
: JsonSerializer.Deserialize<ConfiguratorSettings>(updateSettings.Json);
|
|
|
|
var error = await CheckHostAsync(updateSettings.Settings.Domain, configuratorSettings);
|
|
if (!string.IsNullOrEmpty(error))
|
|
{
|
|
ModelState.AddModelError(
|
|
nameof(updateSettings.Settings) + "." + nameof(updateSettings.Settings.Domain),
|
|
error);
|
|
}
|
|
|
|
for (var index = 0; index < updateSettings.Settings.AdditionalDomains.Count; index++)
|
|
{
|
|
var additionalDomain = updateSettings.Settings.AdditionalDomains[index];
|
|
error = await CheckHostAsync(additionalDomain, configuratorSettings);
|
|
if (!string.IsNullOrEmpty(error))
|
|
{
|
|
ModelState.AddModelError(
|
|
nameof(updateSettings.Settings) + "." +
|
|
nameof(updateSettings.Settings.Domain) + $"[{index}]",
|
|
error);
|
|
}
|
|
}
|
|
|
|
if (!ModelState.IsValid)
|
|
{
|
|
return View(updateSettings);
|
|
}
|
|
|
|
configuratorSettings.DomainSettings = updateSettings.Settings;
|
|
SetConfiguratorSettings(configuratorSettings);
|
|
return RedirectToAction(nameof(ChainSettings));
|
|
}
|
|
}
|