vtest "probes to UDS backends with .proxy_header in [12]"

# Since we can only reliably forward IP addresses via PROXY with
# Vinyl, we can't use the trick from o00002.vtc (use a Vinyl
# instance listening for PROXY as a backend) to verify PROXYv1 (but
# the PROXY header can be viewed in the test log).

# We just verify that the probe is good (and that Vinyl doesn't
# crash with WRONG).

server s1 -listen "${tmpdir}/s1.sock" {
	rxreq
	txresp
} -start

# For PROXYv1 with a UDS backend, we send PROXY UNKNOWN in the probe.
vinyl v1 -vcl {
	backend s1 {
		.path = "${s1_sock}";
		.proxy_header = 1;

		.probe = {
			.window = 1;
			.threshold = 1;
			.interval = 0.5s;
		}
	}
} -start

delay 1

vinyl v1 -cliexpect "vcl1.s1[ ]+probe[ ]+1/1[ ]+healthy" backend.list

# For PROXYv2, we apply a trick similar to o0000[24].vtc, since
# Vinyl accepts (and ignores) PROXY LOCAL.

server s2 {
	rxreq
	expect req.http.Host == "v2"
	expect req.http.X-Forwarded-For == "0.0.0.0"
	txresp
} -start

vinyl v2 -arg "-a ${tmpdir}/v2.sock,PROXY,mode=0777" -vcl {
	backend s2 { .host = "${s2_addr}"; .port = "${s2_port}"; }
} -start

vinyl v3 -vcl {
	backend bp {
		.path = "${v2_sock}";
		.host_header = "v2";
		.proxy_header = 2;

		.probe = {
			.window = 1;
			.threshold = 1;
			.interval = 0.5s;
		}
	}
} -start

server s1 -wait

delay 1

vinyl v3 -cliexpect "vcl1.bp[ ]+probe[ ]+1/1[ ]+healthy" backend.list

# Verify in the v2 log that PROXY LOCAL was sent.

logexpect l1 -v v2 -d 1 -g session -q "Proxy" {
	expect 0 * Begin sess
	expect * = Proxy {^\d+ local local local local$}
	expect * = End
} -run
