-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
27 lines (23 loc) · 742 Bytes
/
Copy pathProgram.cs
File metadata and controls
27 lines (23 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using CloudflareDDNS;
var host = Host.CreateDefaultBuilder(args)
.UseSystemd()
.ConfigureServices((hostContext, services) =>
{
var configuration = hostContext.Configuration;
var serviceConfiguration = configuration.GetSection("CloudflareDDNSConfiguration").Get<CloudflareDDNSConfiguration>();
var domains = configuration
.GetSection("Domains")
.Get<List<DnsConfiguration>>();
if (serviceConfiguration is not null && domains is not null)
{
serviceConfiguration.Domains = domains;
services.AddSingleton(serviceConfiguration);
}
else
{
throw new ArgumentNullException(nameof(configuration), "Configuration cannot be null");
}
services.AddHostedService<CloudflareDDNSService>();
})
.Build();
host.Run();