You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by ne...@apache.org on 2016/12/05 20:46:54 UTC
[1/2] incubator-trafficcontrol git commit: TR now logs original
remote host IP when using X-MM-Client-IP. This closes TC-53
Repository: incubator-trafficcontrol
Updated Branches:
refs/heads/master 78b5c0c4e -> 7afccdb65
TR now logs original remote host IP when using X-MM-Client-IP. This closes TC-53
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/0aa4a73e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/0aa4a73e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/0aa4a73e
Branch: refs/heads/master
Commit: 0aa4a73e69ef289b9e8ef6c89f98389ba179253e
Parents: 78b5c0c
Author: trevorackerman <tr...@gmail.com>
Authored: Mon Nov 28 15:07:44 2016 -0700
Committer: Dave Neuman <ne...@apache.org>
Committed: Mon Dec 5 13:46:15 2016 -0700
----------------------------------------------------------------------
.../core/http/HTTPAccessEventBuilder.java | 14 ++++++++++++--
.../core/http/HTTPAccessEventBuilderTest.java | 17 +++++++++--------
2 files changed, 21 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/0aa4a73e/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/http/HTTPAccessEventBuilder.java
----------------------------------------------------------------------
diff --git a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/http/HTTPAccessEventBuilder.java b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/http/HTTPAccessEventBuilder.java
index ca2712e..96803c7 100644
--- a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/http/HTTPAccessEventBuilder.java
+++ b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/http/HTTPAccessEventBuilder.java
@@ -106,6 +106,7 @@ public class HTTPAccessEventBuilder {
final String xMmClientIpHeader = httpServletRequest.getHeader(HTTPRequest.X_MM_CLIENT_IP);
final String fakeIpParameter = httpServletRequest.getParameter(HTTPRequest.FAKE_IP);
+ final String remoteIp = chi;
if (xMmClientIpHeader != null) {
chi = xMmClientIpHeader;
} else if (fakeIpParameter != null) {
@@ -115,8 +116,17 @@ public class HTTPAccessEventBuilder {
final String rgb = formatObject(httpAccessRecord.getRegionalGeoResult());
final StringBuilder stringBuilder = new StringBuilder(timeString)
- .append(" qtype=HTTP chi=").append(chi)
- .append(" url=\"").append(url)
+ .append(" qtype=HTTP chi=")
+ .append(chi)
+ .append(" rhi=");
+
+ if (!remoteIp.equals(chi)) {
+ stringBuilder.append(remoteIp);
+ } else {
+ stringBuilder.append('-');
+ }
+
+ stringBuilder.append(" url=\"").append(url)
.append("\" cqhm=").append(cqhm)
.append(" cqhv=").append(cqhv)
.append(" rtype=").append(resultType)
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/0aa4a73e/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/http/HTTPAccessEventBuilderTest.java
----------------------------------------------------------------------
diff --git a/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/http/HTTPAccessEventBuilderTest.java b/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/http/HTTPAccessEventBuilderTest.java
index 4a4d9d2..80e119f 100644
--- a/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/http/HTTPAccessEventBuilderTest.java
+++ b/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/http/HTTPAccessEventBuilderTest.java
@@ -74,7 +74,7 @@ public class HTTPAccessEventBuilderTest {
String httpAccessEvent = HTTPAccessEventBuilder.create(httpAccessRecord);
- assertThat(httpAccessEvent, equalTo("144140678.000 qtype=HTTP chi=192.168.7.6 url=\"http://example.com/index.html?foo=bar\" cqhm=GET cqhv=HTTP/1.1 rtype=- rloc=\"-\" rdtl=- rerr=\"-\" rgb=\"-\" rurl=\"-\" rh=\"-\""));
+ assertThat(httpAccessEvent, equalTo("144140678.000 qtype=HTTP chi=192.168.7.6 rhi=- url=\"http://example.com/index.html?foo=bar\" cqhm=GET cqhv=HTTP/1.1 rtype=- rloc=\"-\" rdtl=- rerr=\"-\" rgb=\"-\" rurl=\"-\" rh=\"-\""));
}
@Test
@@ -91,7 +91,7 @@ public class HTTPAccessEventBuilderTest {
HTTPAccessRecord httpAccessRecord = builder.resultType(ResultType.CZ).build();
String httpAccessEvent = HTTPAccessEventBuilder.create(httpAccessRecord);
- assertThat(httpAccessEvent, equalTo("144140678.000 qtype=HTTP chi=192.168.7.6 url=\"http://example.com/index.html?foo=bar\" cqhm=GET cqhv=HTTP/1.1 rtype=CZ rloc=\"39.75,-104.99\" rdtl=- rerr=\"-\" rgb=\"-\" pssc=302 ttms=125.000 rurl=\"http://example.com/hereitis/index.html?foo=bar\" rh=\"-\""));
+ assertThat(httpAccessEvent, equalTo("144140678.000 qtype=HTTP chi=192.168.7.6 rhi=- url=\"http://example.com/index.html?foo=bar\" cqhm=GET cqhv=HTTP/1.1 rtype=CZ rloc=\"39.75,-104.99\" rdtl=- rerr=\"-\" rgb=\"-\" pssc=302 ttms=125.000 rurl=\"http://example.com/hereitis/index.html?foo=bar\" rh=\"-\""));
}
@Test
@@ -111,7 +111,7 @@ public class HTTPAccessEventBuilderTest {
HTTPAccessRecord httpAccessRecord = builder.build();
String httpAccessEvent = HTTPAccessEventBuilder.create(httpAccessRecord);
- assertThat(httpAccessEvent, equalTo("144140678.000 qtype=HTTP chi=192.168.7.6 url=\"http://example.com/index.html?foo=bar\" cqhm=GET cqhv=HTTP/1.1 rtype=ERROR rloc=\"-\" rdtl=- rerr=\"-\" rgb=\"-\" pssc=302 ttms=0.124 rurl=\"http://example.com/hereitis/index.html?foo=bar\" rh=\"-\""));
+ assertThat(httpAccessEvent, equalTo("144140678.000 qtype=HTTP chi=192.168.7.6 rhi=- url=\"http://example.com/index.html?foo=bar\" cqhm=GET cqhv=HTTP/1.1 rtype=ERROR rloc=\"-\" rdtl=- rerr=\"-\" rgb=\"-\" pssc=302 ttms=0.124 rurl=\"http://example.com/hereitis/index.html?foo=bar\" rh=\"-\""));
}
@@ -133,7 +133,7 @@ public class HTTPAccessEventBuilderTest {
HTTPAccessRecord httpAccessRecord = builder.build();
String httpAccessEvent = HTTPAccessEventBuilder.create(httpAccessRecord);
- assertThat(httpAccessEvent, equalTo("144140678.000 qtype=HTTP chi=192.168.7.6 url=\"http://example.com/index.html?foo=bar\" cqhm=GET cqhv=HTTP/1.1 rtype=ERROR rloc=\"-\" rdtl=- rerr=\"RuntimeException: you're doing it wrong\" rgb=\"-\" pssc=302 ttms=0.456 rurl=\"http://example.com/hereitis/index.html?foo=bar\" rh=\"-\""));
+ assertThat(httpAccessEvent, equalTo("144140678.000 qtype=HTTP chi=192.168.7.6 rhi=- url=\"http://example.com/index.html?foo=bar\" cqhm=GET cqhv=HTTP/1.1 rtype=ERROR rloc=\"-\" rdtl=- rerr=\"RuntimeException: you're doing it wrong\" rgb=\"-\" pssc=302 ttms=0.456 rurl=\"http://example.com/hereitis/index.html?foo=bar\" rh=\"-\""));
}
@Test
@@ -152,7 +152,7 @@ public class HTTPAccessEventBuilderTest {
HTTPAccessRecord httpAccessRecord = builder.build();
String httpAccessEvent = HTTPAccessEventBuilder.create(httpAccessRecord);
- assertThat(httpAccessEvent, equalTo("144140678.000 qtype=HTTP chi=192.168.7.6 url=\"http://example.com/index.html?foo=bar\" cqhm=GET cqhv=HTTP/1.1 rtype=MISS rloc=\"-\" rdtl=DS_NO_BYPASS rerr=\"-\" rgb=\"-\" pssc=503 ttms=0.789 rurl=\"-\" rh=\"-\""));
+ assertThat(httpAccessEvent, equalTo("144140678.000 qtype=HTTP chi=192.168.7.6 rhi=- url=\"http://example.com/index.html?foo=bar\" cqhm=GET cqhv=HTTP/1.1 rtype=MISS rloc=\"-\" rdtl=DS_NO_BYPASS rerr=\"-\" rgb=\"-\" pssc=503 ttms=0.789 rurl=\"-\" rh=\"-\""));
}
@Test
@@ -183,11 +183,12 @@ public class HTTPAccessEventBuilderTest {
@Test
public void itUsesXMmClientIpHeaderForChi() throws Exception {
when(request.getHeader(HTTPRequest.X_MM_CLIENT_IP)).thenReturn("192.168.100.100");
+ when(request.getRemoteAddr()).thenReturn("12.34.56.78");
HTTPAccessRecord httpAccessRecord = new HTTPAccessRecord.Builder(new Date(144140678000L), request).build();
String httpAccessEvent = HTTPAccessEventBuilder.create(httpAccessRecord);
- assertThat(httpAccessEvent, equalTo("144140678.000 qtype=HTTP chi=192.168.100.100 url=\"http://example.com/index.html?foo=bar\" cqhm=GET cqhv=HTTP/1.1 rtype=- rloc=\"-\" rdtl=- rerr=\"-\" rgb=\"-\" rurl=\"-\" rh=\"-\""));
+ assertThat(httpAccessEvent, equalTo("144140678.000 qtype=HTTP chi=192.168.100.100 rhi=12.34.56.78 url=\"http://example.com/index.html?foo=bar\" cqhm=GET cqhv=HTTP/1.1 rtype=- rloc=\"-\" rdtl=- rerr=\"-\" rgb=\"-\" rurl=\"-\" rh=\"-\""));
}
@Test
@@ -197,7 +198,7 @@ public class HTTPAccessEventBuilderTest {
HTTPAccessRecord httpAccessRecord = new HTTPAccessRecord.Builder(new Date(144140678000L), request).build();
String httpAccessEvent = HTTPAccessEventBuilder.create(httpAccessRecord);
- assertThat(httpAccessEvent, equalTo("144140678.000 qtype=HTTP chi=192.168.123.123 url=\"http://example.com/index.html?foo=bar\" cqhm=GET cqhv=HTTP/1.1 rtype=- rloc=\"-\" rdtl=- rerr=\"-\" rgb=\"-\" rurl=\"-\" rh=\"-\""));
+ assertThat(httpAccessEvent, equalTo("144140678.000 qtype=HTTP chi=192.168.123.123 rhi=192.168.7.6 url=\"http://example.com/index.html?foo=bar\" cqhm=GET cqhv=HTTP/1.1 rtype=- rloc=\"-\" rdtl=- rerr=\"-\" rgb=\"-\" rurl=\"-\" rh=\"-\""));
}
@Test
@@ -208,6 +209,6 @@ public class HTTPAccessEventBuilderTest {
HTTPAccessRecord httpAccessRecord = new HTTPAccessRecord.Builder(new Date(144140678000L), request).build();
String httpAccessEvent = HTTPAccessEventBuilder.create(httpAccessRecord);
- assertThat(httpAccessEvent, equalTo("144140678.000 qtype=HTTP chi=192.168.100.100 url=\"http://example.com/index.html?foo=bar\" cqhm=GET cqhv=HTTP/1.1 rtype=- rloc=\"-\" rdtl=- rerr=\"-\" rgb=\"-\" rurl=\"-\" rh=\"-\""));
+ assertThat(httpAccessEvent, equalTo("144140678.000 qtype=HTTP chi=192.168.100.100 rhi=192.168.7.6 url=\"http://example.com/index.html?foo=bar\" cqhm=GET cqhv=HTTP/1.1 rtype=- rloc=\"-\" rdtl=- rerr=\"-\" rgb=\"-\" rurl=\"-\" rh=\"-\""));
}
}
[2/2] incubator-trafficcontrol git commit: This closes #105
Posted by ne...@apache.org.
This closes #105
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/7afccdb6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/7afccdb6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/7afccdb6
Branch: refs/heads/master
Commit: 7afccdb657a16b8d1b9d2cb0dc04b2c2d9eecfcd
Parents: 0aa4a73
Author: Dave Neuman <ne...@apache.org>
Authored: Mon Dec 5 13:46:37 2016 -0700
Committer: Dave Neuman <ne...@apache.org>
Committed: Mon Dec 5 13:46:37 2016 -0700
----------------------------------------------------------------------
----------------------------------------------------------------------