/*
* InspIRCd -- Internet Relay Chat Daemon
*
- * Copyright (C) 2018 Peter Powell <petpow@saberuk.com>
+ * Copyright (C) 2019 linuxdaemon <linuxdaemon.irc@gmail.com>
+ * Copyright (C) 2019 Matt Schatz <genius3000@g3k.solutions>
+ * Copyright (C) 2018-2019 Sadie Powell <sadie@witchery.services>
*
* This file is part of InspIRCd. InspIRCd is free software: you can
* redistribute it and/or modify it under the terms of the GNU General Public
return true;
}
- int ReadProxyAddress(StreamSocket* sock)
+ int ReadData(std::string& destrecvq)
+ {
+ // Once connected we handle no special data.
+ std::string& recvq = GetRecvQ();
+ destrecvq.append(recvq);
+ recvq.clear();
+ return 1;
+ }
+
+ int ReadProxyAddress(StreamSocket* sock, std::string& destrecvq)
{
// Block until we have the entire address.
std::string& recvq = GetRecvQ();
// Erase the processed proxy information from the receive queue.
recvq.erase(0, address_length);
+ break;
}
// We're done!
state = HPS_CONNECTED;
- return 1;
+ return ReadData(destrecvq);
}
- int ReadProxyHeader(StreamSocket* sock)
+ int ReadProxyHeader(StreamSocket* sock, std::string& destrecvq)
{
// Block until we have a header.
std::string& recvq = GetRecvQ();
}
state = HPS_WAITING_FOR_ADDRESS;
- return ReadProxyAddress(sock);
+ return ReadProxyAddress(sock, destrecvq);
}
public:
HAProxyHook(IOHookProvider* Prov, StreamSocket* sock, UserCertificateAPI& api)
: IOHookMiddle(Prov)
+ , address_length(0)
, sslapi(api)
, state(HPS_WAITING_FOR_HEADER)
{
switch (state)
{
case HPS_WAITING_FOR_HEADER:
- return ReadProxyHeader(sock);
+ return ReadProxyHeader(sock, destrecvq);
case HPS_WAITING_FOR_ADDRESS:
- return ReadProxyAddress(sock);
+ return ReadProxyAddress(sock, destrecvq);
case HPS_CONNECTED:
- std::string& recvq = GetRecvQ();
- destrecvq.append(recvq);
- recvq.clear();
- return 1;
+ return ReadData(destrecvq);
}
// We should never reach this point.