Move example plugins to their own directory.

pull/2157/head
Roger A. Light 5 years ago
parent dcb9ac93c7
commit c17c6a9028

@ -1,5 +1,2 @@
add_subdirectory(dynamic-security)
if(NOT WIN32)
add_subdirectory(message-timestamp)
endif(NOT WIN32)
add_subdirectory(payload-modification)
add_subdirectory(examples)

@ -1,9 +1,6 @@
DIRS= \
auth-by-ip \
connection-state \
dynamic-security \
message-timestamp \
payload-modification
examples
.PHONY : all binary check clean reallyclean test install uninstall

@ -7,23 +7,43 @@ This is a fully functioning plugin that implements authentication and access
control, with configuration via a $CONTROL topic. See the readme in
dynamic-security for more information.
## Connection state
## Examples / Add properties
This is an **example** plugin that demonstrates adding MQTT v5 properties to
messages, and how to get client information.
## Examples / Authenticate by IP address
This is an **example** plugin that demonstrates a basic authentication callback
that allows clients based on their IP address. Password based authentication is
preferred over this very simple type of access control.
## Examples / Client properties
This is an **example** plugin that demonstrates some of the functions for
retrieving client information such as client id and username.
## Examples / Connection state
This is an **example** plugin to demonstrate the use of the connect and
disconnect events. It publishes messages to
$SYS/broker/connection/client/<client id>/state for every client that connects
to the broker, to indicate the connection state of that client.
## Message timestamp
This is an **example** plugin to demonstrate how it is possible to attach MQTT v5 properties to messages after they have been received, and before they are sent on to subscribers.
This plugin attaches a user-property property to each message which contains the ISO-8601 timestamp of the time the message was received by the broker. This means it is possible for MQTT v5 clients to see how old a retained message is, for example.
## Examples / Message timestamp
This is an **example** plugin to demonstrate how it is possible to attach MQTT
v5 properties to messages after they have been received, and before they are
sent on to subscribers.
## Payload modification
This is an **example** plugin to demonstrate how it is possible to modify the payload of messages after they have been received, and before they are sent on to subscribers.
This plugin attaches a user-property property to each message which contains
the ISO-8601 timestamp of the time the message was received by the broker. This
means it is possible for MQTT v5 clients to see how old a retained message is,
for example.
If you are considering using this feature, you should be very certain you have verified the payload is the correct format before modifying it.
## Examples / Payload modification
This is an **example** plugin to demonstrate how it is possible to modify the
payload of messages after they have been received, and before they are sent on
to subscribers.
This plugin adds the text string "hello " to the beginning of each payload, so with anything other than simple plain text messages it will corrupt the payload contents.
If you are considering using this feature, you should be very certain you have
verified the payload is the correct format before modifying it.
## Authenticate by IP address
This is an **example** plugin that demonstrates a basic authentication callback that allows clients based on their IP address. Password based authentication is preferred over this very simple type of access control.
This plugin adds the text string "hello " to the beginning of each payload, so
with anything other than simple plain text messages it will corrupt the payload
contents.

@ -0,0 +1,8 @@
if(NOT WIN32)
add_subdirectory(add-properties)
add_subdirectory(message-timestamp)
endif(NOT WIN32)
add_subdirectory(auth-by-ip)
add_subdirectory(client-properties)
add_subdirectory(connection-state)
add_subdirectory(payload-modification)

@ -0,0 +1,31 @@
DIRS= \
add-properties \
auth-by-ip \
client-properties \
connection-state \
message-timestamp \
payload-modification
.PHONY : all binary check clean reallyclean test install uninstall
all :
set -e; for d in ${DIRS}; do $(MAKE) -C $${d}; done
binary :
set -e; for d in ${DIRS}; do $(MAKE) -C $${d} $@; done
clean :
set -e; for d in ${DIRS}; do $(MAKE) -C $${d} $@; done
reallyclean :
set -e; for d in ${DIRS}; do $(MAKE) -C $${d} $@; done
check : test
test :
set -e; for d in ${DIRS}; do $(MAKE) -C $${d} $@; done
install :
set -e; for d in ${DIRS}; do $(MAKE) -C $${d} $@; done
uninstall :
set -e; for d in ${DIRS}; do $(MAKE) -C $${d} $@; done

