Introduction
Introduction Statistics Contact Development Disclaimer Help
Fix haproxy support. - geomyidae - a small C-based gopherd (mirror)
git clone git://git.codemadness.org/geomyidae
Log
Files
Refs
README
LICENSE
---
commit 8de0a5087833495b700c7ce4472df52c397c4cd5
parent ef96bd3ac67bd8a63756736a172fe34590d45ea5
Author: Christoph Lohmann <[email protected]>
Date: Mon, 14 Nov 2022 01:06:49 +0100
Fix haproxy support.
Diffstat:
M main.c | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/main.c b/main.c
@@ -916,6 +916,7 @@ main(int argc, char *argv[])
}
#endif /* __OpenBSD__ */
+read_selector_again:
if (recv(sock, &byte0, 1, MSG_PEEK) < 1)
return 1;
@@ -949,7 +950,6 @@ main(int argc, char *argv[])
return 1;
}
-read_selector_again:
maxrecv = sizeof(recvb) - 1;
do {
#ifdef ENABLE_TLS
@@ -980,6 +980,17 @@ read_selector_again:
*/
if (dohaproxy && !strncmp(recvb, "PROXY TCP", 9)) {
/*
+ * In case more than proxy tcp was read,
+ * be pepared.
+ */
+ p = strchr(recvb, '\n');
+ if (p == NULL)
+ return 1;
+ if (p[-1] == '\r')
+ p[-1] = '\0';
+ *p++ = '\0';
+
+ /*
* Be careful, we are using scanf.
* TODO: Use some better parsing.
*/
@@ -1019,7 +1030,13 @@ read_selector_again:
logentry(clienth, clientp, "-",
"haproxy connected");
}
- goto read_selector_again;
+ printf("clienth = %s, clientp = %s, serverh = …
+ clienth, clientp, serverh, ser…
+
+ /* Realign recvb to new value. */
+ memmove(recvb, p, sizeof(recvb)-(p-recvb));
+ if (strlen(recvb) < 1)
+ goto read_selector_again;
}
#ifdef ENABLE_TLS
@@ -1065,8 +1082,9 @@ read_selector_again:
#endif /* ENABLE_TLS */
handlerequest(sock, recvb, rlen, base,
- ohost, sport, clienth,
- clientp, serverh, serverp,
+ (dohaproxy)? serverh : ohost,
+ (dohaproxy)? serverp : sport,
+ clienth, clientp, serverh, serverp,
nocgi, istls);
if (!istls) {
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.