Skip to content

Commit

Permalink
当无任何需要IPV6解析的记录存在时,不进行IPV6地址的获取。
Browse files Browse the repository at this point in the history
  • Loading branch information
CarmJos committed Oct 31, 2021
1 parent 185a5f7 commit 704bf29
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/main/java/cc/carm/app/aliddns/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public class Main {

private static TimerTask updateTimerTask;


public static void main(String[] args) throws InterruptedException {
print("-------------------------------------------");
print("阿里云服务 DDNS更新器");
Expand Down Expand Up @@ -101,4 +100,9 @@ public static ConfigManager getConfigManager() {
public static RequestManager getRequestManager() {
return requestManager;
}

public static TimerTask getUpdateTimerTask() {
return updateTimerTask;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class RequestManager {
public final String SECTION = "UpdateRequests";

private int updatedTimes = 1;
private boolean hasIPv6 = false;

private final SimpleDateFormat format;

public final HashMap<String, UpdateRequest> requests;
Expand Down Expand Up @@ -49,6 +51,9 @@ public int loadRequests() {
}
}

this.hasIPv6 = getRequests().values().stream().anyMatch(UpdateRequest::isIpv6);
this.updatedTimes = 1;

return getRequests().size();
}

Expand All @@ -62,7 +67,7 @@ public void doUpdate() {
Main.info(" 获取完成,当前IPv4地址为 " + IPv4);

String IPv6 = null;
if (ConfigManager.isIPV6Enabled()) {
if (ConfigManager.isIPV6Enabled() && hasIPv6) {
Main.info("开始从 " + ConfigManager.getIPv6QueryURL() + " 获取IPv6地址...");
IPv6 = getCurrentHostIP(true);
Main.info(" 获取完成,当前IPv6地址为 " + IPv6);
Expand Down

0 comments on commit 704bf29

Please sign in to comment.