Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request - include client addresses in more log lines #919

Open
rbeiter opened this issue Aug 15, 2018 · 2 comments
Open

Feature request - include client addresses in more log lines #919

rbeiter opened this issue Aug 15, 2018 · 2 comments
Labels
Component: mosquitto-broker Type: Enhancement A new feature for a minor or major release.
Milestone

Comments

@rbeiter
Copy link

rbeiter commented Aug 15, 2018

It would be useful for the server, especially for client session initiation errors, to have the IP address of the mosquitto client session logged with the failure message. I typically set up fail2ban to block repeated invalid connection attempts for other services and having this for mosquitto would be desirable. I've found that in most instances where events are logged, a mosquitto object is available and address is populated with the remote client's IP address. This could also be handy in determining what IP address a client session belongs to when reading the logs, etc.

An example I've done locally which uses the mosquitto reference passed into the log__printf method to prepend the address, if mosq and the address are non-null:

Aug 15 15:16:13 mqttserver mosquitto[5677]: New connection from 192.168.1.100 on port 8883.
Aug 15 15:16:15 mqttserver mosquitto[5677]: 192.168.1.100 OpenSSL Error: error:140780E5:SSL routines:ssl23_read:ssl handshake failure
Aug 15 15:16:15 mqttserver mosquitto[5677]: 192.168.1.100 Socket error on client <unknown>, disconnecting.

If this is something the maintainers think would be helpful, I'm happy to put together a PR that introduces this in the logger globally and passes along the mosquitto reference in the spots it's available but not passed yet today. I noticed that the reference to the mosquitto context is passed to this method but not utilized on the server's instance of the logging function - I believe this is for signature parity with the lib and is planned to be kept in the interface? So far locally, I'm simply prepending the affected log messages with the client IP address to avoid having to touch every log line in the application. It's worth noting that unless made into an option, this would be a breaking change for users already parsing these log messages.

@toast-uz toast-uz added the Type: Enhancement A new feature for a minor or major release. label Aug 15, 2018
@ralight ralight added this to the 1.6 milestone Aug 16, 2018
@ralight
Copy link
Contributor

ralight commented Aug 16, 2018

This sounds like a pretty sensible request, I've put it on the list for 1.6.

@rbeiter
Copy link
Author

rbeiter commented Aug 16, 2018

👍 Thank you, @ralight!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: mosquitto-broker Type: Enhancement A new feature for a minor or major release.
Projects
None yet
Development

No branches or pull requests

3 participants