Merge branch 'x-forwarded-for-lws' of https://github.com/hardillb/mosquitto into hardillb-x-forwarded-for-lws

This commit is contained in:
Roger A. Light 2022-08-16 14:30:37 +01:00
commit 4a6570567a

View File

@ -133,6 +133,7 @@ static int callback_mqtt(
uint8_t *buf;
int rc;
uint8_t byte;
char ip_addr_buff[1024];
switch (reason) {
case LWS_CALLBACK_ESTABLISHED:
@ -157,7 +158,12 @@ static int callback_mqtt(
}else{
return -1;
}
if (lws_hdr_copy(wsi, ip_addr_buff, sizeof(ip_addr_buff), WSI_TOKEN_X_FORWARDED_FOR) > 0) {
mosq->address = mosquitto__strdup(ip_addr_buff);
} else {
easy_address(lws_get_socket_fd(wsi), mosq);
}
if(!mosq->address){
/* getpeername and inet_ntop failed and not a bridge */
mosquitto__free(mosq);