mosquitto_plugin icon indicating copy to clipboard operation
mosquitto_plugin copied to clipboard

Create a Client struct to provide client information and functionality to higher level handlers

Open Tejpbit opened this issue 3 years ago • 4 comments

There are multiple entry points made available for a plugin through the C bindings.

These three functions receive the client reference from the broker.

  • https://mosquitto.org/api/files/mosquitto_plugin-h.html#mosquitto_auth_acl_check
  • https://mosquitto.org/api/files/mosquitto_plugin-h.html#mosquitto_auth_unpwd_check
  • https://mosquitto.org/api/files/mosquitto_plugin-h.html#mosquitto_auth_start

These are the things that should be put in a Client struct.

  • client_id
  • certificate
  • IP
  • clean session flag
  • keep alive value
  • protocol
  • protocol version
  • subscription count
  • username

The client struct should also have an implementation to provide the following functionality:

  • Be able to set the username
  • Kick client by username or client id
  • Publish to client

If we create a client struct we can replace the client_id in the acl_check and the username_password functions with the whole client. We should just take care to not add too much parsing overhead. E.g. do not parse the certificate just put it in a Vec field. If possible we should also avoid copying overhead but that might not be as easy and can be improved upon later.

Tejpbit avatar May 10 '21 14:05 Tejpbit