Return empty string if we have no proxy

This commit is contained in:
Alex Hultman
2020-06-06 21:07:20 +02:00
parent 0d9cb39db6
commit 5d5f9edc63
2 changed files with 13 additions and 1 deletions
+4
View File
@@ -100,6 +100,10 @@ protected:
static thread_local char buf[64];
int ipLength = 0;
if (!binary.length()) {
return {};
}
unsigned char *b = (unsigned char *) binary.data();
if (binary.length() == 4) {
+9 -1
View File
@@ -50,12 +50,20 @@ T _cond_byte_swap(T value) {
struct ProxyParser {
private:
union proxy_addr addr = {};
union proxy_addr addr;
// we should have "unset" where the return value is "" from proxied ip!
uint8_t family = 0;
public:
/* Returns 4 or 16 bytes source address */
std::string_view getSourceAddress() {
// UNSPEC family and protocol
if (family == 0) {
return {};
}
if ((family & 0xf0) >> 4 == 1) {
/* Family 1 is INET4 */
return {(char *) &addr.ipv4_addr.src_addr, 4};