You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2021/10/13 22:55:03 UTC
[trafficserver] branch 9.2.x updated: Fix map_with_recv_port URL
remapping type. (#8406)
This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch 9.2.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/9.2.x by this push:
new 02b06cc Fix map_with_recv_port URL remapping type. (#8406)
02b06cc is described below
commit 02b06cc4703ee362906c8414b296bec699d9b621
Author: Walt Karas <wk...@verizonmedia.com>
AuthorDate: Tue Oct 12 17:32:59 2021 -0500
Fix map_with_recv_port URL remapping type. (#8406)
(cherry picked from commit 85e73b753ec730c55f34d556185a82ee904d5d96)
---
proxy/http/remap/RemapProcessor.cc | 7 ++++---
tests/gold_tests/remap/gold/remap-https-200_3.gold | 13 +++++++++++++
tests/gold_tests/remap/gold/remap2-200.gold | 14 ++++++++++++++
tests/gold_tests/remap/remap_http.test.py | 10 ++++++++++
tests/gold_tests/remap/remap_https.test.py | 10 ++++++++++
5 files changed, 51 insertions(+), 3 deletions(-)
diff --git a/proxy/http/remap/RemapProcessor.cc b/proxy/http/remap/RemapProcessor.cc
index 3081ae7..ec82148 100644
--- a/proxy/http/remap/RemapProcessor.cc
+++ b/proxy/http/remap/RemapProcessor.cc
@@ -77,9 +77,10 @@ RemapProcessor::setup_for_remap(HttpTransact::State *s, UrlRewrite *table)
Debug("url_rewrite", "[lookup] attempting %s lookup", proxy_request ? "proxy" : "normal");
if (table->num_rules_forward_with_recv_port) {
- Debug("url_rewrite", "[lookup] forward mappings with recv port found; Using recv port %d", s->client_info.dst_addr.port());
- if (table->forwardMappingWithRecvPortLookup(request_url, s->client_info.dst_addr.port(), request_host, request_host_len,
- s->url_map)) {
+ Debug("url_rewrite", "[lookup] forward mappings with recv port found; Using recv port %d",
+ s->client_info.dst_addr.host_order_port());
+ if (table->forwardMappingWithRecvPortLookup(request_url, s->client_info.dst_addr.host_order_port(), request_host,
+ request_host_len, s->url_map)) {
Debug("url_rewrite", "Found forward mapping with recv port");
mapping_found = true;
} else if (table->num_rules_forward == 0) {
diff --git a/tests/gold_tests/remap/gold/remap-https-200_3.gold b/tests/gold_tests/remap/gold/remap-https-200_3.gold
new file mode 100644
index 0000000..f5a6798
--- /dev/null
+++ b/tests/gold_tests/remap/gold/remap-https-200_3.gold
@@ -0,0 +1,13 @@
+``
+> GET / HTTP/1.1
+> Host: www.example3.com``
+> User-Agent: curl/``
+``
+< HTTP/1.1 200 OK
+< Date: ``
+< Age: ``
+< Transfer-Encoding: chunked
+< Connection: keep-alive
+< Server: ATS/``
+<
+``
diff --git a/tests/gold_tests/remap/gold/remap2-200.gold b/tests/gold_tests/remap/gold/remap2-200.gold
new file mode 100644
index 0000000..016e30e
--- /dev/null
+++ b/tests/gold_tests/remap/gold/remap2-200.gold
@@ -0,0 +1,14 @@
+``
+> GET http://www.example2.com``
+> Host: www.example2.com``
+> User-Agent: curl/``
+> Accept: */*
+``
+< HTTP/1.1 200 OK
+< Date: ``
+< Age: ``
+< Transfer-Encoding: chunked
+< Proxy-Connection: keep-alive
+< Server: ATS/``
+<
+``
diff --git a/tests/gold_tests/remap/remap_http.test.py b/tests/gold_tests/remap/remap_http.test.py
index 551f548..6bf9200 100644
--- a/tests/gold_tests/remap/remap_http.test.py
+++ b/tests/gold_tests/remap/remap_http.test.py
@@ -55,6 +55,9 @@ ts.Disk.remap_config.AddLine(
'map http://www.example.com http://127.0.0.1:{0}'.format(server.Variables.Port)
)
ts.Disk.remap_config.AddLine(
+ 'map_with_recv_port http://www.example2.com:{0} http://127.0.0.1:{1}'.format(ts.Variables.port, server.Variables.Port)
+)
+ts.Disk.remap_config.AddLine(
'map http://www.example.com:8080 http://127.0.0.1:{0}'.format(server.Variables.Port)
)
ts.Disk.remap_config.AddLine(
@@ -91,6 +94,13 @@ tr.Processes.Default.Command = 'curl --proxy 127.0.0.1:{0} "http://www.example.c
tr.Processes.Default.ReturnCode = 0
tr.Processes.Default.Streams.stderr = "gold/remap-200.gold"
+# www.example2.com host (match on receive port)
+tr = Test.AddTestRun()
+tr.Processes.Default.Command = 'curl --proxy 127.0.0.1:{0} "http://www.example2.com" -H "Proxy-Connection: keep-alive" --verbose'.format(
+ ts.Variables.port)
+tr.Processes.Default.ReturnCode = 0
+tr.Processes.Default.Streams.stderr = "gold/remap2-200.gold"
+
# www.example.com:80 host
tr = Test.AddTestRun()
tr.Processes.Default.Command = 'curl --proxy 127.0.0.1:{0} "http://www.example.com:80/" -H "Proxy-Connection: keep-alive" --verbose'.format(
diff --git a/tests/gold_tests/remap/remap_https.test.py b/tests/gold_tests/remap/remap_https.test.py
index a61d954..ba56dc8 100644
--- a/tests/gold_tests/remap/remap_https.test.py
+++ b/tests/gold_tests/remap/remap_https.test.py
@@ -56,6 +56,9 @@ ts.Disk.remap_config.AddLine(
'map https://www.example.com:{1} http://127.0.0.1:{0}'.format(server.Variables.Port, ts.Variables.ssl_port)
)
ts.Disk.remap_config.AddLine(
+ 'map_with_recv_port https://www.example3.com:{1} http://127.0.0.1:{0}'.format(server.Variables.Port, ts.Variables.ssl_port)
+)
+ts.Disk.remap_config.AddLine(
'map https://www.anotherexample.com https://127.0.0.1:{0}'.format(server2.Variables.SSL_Port, ts.Variables.ssl_port)
)
@@ -99,6 +102,13 @@ tr.Processes.Default.Command = 'curl --http1.1 -k https://127.0.0.1:{0} -H "Host
tr.Processes.Default.ReturnCode = 0
tr.Processes.Default.Streams.stderr = "gold/remap-https-200.gold"
+# www.example3.com (match on receive port)
+tr = Test.AddTestRun()
+tr.Processes.Default.Command = 'curl --http1.1 -k https://127.0.0.1:{0} -H "Host: www.example3.com" --verbose'.format(
+ ts.Variables.ssl_port)
+tr.Processes.Default.ReturnCode = 0
+tr.Processes.Default.Streams.stderr = "gold/remap-https-200_3.gold"
+
# no rule for this
tr = Test.AddTestRun()
tr.Processes.Default.Command = 'curl --http1.1 -k https://127.0.0.1:{0} -H "Host: www.test.com" --verbose'.format(