How to get client IP address?
Hello,
I want to create an auth module for mosquitto that uses amongst other the client IP address. Is mosquitto->address the client IP (in some form (as string))?
Thank you!
mosquitto_client_address func
static int basic_auth_callback(int event, void *event_data, void *userdata) { struct mosquitto_evt_basic_auth *ed = event_data; const char *ip_address;
UNUSED(event);
UNUSED(userdata);
ip_address = mosquitto_client_address(ed->client);
if(!strcmp(ip_address, "127.0.0.1")){
/* Only allow connections from localhost */
return MOSQ_ERR_SUCCESS;
}else{
return MOSQ_ERR_AUTH;
}
}
I guess this answered the question. Can we close?
Thank you for giving me the chance on a sunday to reply ;-)
Sorry, I was being a bit quick at trying to tidy up,
Was no offense. I just did not request close myself because was not able to test the suggestion so far. busy busy ...
Thank you for your work!