change Platform to a EnumType

This commit is contained in:
2023-04-23 00:03:52 +08:00
parent 5ddf355799
commit f8df2fe468
4 changed files with 29 additions and 5 deletions

View File

@@ -12,9 +12,9 @@ namespace Hua.DDNS.Common.Config.Options
public class DomainOption public class DomainOption
{ {
/// <summary> /// <summary>
/// platform from [Ali,Tencent] /// platform from 1 Ali 2 Tencent
/// </summary> /// </summary>
public string Platform { get; set; } public PlatformEnum Platform { get; set; }
/// <summary> /// <summary>
/// Id, the id and key from AliCould or DnsPod /// Id, the id and key from AliCould or DnsPod

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Hua.DDNS.Common.Config.Options
{
/// <summary>
/// DDNS Platform
/// </summary>
public enum PlatformEnum
{
/// <summary>
/// Ali
/// </summary>
Ali = 1,
/// <summary>
/// Tencent
/// </summary>
Tencent
}
}

View File

@@ -66,7 +66,7 @@ namespace Hua.DDNS.Jobs
//更新Ip记录 //更新Ip记录
switch (_domainOption.Platform) switch (_domainOption.Platform)
{ {
case "Tencent": case PlatformEnum.Tencent:
var _dnspodClient = new DnspodClient( var _dnspodClient = new DnspodClient(
// 实例化一个认证对象入参需要传入腾讯云账户secretIdsecretKey,此处还需注意密钥对的保密 // 实例化一个认证对象入参需要传入腾讯云账户secretIdsecretKey,此处还需注意密钥对的保密
// 密钥可前往https://console.cloud.tencent.com/cam/capi网站进行获取 // 密钥可前往https://console.cloud.tencent.com/cam/capi网站进行获取
@@ -97,7 +97,7 @@ namespace Hua.DDNS.Jobs
}); });
break; break;
case "Ali": case PlatformEnum.Ali:
var aliClient = new AlibabaCloud.SDK.Alidns20150109.Client(new Config() var aliClient = new AlibabaCloud.SDK.Alidns20150109.Client(new Config()
{ {
// 您的 AccessKey ID // 您的 AccessKey ID

View File

@@ -14,7 +14,7 @@
}, },
"Domain": { "Domain": {
"Platform": "Ali", "Platform": 1, //1 Ali 2 Tencent
// Access Id/Secret Id // Access Id/Secret Id
"Id": "Id", "Id": "Id",
// Access Key/Secret Key // Access Key/Secret Key