Skip to content

Commit

Permalink
删除ENDPOINT的设置,改为自动解析获取。
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjusss committed May 22, 2020
1 parent 4b53b99 commit dff6e2a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
4 changes: 0 additions & 4 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ docker run -d --restart=always --net=host \
-e "AKID=[ALIYUN's AccessKey-ID]" \
-e "AKSCT=[ALIYUN's AccessKey-Secret]" \
-e "DOMAIN=ddns.aliyun.win" \
-e "ENDPOINT=cn-hangzhou" \
-e "REDO=30" \
-e "TTL=60" \
-e "TIMEZONE=8.0" \
Expand All @@ -28,7 +27,6 @@ docker run -d --restart=always --net=host \
|AKID|阿里云的Access Key ID。[获取阿里云AccessToken](https://usercenter.console.aliyun.com/)|access key id|
|AKSCT|阿里云的Access Key Secret。|access key secret|
|DOMAIN|需要更新的域名,多个域名需要“,”分隔。|my.domain.com|
|ENDPOINT|[详见定义](https://help.aliyun.com/document_detail/40654.html?spm=a2c4e.11153987.0.0.6d85366aUfTWbG)|cn-hangzhou|
|REDO|更新间隔,单位秒。建议大于等于TTL/2。|300|
|TTL|服务器缓存解析记录的时长,单位秒,普通用户最小为600。|600|
|TIMEZONE|输出日志时的时区,单位小时。|8|
Expand All @@ -52,7 +50,6 @@ dotnet aliyun-ddns.dll \
-u "ALIYUN's AccessKey-ID" \
-p "ALIYUN's AccessKey-Secret" \
-d "ddns.aliyun.win,ddns2.aliyun2.win" \
-e "cn-hangzhou" \
-i 300 \
-t 600 \
--timezone 8.0 \
Expand All @@ -65,7 +62,6 @@ dotnet aliyun-ddns.dll \
|u|阿里云的Access Key ID。[获取阿里云AccessToken](https://usercenter.console.aliyun.com/)|access key id|
|p|阿里云的Access Key Secret。|access key secret|
|d|需要更新的域名,多个域名需要“,”分隔。|my.domain.com|
|e|[详见定义](https://help.aliyun.com/document_detail/40654.html?spm=a2c4e.11153987.0.0.6d85366aUfTWbG)|cn-hangzhou|
|i|更新间隔,单位秒。建议大于等于TTL/2。|300|
|t|服务器缓存解析记录的时长,单位秒,普通用户最小为600。|600|
|timezone|输出日志时的时区,单位小时。|8|
Expand Down
9 changes: 5 additions & 4 deletions aliyun-ddns/DomainUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
using System.Linq;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using static Aliyun.Acs.Alidns.Model.V20150109.DescribeSubDomainRecordsResponse;

namespace aliyun_ddns
{
using Record=DescribeSubDomainRecords_Record;
using Record = DescribeSubDomainRecords_Record;
/// <summary>
/// 域名更新类。
/// </summary>
Expand Down Expand Up @@ -222,8 +221,10 @@ private IEnumerable<IpType> GetSupportIpTypes()
/// <returns>新的阿里云客户端</returns>
private DefaultAcsClient GetNewClient()
{
var clientProfile = DefaultProfile.GetProfile(Options.Instance.ENDPOINT, Options.Instance.AKID, Options.Instance.AKSCT);
return new DefaultAcsClient(clientProfile);
//var clientProfile = DefaultProfile.GetProfile(Options.Instance.ENDPOINT, Options.Instance.AKID, Options.Instance.AKSCT);
//return new DefaultAcsClient(clientProfile);
return new DefaultAcsClient(DefaultProfile.GetProfile(),
new Aliyun.Acs.Core.Auth.BasicCredentials(Options.Instance.AKID, Options.Instance.AKSCT));
}

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions aliyun-ddns/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ public class Options
[Option('p', "access-key-secret", Required = false, Default = "access key secret", HelpText = "access key secret")]
public string AKSCT { get; set; } = "access key secret";
[Option('e', "endpoint", Required = false, Default = "cn-hangzhou", HelpText = "Region Id,详见https://help.aliyun.com/document_detail/40654.html?spm=a2c4e.11153987.0.0.6d85366aUfTWbG")]
public string ENDPOINT { get; set; } = "cn-hangzhou";
[Option('d', "domain", Required = false, Default = "my.domain.com", HelpText = "需要更新的域名,可以用“,”隔开。")]
//public string ENDPOINT { get; set; } = "cn-hangzhou";
//[Option('d', "domain", Required = false, Default = "my.domain.com", HelpText = "需要更新的域名,可以用“,”隔开。")]
public string DOMAIN { get; set; } = "my.domain.com";
[Option('i', "interval", Required = false, Default = 300, HelpText = "执行域名更新的间隔,单位秒。")]
public int REDO { get; set; } = 300;
Expand Down Expand Up @@ -55,7 +55,7 @@ private void InitOptionsFromEnvironment()
{
AKID = Environment.GetEnvironmentVariable("AKID") ?? AKID;
AKSCT = Environment.GetEnvironmentVariable("AKSCT") ?? AKSCT;
ENDPOINT = Environment.GetEnvironmentVariable("ENDPOINT") ?? ENDPOINT;
//ENDPOINT = Environment.GetEnvironmentVariable("ENDPOINT") ?? ENDPOINT;
DOMAIN = Environment.GetEnvironmentVariable("DOMAIN") ?? DOMAIN;
TYPE = Environment.GetEnvironmentVariable("TYPE") ?? TYPE;

Expand Down
3 changes: 1 addition & 2 deletions aliyun-ddns/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using aliyun_ddns.Common;
using CommandLine;
using CommandLine;
using System;

namespace aliyun_ddns
Expand Down

0 comments on commit dff6e2a

Please sign in to comment.