Add support for X-Forwarded-For LWS
I know you've added this for the next release, but here is a fix for LWS. But just incase there are any more 2.0.x releases. It does leave the incoming port as 0 but as this is pretty meaningless for a proxied connection I think it's probably ok. Signed-off-by: Ben Hardill <hardillb@gmail.com>
This commit is contained in:
parent
1ed0c0436a
commit
0eec37af99
@ -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;
|
||||
}
|
||||
easy_address(lws_get_socket_fd(wsi), mosq);
|
||||
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user