[master] 519737ac4 split out proxyv2 formatting
Nils Goroll
nils.goroll at uplex.de
Wed Jan 15 16:12:07 UTC 2020
commit 519737ac4c4e5b4f878b7d4a30f95ddd5008029a
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Fri Nov 23 15:31:37 2018 +0100
split out proxyv2 formatting
diff --git a/bin/varnishd/proxy/cache_proxy_proto.c b/bin/varnishd/proxy/cache_proxy_proto.c
index 69722805f..0f86d944e 100644
--- a/bin/varnishd/proxy/cache_proxy_proto.c
+++ b/bin/varnishd/proxy/cache_proxy_proto.c
@@ -632,6 +632,34 @@ vpx_format_proxy_v1(struct vsb *vsb, int proto,
AZ(VSB_finish(vsb));
}
+static void
+vpx_format_proxy_v2(struct vsb *vsb, int proto,
+ const struct suckaddr *sac, const struct suckaddr *sas)
+{
+ AN(vsb);
+ AN(sac);
+ AN(sas);
+
+ VSB_bcat(vsb, vpx2_sig, sizeof(vpx2_sig));
+ VSB_putc(vsb, 0x21);
+ if (proto == PF_INET6) {
+ VSB_putc(vsb, 0x21);
+ VSB_putc(vsb, 0x00);
+ VSB_putc(vsb, 0x24);
+ } else if (proto == PF_INET) {
+ VSB_putc(vsb, 0x11);
+ VSB_putc(vsb, 0x00);
+ VSB_putc(vsb, 0x0c);
+ } else {
+ WRONG("Wrong proxy v2 proto");
+ }
+ vpx_enc_addr(vsb, proto, sac);
+ vpx_enc_addr(vsb, proto, sas);
+ vpx_enc_port(vsb, sac);
+ vpx_enc_port(vsb, sas);
+ AZ(VSB_finish(vsb));
+}
+
void
VPX_Send_Proxy(int fd, int version, const struct sess *sp)
{
@@ -649,7 +677,6 @@ VPX_Send_Proxy(int fd, int version, const struct sess *sp)
AZ(SES_Get_server_addr(sp, &sas));
AN(sas);
proto = VSA_Get_Proto(sas);
- assert(proto == PF_INET6 || proto == PF_INET);
if (version == 1) {
VTCP_name(sas, ha, sizeof ha, pa, sizeof pa);
@@ -660,23 +687,7 @@ VPX_Send_Proxy(int fd, int version, const struct sess *sp)
} else if (version == 2) {
AZ(SES_Get_client_addr(sp, &sac));
AN(sac);
-
- VSB_bcat(vsb, vpx2_sig, sizeof(vpx2_sig));
- VSB_putc(vsb, 0x21);
- if (proto == PF_INET6) {
- VSB_putc(vsb, 0x21);
- VSB_putc(vsb, 0x00);
- VSB_putc(vsb, 0x24);
- } else if (proto == PF_INET) {
- VSB_putc(vsb, 0x11);
- VSB_putc(vsb, 0x00);
- VSB_putc(vsb, 0x0c);
- }
- vpx_enc_addr(vsb, proto, sac);
- vpx_enc_addr(vsb, proto, sas);
- vpx_enc_port(vsb, sac);
- vpx_enc_port(vsb, sas);
- AZ(VSB_finish(vsb));
+ vpx_format_proxy_v2(vsb, proto, sac, sas);
} else
WRONG("Wrong proxy version");
More information about the varnish-commit
mailing list