Beispiel #1
0
        public IActionResult EditIP(string ip)
        {
            var recordId = record.RecordList(configuration.DomainName).Records.FirstOrDefault(r => r.Name == configuration.SubDomain)?.Id;

            if (record.Modify(configuration.DomainName, recordId, ip, configuration.SubDomain))
            {
                return(Content("修改完成!"));
            }
            else
            {
                return(Content("修改失败!"));
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("DnsPod Cli Tools v1.0");

            var builder = new ConfigurationBuilder();

            builder.AddCommandLine(args, new Dictionary <string, string> {
                { "-t", "Token" },
                { "-d", "DomainName" },
                { "-r", "RecordId" },
                { "-v", "Value" },
                { "-s", "SubDomain" },
                { "--type", "RecordType" }
            });
            var item = builder.Build().Get <CommandLineArgs>();

            if (item == null)
            {
                Console.WriteLine("请输入参数");
                PrintMenu();
                return;
            }

            Console.WriteLine("正在修改域名记录:" + item.SubDomain + "." + item.DomainName);

            DnsPodConfiguration configuration = new DnsPodConfiguration
            {
                Token = item.Token
            };
            DnsPodClient client = new DnsPodClient(new HttpClient(), configuration);
            DnsPodApi    record = new DnsPodApi(client);

            //如果用户没有输入RecordId,则通过List接口获取
            if (item.RecordId == null)
            {
                item.RecordId = record.RecordList(item.DomainName).Records.FirstOrDefault(r => r.Name == item.SubDomain)?.Id;
            }

            if (record.Modify(item.DomainName, item.RecordId, item.Value, item.SubDomain, item.RecordType))
            {
                Console.WriteLine("修改完成!");
            }
            else
            {
                Console.WriteLine("修改失败!");
            }
        }