This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new bf9eab6cab Preparatory work for switching to using either Pattern or
CIDR
bf9eab6cab is described below
commit bf9eab6cab42233927533edccad3909c941d1bd3
Author: Mark Thomas <[email protected]>
AuthorDate: Wed Oct 1 11:57:45 2025 +0100
Preparatory work for switching to using either Pattern or CIDR
---
.../apache/catalina/filters/RemoteIpFilter.java | 50 ++++++++++++++++++++++
.../catalina/filters/TestRemoteIpFilter.java | 3 +-
2 files changed, 52 insertions(+), 1 deletion(-)
diff --git a/java/org/apache/catalina/filters/RemoteIpFilter.java
b/java/org/apache/catalina/filters/RemoteIpFilter.java
index 6e116047a3..efe96618c9 100644
--- a/java/org/apache/catalina/filters/RemoteIpFilter.java
+++ b/java/org/apache/catalina/filters/RemoteIpFilter.java
@@ -947,10 +947,35 @@ public class RemoteIpFilter extends GenericFilter {
return httpsServerPort;
}
+ /**
+ * Obtain the currently configured regular expression Pattern for internal
proxies.
+ *
+ * @return The currently configured regular expression Pattern for
internal proxies
+ *
+ * @deprecated The implementation of this method will be replaced with the
implementation of
+ * {@link #getInternalProxiesAsString()} in Tomcat 12
onwards with the return type changing to
+ * {@code String}
+ */
+ @Deprecated
public Pattern getInternalProxies() {
return internalProxies;
}
+ /**
+ * Obtain the currently configured internal proxies.
+ *
+ * @return The currently configured internal proxies.
+ *
+ * @deprecated This method will be renamed to {@code getInternalProxies()}
as of Tomcat 12
+ */
+ @Deprecated
+ public String getInternalProxiesAsString() {
+ if (internalProxies == null) {
+ return null;
+ }
+ return internalProxies.toString();
+ }
+
public String getProtocolHeader() {
return protocolHeader;
}
@@ -980,10 +1005,35 @@ public class RemoteIpFilter extends GenericFilter {
return requestAttributesEnabled;
}
+ /**
+ * Obtain the currently configured regular expression Pattern for trusted
proxies.
+ *
+ * @return The currently configured regular expression Pattern for trusted
proxies
+ *
+ * @deprecated The implementation of this method will be replaced with the
implementation of
+ * {@link #getTrustedProxiesAsString()} in Tomcat 12
onwards with the return type changing to
+ * {@code String}
+ */
+ @Deprecated
public Pattern getTrustedProxies() {
return trustedProxies;
}
+ /**
+ * Obtain the currently configured trusted proxies.
+ *
+ * @return The currently configured trusted proxies.
+ *
+ * @deprecated This method will be renamed to {@code getInternalProxies()}
as of Tomcat 12
+ */
+ @Deprecated
+ public String getTrustedProxiesAsString() {
+ if (trustedProxies == null) {
+ return null;
+ }
+ return trustedProxies.toString();
+ }
+
public boolean getEnableLookups() {
return enableLookups;
}
diff --git a/test/org/apache/catalina/filters/TestRemoteIpFilter.java
b/test/org/apache/catalina/filters/TestRemoteIpFilter.java
index f69e255ee1..2cfcd1e224 100644
--- a/test/org/apache/catalina/filters/TestRemoteIpFilter.java
+++ b/test/org/apache/catalina/filters/TestRemoteIpFilter.java
@@ -844,7 +844,8 @@ public class TestRemoteIpFilter extends TomcatBaseTest {
@Test
public void testInternalProxies() throws Exception {
RemoteIpFilter remoteIpFilter = new RemoteIpFilter();
- Pattern internalProxiesPattern = remoteIpFilter.getInternalProxies();
+ @SuppressWarnings("deprecation")
+ Pattern internalProxiesPattern =
Pattern.compile(remoteIpFilter.getInternalProxiesAsString());
doTestPattern(internalProxiesPattern, "8.8.8.8", false);
doTestPattern(internalProxiesPattern, "100.62.0.0", false);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]