Compare commits

..

No commits in common. "e19fdbf11e1e66bab930cd884c3b8eaa9c0254d8" and "4c4d1d657e2befb7bda2a0e2412159a74858dd12" have entirely different histories.

5 changed files with 6 additions and 49 deletions

View File

@ -1,6 +1,6 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<Version>1.0.3</Version> <Version>1.0.2</Version>
<Authors>Tudor Stanciu</Authors> <Authors>Tudor Stanciu</Authors>
<Company>STA</Company> <Company>STA</Company>
<PackageTags>GoDaddyDDNS</PackageTags> <PackageTags>GoDaddyDDNS</PackageTags>

View File

@ -21,9 +21,3 @@ To make this worker functional, a minimum configuration is required:
## Stack ## Stack
* .NET (C#) * .NET (C#)
* Docker * Docker
## Changelog
**1.0.0** - The first release version of the service.
**1.0.1** - ConfigureAwait(false) was set for the http client get async calls.
**1.0.2** - .NET 6 upgrade.
**1.0.3** - The ```ExecutionTimeInSeconds``` parameter has been replaced with ```ExecutionFrequency``` which accepts values in the format ```30s```, ```10m```, ```1h``` or ```1d```.

View File

@ -1,37 +0,0 @@
using System;
using System.Text.RegularExpressions;
namespace GoDaddyDDNS.Utils
{
internal static class TimeSpanUtils
{
public static TimeSpan ParseTimeInterval(string timeInterval)
{
if (string.IsNullOrEmpty(timeInterval))
throw new ArgumentException("Time interval cannot be null or empty.");
var formatRegex = new Regex(@"^(\d+)([smhd])$", RegexOptions.IgnoreCase);
var match = formatRegex.Match(timeInterval);
if (!match.Success)
throw new ArgumentException("Invalid time interval format. Use format like '30s', '10m', '1h', or '1d'.");
var value = int.Parse(timeInterval.Substring(0, timeInterval.Length - 1));
var unit = timeInterval.Substring(timeInterval.Length - 1).ToLower();
switch (unit)
{
case "s": // seconds
return TimeSpan.FromSeconds(value);
case "m": // minutes
return TimeSpan.FromMinutes(value);
case "h": // hours
return TimeSpan.FromHours(value);
case "d": // days
return TimeSpan.FromDays(value);
default:
throw new ArgumentException("Invalid time interval unit.");
}
}
}
}

View File

@ -1,5 +1,4 @@
using GoDaddyDDNS.Abstractions; using GoDaddyDDNS.Abstractions;
using GoDaddyDDNS.Utils;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@ -13,15 +12,16 @@ namespace GoDaddyDDNS
{ {
private readonly ILogger<Worker> _logger; private readonly ILogger<Worker> _logger;
private readonly IDynamicDNSService _dynamicDNSService; private readonly IDynamicDNSService _dynamicDNSService;
private readonly TimeSpan _delay; private readonly int _delay;
public Worker(ILogger<Worker> logger, IDynamicDNSService dynamicDNSService, IConfiguration configuration) public Worker(ILogger<Worker> logger, IDynamicDNSService dynamicDNSService, IConfiguration configuration)
{ {
_logger=logger; _logger=logger;
_dynamicDNSService=dynamicDNSService; _dynamicDNSService=dynamicDNSService;
var delay = configuration.GetValue<string>("ExecutionFrequency"); var delayInSeconds = configuration.GetValue<int>("ExecutionTimeInSeconds");
_delay = TimeSpanUtils.ParseTimeInterval(delay); _delay = Convert.ToInt32(TimeSpan.FromSeconds(delayInSeconds).TotalMilliseconds);
} }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) protected override async Task ExecuteAsync(CancellationToken stoppingToken)

View File

@ -17,5 +17,5 @@
"Records": [ "@" ], "Records": [ "@" ],
"Key": "*********", "Key": "*********",
"Secret": "*********", "Secret": "*********",
"ExecutionFrequency": "60s" "ExecutionTimeInSeconds": 60
} }