vtest "client.identity is 0.0.0.0 if unset & client addr is UDS"
# vinyltest "vtc remote.ip, remote.port and remote.path" (a00020)

server s1 {
	rxreq
	expect remote.ip == "${localhost}"
	expect remote.port > 0
	expect remote.path == <undef>
	txresp
} -start

vinyl v1 -vcl+backend {} -start

client c1 {
	txreq
	rxresp
	expect remote.ip == "${v1_addr}"
	expect remote.port == "${v1_port}"
	expect remote.path == <undef>
} -run

vinyl v1 -stop

server s1 -wait
server s1 -start

vinyl v2 -arg "-a ${tmpdir}/v2.sock" -vcl+backend {} -start

client c1 -connect "${tmpdir}/v2.sock" {
	txreq
	rxresp
	expect remote.ip == "0.0.0.0"
	expect remote.port == 0
	expect remote.path == "${tmpdir}/v2.sock"
} -run

vinyl v3 -arg "-a ${tmpdir}/v3.sock" -vcl {
	backend b None;

	sub vcl_recv {
		if (req.url == "/nobody") {
			set client.identity = "Samuel B. Nobody";
		}
		set req.http.id = client.identity;
		return(synth(200));
	}

	sub vcl_synth {
		set resp.http.id = req.http.id;
	}
} -start

client c2 -connect "${tmpdir}/v3.sock" {
	txreq -url "/nobody"
	rxresp
	expect resp.status == 200
	expect resp.http.id == "Samuel B. Nobody"
	txreq
	rxresp
	expect resp.status == 200
	expect resp.http.id == "0.0.0.0"
} -run
