Deducing if to perform update check from update url configuration

This commit is contained in:
rockstardev 2020-08-03 03:16:29 -05:00
parent ce87d2e45c
commit 16eedf4153
6 changed files with 7 additions and 8 deletions

View file

@ -176,8 +176,7 @@ namespace BTCPayServer.Configuration
SocksEndpoint = endpoint;
}
UpdateCheck = conf.GetOrDefault<bool>("updatecheck", false);
UpdateUrl = conf.GetOrDefault<Uri>("updateurl", new Uri("https://api.github.com/repos/btcpayserver/btcpayserver/releases/latest"));
UpdateUrl = conf.GetOrDefault<Uri>("updateurl", null);
var sshSettings = ParseSSHConfiguration(conf);
if ((!string.IsNullOrEmpty(sshSettings.Password) || !string.IsNullOrEmpty(sshSettings.KeyFile)) && !string.IsNullOrEmpty(sshSettings.Server))
@ -303,7 +302,6 @@ namespace BTCPayServer.Configuration
set;
}
public string TorrcFile { get; set; }
public bool UpdateCheck { get; set; }
public Uri UpdateUrl { get; set; }
}
}

View file

@ -38,8 +38,7 @@ namespace BTCPayServer.Configuration
app.Option("--sshtrustedfingerprints", "SSH Host public key fingerprint or sha256 (default: empty, it will allow untrusted connections)", CommandOptionType.SingleValue);
app.Option("--torrcfile", "Path to torrc file containing hidden services directories (default: empty)", CommandOptionType.SingleValue);
app.Option("--socksendpoint", "Socks endpoint to connect to onion urls (default: empty)", CommandOptionType.SingleValue);
app.Option("--updatecheck", $"Enabling once a day check for new releases (default: false)", CommandOptionType.SingleValue);
app.Option("--updateurl", $"Url location used for updatecheck (default: https://api.github.com/repos/btcpayserver/btcpayserver/releases/latest)", CommandOptionType.SingleValue);
app.Option("--updateurl", $"Url used for once a day new release version check. Check performed only if value is not empty (default: empty)", CommandOptionType.SingleValue);
app.Option("--debuglog", "A rolling log file for debug messages.", CommandOptionType.SingleValue);
app.Option("--debugloglevel", "The severity you log (default:information)", CommandOptionType.SingleValue);
app.Option("--disable-registration", "Disables new user registrations (default:true)", CommandOptionType.SingleValue);

View file

@ -444,7 +444,7 @@ namespace BTCPayServer.Controllers
settings.FirstRun = false;
await _SettingsRepository.UpdateSetting<ThemeSettings>(settings);
await _SettingsRepository.FirstAdminRegistered(policies, _Options.UpdateCheck, _Options.DisableRegistration);
await _SettingsRepository.FirstAdminRegistered(policies, _Options.UpdateUrl != null, _Options.DisableRegistration);
RegisteredAdmin = true;
}

View file

@ -148,7 +148,7 @@ namespace BTCPayServer.Controllers.GreenField
await _userManager.AddToRoleAsync(user, Roles.ServerAdmin);
if (!anyAdmin)
{
await _settingsRepository.FirstAdminRegistered(policies, _options.UpdateCheck, _options.DisableRegistration);
await _settingsRepository.FirstAdminRegistered(policies, _options.UpdateUrl != null, _options.DisableRegistration);
}
}
_eventAggregator.Publish(new UserRegisteredEvent() { RequestUri = Request.GetAbsoluteRootUri(), User = user, Admin = request.IsAdministrator is true });

View file

@ -94,6 +94,9 @@ namespace BTCPayServer.HostedServices
private static readonly Regex _releaseVersionTag = new Regex("^(v[1-9]+(\\.[0-9]+)*(-[0-9]+)?)$");
public async Task<string> Fetch(CancellationToken cancellation)
{
if (_updateurl == null)
return null;
using (var resp = await _httpClient.GetAsync(_updateurl, cancellation))
{
var strResp = await resp.Content.ReadAsStringAsync();

View file

@ -20,7 +20,6 @@
"BTCPAY_DEBUGLOG": "debug.log",
"BTCPAY_TORRCFILE": "../BTCPayServer.Tests/TestData/Tor/torrc",
"BTCPAY_SOCKSENDPOINT": "localhost:9050",
"BTCPAY_UPDATECHECK": "false",
"BTCPAY_UPDATEURL": ""
},
"applicationUrl": "http://127.0.0.1:14142/"