From b742190e7b0ad2cb00fc2eee60a31a9cb5dd23aa Mon Sep 17 00:00:00 2001 From: Steve Hamrick Date: Thu, 12 Nov 2020 20:06:53 -0700 Subject: [PATCH 1/3] Fix LE Watcher --- .../ds/LetsEncryptDnsChallengeWatcher.java | 26 ++++++++++++++----- .../webapp/WEB-INF/applicationContext.xml | 17 ++++++------ 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/ds/LetsEncryptDnsChallengeWatcher.java b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/ds/LetsEncryptDnsChallengeWatcher.java index d568085bb8..f009f6a893 100644 --- a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/ds/LetsEncryptDnsChallengeWatcher.java +++ b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/ds/LetsEncryptDnsChallengeWatcher.java @@ -29,6 +29,7 @@ import org.apache.log4j.Logger; import java.io.*; +import java.nio.file.Path; import java.time.Instant; import java.util.HashMap; import java.util.List; @@ -36,13 +37,10 @@ public class LetsEncryptDnsChallengeWatcher extends AbstractResourceWatcher { private static final Logger LOGGER = Logger.getLogger(LetsEncryptDnsChallengeWatcher.class); public static final String DEFAULT_LE_DNS_CHALLENGE_URL = "https://${toHostname}/api/2.0/letsencrypt/dnsrecords/"; - private static final String configFile = "/opt/traffic_router/db/cr-config.json"; + private String configFile; private ConfigHandler configHandler; - - public void setConfigHandler(final ConfigHandler configHandler) { - this.configHandler = configHandler; - } + private Path databasesDirectory; public LetsEncryptDnsChallengeWatcher() { setDatabaseUrl(DEFAULT_LE_DNS_CHALLENGE_URL); @@ -134,7 +132,7 @@ public String getWatcherConfigPrefix() { private String readConfigFile() { try { - final InputStream is = new FileInputStream(configFile); + final InputStream is = new FileInputStream(databasesDirectory.resolve(configFile).toString()); final BufferedReader buf = new BufferedReader(new InputStreamReader(is)); String line = buf.readLine(); final StringBuilder sb = new StringBuilder(); @@ -144,7 +142,7 @@ private String readConfigFile() { } return sb.toString(); } catch (Exception e) { - LOGGER.error("Could not read cr-config file."); + LOGGER.error("Could not read cr-config file " + configFile + "."); return null; } } @@ -178,4 +176,18 @@ private ArrayNode updateStaticEntries(final LetsEncryptDnsChallenge challenge, f return newStaticDnsEntriesNode; } + public void setConfigHandler(final ConfigHandler configHandler) { + this.configHandler = configHandler; + } + public ConfigHandler getConfigHandler() { + return this.configHandler; + } + + public void setDatabasesDirectory(final Path databasesDirectory) { + this.databasesDirectory = databasesDirectory; + } + + public void setConfigFile(final String configFile) { + this.configFile = configFile; + } } diff --git a/traffic_router/core/src/main/webapp/WEB-INF/applicationContext.xml b/traffic_router/core/src/main/webapp/WEB-INF/applicationContext.xml index 544cf55a18..0d69176759 100644 --- a/traffic_router/core/src/main/webapp/WEB-INF/applicationContext.xml +++ b/traffic_router/core/src/main/webapp/WEB-INF/applicationContext.xml @@ -89,14 +89,15 @@ - - - - - - - - + + + + + + + + + From a19a91a66952644ecad14473afccba08c7783430 Mon Sep 17 00:00:00 2001 From: shamrickus Date: Fri, 13 Nov 2020 08:24:02 -0700 Subject: [PATCH 2/3] Forgot Changelog --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 776a79bca5..0ebce43dc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Added locationByDeepCoverageZone to the `crs/stats/ip/{ip}` endpoint in the Traffic Router API ### Fixed -- Fixed #5274 - CDN in a Box's Traffic Vault image failed to build due to Basho's repo responding with 402 Payment Required. The repo has been removed from the image. +- [#5274](https://github.com/apache/trafficcontrol/issues/5274) - CDN in a Box's Traffic Vault image failed to build due + to Basho's repo responding with 402 Payment Required. The repo has been removed from the image. +- [#5069](https://github.com/apache/trafficcontrol/issues/5069) - For LetsEncryptDnsChallengerWatcher in Traffic Router, + the cr-config location is configurable instead of only looking at `/opt/traffic_router/db/cr-config.json` ## [5.0.0] - 2020-10-20 ### Added From 18c0417d572526e128d9d0507a5b91fa23ba181a Mon Sep 17 00:00:00 2001 From: shamrickus Date: Fri, 13 Nov 2020 09:07:52 -0700 Subject: [PATCH 3/3] Use tabs --- .../main/webapp/WEB-INF/applicationContext.xml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/traffic_router/core/src/main/webapp/WEB-INF/applicationContext.xml b/traffic_router/core/src/main/webapp/WEB-INF/applicationContext.xml index 0d69176759..55ef754d61 100644 --- a/traffic_router/core/src/main/webapp/WEB-INF/applicationContext.xml +++ b/traffic_router/core/src/main/webapp/WEB-INF/applicationContext.xml @@ -89,15 +89,15 @@ - - - - - - - - - + + + + + + + + +