@ -0,0 +1,11 @@
include_directories(${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/include
${STDBOOL_H_PATH} ${STDINT_H_PATH})
add_library(mosquitto_add_properties SHARED mosquitto_add_properties.c)
set_target_properties(mosquitto_add_properties PROPERTIES
POSITION_INDEPENDENT_CODE 1
)
set_target_properties(mosquitto_add_properties PROPERTIES PREFIX "")
# Don't install, these are example plugins only.
#install(TARGETS mosquitto_add_properties RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")

@ -1,8 +1,9 @@
include ../../config.mk
include ../../../config.mk
.PHONY : all binary check clean reallyclean test install uninstall
PLUGIN_NAME=add_properties
PLUGIN_NAME=mosquitto_add_properties
PLUGIN_CFLAGS+=-I../../../include -I../../../
all : binary

@ -1,8 +1,9 @@
include ../../config.mk
include ../../../config.mk
.PHONY : all binary check clean reallyclean test install uninstall
PLUGIN_NAME=mosquitto_auth_by_ip
PLUGIN_CFLAGS+=-I../../../include -I../../../
all : binary

@ -0,0 +1,15 @@
include_directories(${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/include
${STDBOOL_H_PATH} ${STDINT_H_PATH})
link_directories(${mosquitto_SOURCE_DIR})
add_library(mosquitto_client_properties SHARED mosquitto_client_properties.c)
set_target_properties(mosquitto_client_properties PROPERTIES
POSITION_INDEPENDENT_CODE 1
)
set_target_properties(mosquitto_client_properties PROPERTIES PREFIX "")
if(WIN32)
target_link_libraries(mosquitto_client_properties mosquitto)
endif(WIN32)
# Don't install, these are example plugins only.
#install(TARGETS mosquitto_client_properties RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")

@ -0,0 +1,28 @@
include ../../../config.mk
.PHONY : all binary check clean reallyclean test install uninstall
PLUGIN_NAME=mosquitto_client_properties
PLUGIN_CFLAGS+=-I../../../include -I../../../
all : binary
binary : ${PLUGIN_NAME}.so
${PLUGIN_NAME}.so : ${PLUGIN_NAME}.c
$(CROSS_COMPILE)$(CC) $(PLUGIN_CPPFLAGS) $(PLUGIN_CFLAGS) $(PLUGIN_LDFLAGS) -fPIC -shared $< -o $@
reallyclean : clean
clean:
-rm -f *.o ${PLUGIN_NAME}.so *.gcda *.gcno
check: test
test:
install: ${PLUGIN_NAME}.so
# Don't install, these are examples only.
#$(INSTALL) -d "${DESTDIR}$(libdir)"
#$(INSTALL) ${STRIP_OPTS} ${PLUGIN_NAME}.so "${DESTDIR}${libdir}/${PLUGIN_NAME}.so"
uninstall :
-rm -f "${DESTDIR}${libdir}/${PLUGIN_NAME}.so"

@ -1,8 +1,9 @@
include ../../config.mk
include ../../../config.mk
.PHONY : all binary check clean reallyclean test install uninstall
PLUGIN_NAME=mosquitto_connection_state
PLUGIN_CFLAGS+=-I../../../include -I../../../
all : binary

@ -1,8 +1,9 @@
include ../../config.mk
include ../../../config.mk
.PHONY : all binary check clean reallyclean test install uninstall
PLUGIN_NAME=mosquitto_message_timestamp
PLUGIN_CFLAGS+=-I../../../include -I../../../
all : binary

@ -1,8 +1,9 @@
include ../../config.mk
include ../../../config.mk
.PHONY : all binary check clean reallyclean test install uninstall
PLUGIN_NAME=mosquitto_payload_modification
PLUGIN_CFLAGS+=-I../../../include -I../../../
all : binary

@ -1,11 +0,0 @@
include_directories(${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/include
${STDBOOL_H_PATH} ${STDINT_H_PATH})
add_library(mosquitto_message_timestamp SHARED mosquitto_message_timestamp.c)
set_target_properties(mosquitto_message_timestamp PROPERTIES
POSITION_INDEPENDENT_CODE 1
)
set_target_properties(mosquitto_message_timestamp PROPERTIES PREFIX "")
# Don't install, these are example plugins only.
#install(TARGETS mosquitto_message_timestamp RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")

@ -1,15 +0,0 @@
include_directories(${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/include
${STDBOOL_H_PATH} ${STDINT_H_PATH})
link_directories(${mosquitto_SOURCE_DIR})
add_library(mosquitto_payload_modification SHARED mosquitto_payload_modification.c)
set_target_properties(mosquitto_payload_modification PROPERTIES
POSITION_INDEPENDENT_CODE 1
)
set_target_properties(mosquitto_payload_modification PROPERTIES PREFIX "")
if(WIN32)
target_link_libraries(mosquitto_payload_modification mosquitto)
endif(WIN32)
# Don't install, these are example plugins only.
#install(TARGETS mosquitto_payload_modification RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")

@ -1,27 +0,0 @@
include ../../config.mk
.PHONY : all binary check clean reallyclean test install uninstall
PLUGIN_NAME=printf_example
all : binary
binary : ${PLUGIN_NAME}.so
${PLUGIN_NAME}.so : ${PLUGIN_NAME}.c
$(CROSS_COMPILE)$(CC) $(PLUGIN_CPPFLAGS) $(PLUGIN_CFLAGS) $(PLUGIN_LDFLAGS) -fPIC -shared $< -o $@
reallyclean : clean
clean:
-rm -f *.o ${PLUGIN_NAME}.so *.gcda *.gcno
check: test
test:
install: ${PLUGIN_NAME}.so
# Don't install, these are examples only.
#$(INSTALL) -d "${DESTDIR}$(libdir)"
#$(INSTALL) ${STRIP_OPTS} ${PLUGIN_NAME}.so "${DESTDIR}${libdir}/${PLUGIN_NAME}.so"
uninstall :
-rm -f "${DESTDIR}${libdir}/${PLUGIN_NAME}.so"
Loading…
Cancel
Save