Merge branch 'x-forwarded-for-lws' of https://github.com/hardillb/mosquitto into hardillb-x-forwarded-for-lws
This commit is contained in:
commit
4a6570567a
@ -133,6 +133,7 @@ static int callback_mqtt(
|
|||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
int rc;
|
int rc;
|
||||||
uint8_t byte;
|
uint8_t byte;
|
||||||
|
char ip_addr_buff[1024];
|
||||||
|
|
||||||
switch (reason) {
|
switch (reason) {
|
||||||
case LWS_CALLBACK_ESTABLISHED:
|
case LWS_CALLBACK_ESTABLISHED:
|
||||||
@ -157,7 +158,12 @@ static int callback_mqtt(
|
|||||||
}else{
|
}else{
|
||||||
return -1;
|
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);
|
easy_address(lws_get_socket_fd(wsi), mosq);
|
||||||
|
}
|
||||||
if(!mosq->address){
|
if(!mosq->address){
|
||||||
/* getpeername and inet_ntop failed and not a bridge */
|
/* getpeername and inet_ntop failed and not a bridge */
|
||||||
mosquitto__free(mosq);
|
mosquitto__free(mosq);
|
||||||
|
Loading…
Reference in New Issue
Block a user