diff --git a/BTCPayServer/Configuration/BTCPayServerOptions.cs b/BTCPayServer/Configuration/BTCPayServerOptions.cs index e477a200b..e0272d854 100644 --- a/BTCPayServer/Configuration/BTCPayServerOptions.cs +++ b/BTCPayServer/Configuration/BTCPayServerOptions.cs @@ -141,6 +141,18 @@ namespace BTCPayServer.Configuration Logs.Configuration.LogInformation("Supported chains: " + String.Join(',', supportedChains.ToArray())); + var services = conf.GetOrDefault("externalservices", null); + if(services != null) + { + foreach(var service in services.Split(new[] { ';', ',' }) + .Select(p => p.Split(':')) + .Where(p => p.Length == 2) + .Select(p => (Name: p[0], Link: p[1]))) + { + ExternalServices.AddOrReplace(service.Name, service.Link); + } + } + PostgresConnectionString = conf.GetOrDefault("postgres", null); MySQLConnectionString = conf.GetOrDefault("mysql", null); BundleJsCss = conf.GetOrDefault("bundlejscss", true); @@ -248,6 +260,8 @@ namespace BTCPayServer.Configuration public string RootPath { get; set; } public Dictionary InternalLightningByCryptoCode { get; set; } = new Dictionary(); + public Dictionary ExternalServices { get; set; } = new Dictionary(); + public ExternalServices ExternalServicesByCryptoCode { get; set; } = new ExternalServices(); public BTCPayNetworkProvider NetworkProvider { get; set; } diff --git a/BTCPayServer/Configuration/DefaultConfiguration.cs b/BTCPayServer/Configuration/DefaultConfiguration.cs index ef8511db3..1f26bd61c 100644 --- a/BTCPayServer/Configuration/DefaultConfiguration.cs +++ b/BTCPayServer/Configuration/DefaultConfiguration.cs @@ -33,6 +33,7 @@ namespace BTCPayServer.Configuration app.Option("--postgres", $"Connection string to a PostgreSQL database (default: SQLite)", CommandOptionType.SingleValue); app.Option("--mysql", $"Connection string to a MySQL database (default: SQLite)", CommandOptionType.SingleValue); app.Option("--externalurl", $"The expected external URL of this service, to use if BTCPay is behind a reverse proxy (default: empty, use the incoming HTTP request to figure out)", CommandOptionType.SingleValue); + app.Option("--externalservices", $"Links added to external services inside Server Settings / Services under the format service1:path2;service2:path2.(default: empty)", CommandOptionType.SingleValue); app.Option("--bundlejscss", $"Bundle JavaScript and CSS files for better performance (default: true)", CommandOptionType.SingleValue); app.Option("--rootpath", "The root path in the URL to access BTCPay (default: /)", CommandOptionType.SingleValue); app.Option("--sshconnection", "SSH server to manage BTCPay under the form user@server:port (default: root@externalhost or empty)", CommandOptionType.SingleValue); diff --git a/BTCPayServer/Controllers/ServerController.cs b/BTCPayServer/Controllers/ServerController.cs index e44ae8f43..716c704c7 100644 --- a/BTCPayServer/Controllers/ServerController.cs +++ b/BTCPayServer/Controllers/ServerController.cs @@ -435,7 +435,22 @@ namespace BTCPayServer.Controllers }); } } - result.HasSSH = _Options.SSHSettings != null; + foreach(var externalService in _Options.ExternalServices) + { + result.ExternalServices.Add(new ServicesViewModel.ExternalService() + { + Name = externalService.Key, + Link = this.Request.GetRelativePath(externalService.Value) + }); + } + if(_Options.SSHSettings != null) + { + result.ExternalServices.Add(new ServicesViewModel.ExternalService() + { + Name = "SSH", + Link = this.Url.Action(nameof(SSHService)) + }); + } return View(result); } diff --git a/BTCPayServer/Extensions.cs b/BTCPayServer/Extensions.cs index 8e7b694e4..b9f50431b 100644 --- a/BTCPayServer/Extensions.cs +++ b/BTCPayServer/Extensions.cs @@ -168,6 +168,15 @@ namespace BTCPayServer request.Path.ToUriComponent()); } + public static string GetRelativePath(this HttpRequest request, string path) + { + if (path.Length > 0 && path[0] != '/') + path = $"/{path}"; + return string.Concat( + request.PathBase.ToUriComponent(), + path); + } + public static string GetAbsoluteUri(this HttpRequest request, string redirectUrl) { bool isRelative = diff --git a/BTCPayServer/Models/ServerViewModels/ServicesViewModel.cs b/BTCPayServer/Models/ServerViewModels/ServicesViewModel.cs index e103bd6bf..e3ddab4ea 100644 --- a/BTCPayServer/Models/ServerViewModels/ServicesViewModel.cs +++ b/BTCPayServer/Models/ServerViewModels/ServicesViewModel.cs @@ -15,7 +15,13 @@ namespace BTCPayServer.Models.ServerViewModels public int Index { get; set; } } + public class ExternalService + { + public string Name { get; set; } + public string Link { get; set; } + } + public List LNDServices { get; set; } = new List(); - public bool HasSSH { get; set; } + public List ExternalServices { get; set; } = new List(); } } diff --git a/BTCPayServer/Properties/launchSettings.json b/BTCPayServer/Properties/launchSettings.json index 176290c25..8f728e890 100644 --- a/BTCPayServer/Properties/launchSettings.json +++ b/BTCPayServer/Properties/launchSettings.json @@ -32,7 +32,8 @@ "BTCPAY_BTCEXPLORERURL": "http://127.0.0.1:32838/", "ASPNETCORE_ENVIRONMENT": "Development", "BTCPAY_CHAINS": "btc,ltc", - "BTCPAY_POSTGRES": "User ID=postgres;Host=127.0.0.1;Port=39372;Database=btcpayserver" + "BTCPAY_POSTGRES": "User ID=postgres;Host=127.0.0.1;Port=39372;Database=btcpayserver", + "BTCPAY_EXTERNALSERVICES": "totoservice:totolink;" }, "applicationUrl": "https://localhost:14142/" } diff --git a/BTCPayServer/Views/Server/Services.cshtml b/BTCPayServer/Views/Server/Services.cshtml index 7451fb2d5..3250c81c0 100644 --- a/BTCPayServer/Views/Server/Services.cshtml +++ b/BTCPayServer/Views/Server/Services.cshtml @@ -15,8 +15,9 @@
+

Crypto services

- You can get access here to LND (gRPC, Rest) or SSH services exposed by your server + You can get access here to LND (gRPC, Rest) services exposed by your server
@@ -46,13 +47,35 @@ } - @if (Model.HasSSH) + + +
+
+
+ +@if (Model.ExternalServices.Count != 0) +{ +
+
+

Other services

+
+ Other external services +
+
+ + + + + + + + + @foreach (var s in Model.ExternalServices) { - - + } @@ -61,6 +84,7 @@ +} @section Scripts { @await Html.PartialAsync("_ValidationScriptsPartial")
NameActions
NoneSSH@s.Name - See information + See information