Created
August 31, 2022 16:58
-
-
Save blubbll/3f32d6dcac0ac021856490b77ddaba34 to your computer and use it in GitHub Desktop.
c# shit for shrine dns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using CloudFlare.Client; | |
using CloudFlare.Client.Api.Zones.DnsRecord; | |
using System; | |
using System.Configuration; | |
using System.Linq; | |
using System.Net; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace ShrineR | |
{ | |
internal class Program | |
{ | |
private static string ip() | |
{ | |
using (var wc = new WebClient()) | |
{ | |
return wc.DownloadString("https://checkip.amazonaws.com"); | |
} | |
} | |
private static async Task Main(string[] args) | |
{ | |
using (var client = new CloudFlareClient(ConfigurationManager.AppSettings["cf_user"], ConfigurationManager.AppSettings["cf_globalkey"])) | |
{ | |
var ct = new CancellationToken(); | |
var zones = await client.Zones.GetAsync(cancellationToken: ct); | |
var exxoZone = zones.Result.FirstOrDefault(x => x.Name.Equals("exxo.cloud")); | |
var dnsRecords = await client.Zones.DnsRecords.GetAsync(exxoZone.Id, cancellationToken: ct); | |
var silver = dnsRecords.Result.FirstOrDefault(x => x.Name.StartsWith("silver.")); | |
var modified = new ModifiedDnsRecord | |
{ | |
Type = silver.Type,//DnsRecordType.A, | |
Name = silver.Name, | |
Ttl = 60, //Seconds | |
Content = ip() | |
}; | |
await client.Zones.DnsRecords.UpdateAsync(exxoZone.Id, silver.Id, modified, ct); | |
Console.WriteLine("updated dns ip to " + modified.Content); | |
Thread.Sleep(9999); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment