aboutsummaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2024-08-03 10:27:07 +0000
committerOmar Polo <op@omarpolo.com>2024-08-03 10:27:07 +0000
commit040f7aaca1032511212b4fbad28717dcfadc3d49 (patch)
treec7d45134b16420b998f9b4fd78d060972b5a9549 /regress
parent9360fb1a552b13b24f0b21bfd7146460e87341e0 (diff)
add support for using the proxy protocol v1 when proxying too
This is symmetrical to the support for *incoming* requests. The new regress case uses this to proxy to itself using the proxy-protocol v1. Fixes https://github.com/omar-polo/gmid/issues/31
Diffstat (limited to 'regress')
-rw-r--r--regress/lib.sh3
-rwxr-xr-xregress/regress1
-rw-r--r--regress/tests.sh29
3 files changed, 32 insertions, 1 deletions
diff --git a/regress/lib.sh b/regress/lib.sh
index 6116cd7..561f9bf 100644
--- a/regress/lib.sh
+++ b/regress/lib.sh
@@ -14,6 +14,7 @@ run_test() {
host="$REGRESS_HOST"
port=10965
proxy_port=10966
+ proxy=
config_common="log syslog off"
hdr=
body=
@@ -72,7 +73,7 @@ server "$server_name" {
cert "$PWD/localhost.pem"
key "$PWD/localhost.key"
root "$PWD/testdata"
- listen on $host port $port
+ listen on $host port $port $proxy
$2
}
EOF
diff --git a/regress/regress b/regress/regress
index 82d17a9..c3bbed8 100755
--- a/regress/regress
+++ b/regress/regress
@@ -69,6 +69,7 @@ run_test test_ipv4_addr
run_test test_ipv6_addr need_ipv6
run_test test_ipv6_server need_ipv6
run_test test_high_prefork
+run_test test_proxy_protocol_v1
# TODO: add test that uses only a TLSv1.2 or TLSv1.3
# TODO: add a test that attempt to serve a non-regular file
diff --git a/regress/tests.sh b/regress/tests.sh
index 4905dbc..cfc7c6a 100644
--- a/regress/tests.sh
+++ b/regress/tests.sh
@@ -533,3 +533,32 @@ test_high_prefork() {
dont_check_server_alive=yes
kill "$(cat gmid.pid)" 2>/dev/null || true
}
+
+test_proxy_protocol_v1() {
+ rm -f log
+ proxy=proxy-v1
+ gen_config '
+log access "'$PWD'/log"
+log style legacy' ''
+ set_proxy 'proxy-v1'
+ run
+
+ ggflags="-P localhost:$proxy_port -H localhost.local"
+
+ # This will generate two log entry: one for the "frontend"
+ # and one for the proxied request. Both should have exactly
+ # the same IP and port.
+ fetch_hdr /
+ check_reply '20 text/gemini'
+
+ n=$(awk '{print $1}' log | uniq | wc -l)
+ if [ "$n" -ne 1 ]; then
+ # keep the log for post-mortem analysis
+ echo
+ echo "n is $n"
+ return 1
+ fi
+
+ rm -f log
+ return 0
+}