Return empty string if we have no proxy
This commit is contained in:
@@ -100,6 +100,10 @@ protected:
|
|||||||
static thread_local char buf[64];
|
static thread_local char buf[64];
|
||||||
int ipLength = 0;
|
int ipLength = 0;
|
||||||
|
|
||||||
|
if (!binary.length()) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
unsigned char *b = (unsigned char *) binary.data();
|
unsigned char *b = (unsigned char *) binary.data();
|
||||||
|
|
||||||
if (binary.length() == 4) {
|
if (binary.length() == 4) {
|
||||||
|
|||||||
+9
-1
@@ -50,12 +50,20 @@ T _cond_byte_swap(T value) {
|
|||||||
|
|
||||||
struct ProxyParser {
|
struct ProxyParser {
|
||||||
private:
|
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;
|
uint8_t family = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/* Returns 4 or 16 bytes source address */
|
/* Returns 4 or 16 bytes source address */
|
||||||
std::string_view getSourceAddress() {
|
std::string_view getSourceAddress() {
|
||||||
|
|
||||||
|
// UNSPEC family and protocol
|
||||||
|
if (family == 0) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
if ((family & 0xf0) >> 4 == 1) {
|
if ((family & 0xf0) >> 4 == 1) {
|
||||||
/* Family 1 is INET4 */
|
/* Family 1 is INET4 */
|
||||||
return {(char *) &addr.ipv4_addr.src_addr, 4};
|
return {(char *) &addr.ipv4_addr.src_addr, 4};
|
||||||
|
|||||||
Reference in New Issue
Block a user