예제 #1
0
        public void GetDnsRecord(GoDaddy goDaddyValues)
        {
            var client  = new RestClient(BuildApiUrl());
            var request = new RestRequest(Method.GET);

            request.RequestFormat = DataFormat.Json;
            request.AddHeader("Accept", "application/json");
            request.AddHeader("Content-Type", "application/json");
            request.AddHeader("Authorization", $"sso-key {goDaddyValues.ApiKey}:{goDaddyValues.ApiSecret}");
            var     response        = client.Execute(request);
            dynamic dynamicResponse = JsonConvert.DeserializeObject(response.Content);

            this.IpAddress = dynamicResponse[0].data;
            this.Ttl       = Convert.ToInt32(dynamicResponse[0].ttl);
            this.Type      = dynamicResponse[0].type;
        }
예제 #2
0
        static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json");

            var configuration = builder.Build();

            Console.WriteLine(configuration["ExternalIpServiceUrl"]);
            Console.WriteLine(configuration["GoDaddyUsername"]);
            Console.WriteLine(configuration["GodaddyPassword"]);



            //now start the program
            try
            {
                var currentIp = new CurrentIpAddress(configuration["ExternalIpServiceUrl"]);
                var goDaddy   = new GoDaddy()
                {
                    ApiUrl    = configuration["GoDaddyUrl"],
                    DnsName   = configuration["DnsName"],
                    DnsType   = configuration["DnsType"],
                    Domain    = configuration["Domain"],
                    ApiKey    = configuration["ApiKey"],
                    ApiSecret = configuration["ApiSecret"],
                };
                goDaddy.GetDnsRecord(goDaddy);
                currentIp.Value = Regex.Replace(currentIp.Value, @"\t|\n|\r", "");
                if (goDaddy.IpAddress != currentIp.Value)
                {
                    //update godaddy
                }
                Console.WriteLine(currentIp.Value);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }



            Console.ReadLine();
        }
예제 #3
0
 public Boolean UpdateDnsRecord(GoDaddy goDaddyValues)
 {
     return false
 }