From 8e4256c06fb42770efa3dd27a9e4b13aacaed58e Mon Sep 17 00:00:00 2001 From: JianBo He Date: Wed, 29 Sep 2021 14:11:20 +0800 Subject: [PATCH] chore(conf): refine config format --- apps/emqx_gateway/etc/emqx_gateway.conf | 348 +----------------- .../etc/emqx_gateway.conf.example | 346 +++++++++++++++++ 2 files changed, 349 insertions(+), 345 deletions(-) create mode 100644 apps/emqx_gateway/etc/emqx_gateway.conf.example diff --git a/apps/emqx_gateway/etc/emqx_gateway.conf b/apps/emqx_gateway/etc/emqx_gateway.conf index 4695d41ba..f6b0aaa37 100644 --- a/apps/emqx_gateway/etc/emqx_gateway.conf +++ b/apps/emqx_gateway/etc/emqx_gateway.conf @@ -2,348 +2,6 @@ ## EMQ X Gateway configurations ##-------------------------------------------------------------------- -## TODO: These configuration options are temporary example here. -## In the final version, it will be commented out. - -#gateway.stomp { -# -# ## How long time the connection will be disconnected if the -# ## connection is established but no bytes received -# idle_timeout = 30s -# -# ## To control whether write statistics data into ETS table -# ## for dashbord to read. -# enable_stats = true -# -# ## When publishing or subscribing, prefix all topics with a mountpoint string. -# mountpoint = "" -# -# frame { -# max_headers = 10 -# max_headers_length = 1024 -# max_body_length = 8192 -# } -# -# clientinfo_override { -# username = "${Packet.headers.login}" -# password = "${Packet.headers.passcode}" -# } -# -# authentication: { -# mechanism = password-based -# backend = built-in-database -# user_id_type = clientid -# } -# -# listeners.tcp.default { -# bind = 61613 -# acceptors = 16 -# max_connections = 1024000 -# max_conn_rate = 1000 -# -# access_rules = [ -# "allow all" -# ] -# -# authentication: { -# mechanism = password-based -# backend = built-in-database -# user_id_type = username -# } -# -# ## TCP options -# ## See ${example_common_tcp_options} for more information -# tcp.active_n = 100 -# tcp.backlog = 1024 -# tcp.buffer = 4KB -# } -# -# listeners.ssl.default { -# bind = 61614 -# acceptors = 16 -# max_connections = 1024000 -# max_conn_rate = 1000 -# -# ## TCP options -# ## See ${example_common_tcp_options} for more information -# tcp.active_n = 100 -# tcp.backlog = 1024 -# tcp.buffer = 4KB -# -# ## SSL options -# ## See ${example_common_ssl_options} for more information -# ssl.versions = ["tlsv1.3", "tlsv1.2", "tlsv1.1", "tlsv1"] -# ssl.keyfile = "{{ platform_etc_dir }}/certs/key.pem" -# ssl.certfile = "{{ platform_etc_dir }}/certs/cert.pem" -# ssl.cacertfile = "{{ platform_etc_dir }}/certs/cacert.pem" -# #ssl.verify = verify_none -# #ssl.fail_if_no_peer_cert = false -# #ssl.server_name_indication = disable -# #ssl.secure_renegotiate = false -# #ssl.reuse_sessions = false -# #ssl.honor_cipher_order = false -# #ssl.handshake_timeout = 15s -# #ssl.depth = 10 -# #ssl.password = foo -# #ssl.dhfile = path-to-your-file -# } -#} -# -#gateway.coap { -# -# ## How long time the connection will be disconnected if the -# ## connection is established but no bytes received -# idle_timeout = 30s -# -# ## To control whether write statistics data into ETS table -# ## for dashbord to read. -# enable_stats = true -# -# ## When publishing or subscribing, prefix all topics with a mountpoint string. -# mountpoint = "" -# -# ## Enable or disable connection mode -# ## If true, you need to establish a connection before send any publish/subscribe -# ## requests -# ## -# ## Default: false -# #connection_required = false -# -# ## The Notification Message Type. -# ## The notification message will be delivered to the CoAP client if a new -# ## message received on an observed topic. -# ## The type of delivered coap message can be set to: -# ## - non: Non-confirmable -# ## - con: Confirmable -# ## - qos: Mapping from QoS type of the recevied message. -# ## QoS0 -> non, QoS1,2 -> con. -# ## -# ## Enum: non | con | qos -# ## Default: qos -# #notify_type = qos -# -# ## The *Default QoS Level* indicator for subscribe request. -# ## This option specifies the QoS level for the CoAP Client when establishing -# ## a subscription membership, if the subscribe request is not carried `qos` -# ## option. -# ## The indicator can be set to: -# ## - qos0, qos1, qos2: Fixed default QoS level -# ## - coap: Dynamic QoS level by the message type of subscribe request -# ## * qos0: If the subscribe request is non-confirmable -# ## * qos1: If the subscribe request is confirmable -# ## -# ## Enum: qos0 | qos1 | qos2 | coap -# ## Default: coap -# #subscribe_qos = coap -# -# ## The *Default QoS Level* indicator for publish request. -# ## This option specifies the QoS level for the CoAP Client when publishing a -# ## message to EMQ X PUB/SUB system, if the publish request is not carried `qos` -# ## option. -# ## The indicator can be set to: -# ## - qos0, qos1, qos2: Fixed default QoS level -# ## - coap: Dynamic QoS level by the message type of publish request -# ## * qos0: If the publish request is non-confirmable -# ## * qos1: If the publish request is confirmable -# ## -# ## Enum: qos0 | qos1 | qos2 | coap -# #publish_qos = coap -# -# listeners.udp.default { -# bind = 5683 -# max_connections = 102400 -# max_conn_rate = 1000 -# -# ## UDP Options -# ## See ${example_common_udp_options} for more information -# udp.active_n = 100 -# udp.buffer = 16KB -# } -# listeners.dtls.default { -# bind = 5684 -# acceptors = 4 -# max_connections = 102400 -# max_conn_rate = 1000 -# -# ## UDP Options -# ## See ${example_common_udp_options} for more information -# udp.active_n = 100 -# udp.buffer = 16KB -# -# ## DTLS Options -# ## See #{example_common_dtls_options} for more information -# dtls.versions = ["dtlsv1.2", "dtlsv1"] -# dtls.keyfile = "{{ platform_etc_dir }}/certs/key.pem" -# dtls.certfile = "{{ platform_etc_dir }}/certs/cert.pem" -# dtls.cacertfile = "{{ platform_etc_dir }}/certs/cacert.pem" -# dtls.handshake_timeout = 15s -# } -#} -# -#gateway.mqttsn { -# -# ## How long time the connection will be disconnected if the -# ## connection is established but no bytes received -# idle_timeout = 30s -# -# ## To control whether write statistics data into ETS table -# ## for dashbord to read. -# enable_stats = true -# -# ## When publishing or subscribing, prefix all topics with a mountpoint string. -# mountpoint = "" -# -# ## The MQTT-SN Gateway ID in ADVERTISE message. -# gateway_id = 1 -# -# ## Enable broadcast this gateway to WLAN -# broadcast = true -# -# ## To control whether accept and process the received -# ## publish message with qos=-1. -# enable_qos3 = true -# -# ## The pre-defined topic name corresponding to the pre-defined topic -# ## id of N. -# ## Note that the pre-defined topic id of 0 is reserved. -# predefined = [ -# { id = 1 -# topic = "/predefined/topic/name/hello" -# }, -# { id = 2 -# topic = "/predefined/topic/name/nice" -# } -# ] -# -# ### ClientInfo override -# clientinfo_override { -# username = "mqtt_sn_user" -# password = "abc" -# } -# -# listeners.udp.default { -# bind = 1884 -# max_connections = 10240000 -# max_conn_rate = 1000 -# } -# -# listeners.dtls.default { -# bind = 1885 -# acceptors = 4 -# max_connections = 102400 -# max_conn_rate = 1000 -# -# ## UDP Options -# ## See ${example_common_udp_options} for more information -# udp.active_n = 100 -# udp.buffer = 16KB -# -# ## DTLS Options -# ## See #{example_common_dtls_options} for more information -# dtls.versions = ["dtlsv1.2", "dtlsv1"] -# dtls.keyfile = "{{ platform_etc_dir }}/certs/key.pem" -# dtls.certfile = "{{ platform_etc_dir }}/certs/cert.pem" -# dtls.cacertfile = "{{ platform_etc_dir }}/certs/cacert.pem" -# } -# -#} -# -#gateway.lwm2m { -# -# ## How long time the connection will be disconnected if the -# ## connection is established but no bytes received -# idle_timeout = 30s -# -# ## To control whether write statistics data into ETS table -# ## for dashbord to read. -# enable_stats = true -# -# ## When publishing or subscribing, prefix all topics with a mountpoint string. -# mountpoint = "lwm2m/%u" -# -# xml_dir = "{{ platform_etc_dir }}/lwm2m_xml" -# -# ## -# ## -# lifetime_min = 1s -# -# lifetime_max = 86400s -# -# qmode_time_window = 22 -# -# auto_observe = false -# -# ## always | contains_object_list -# update_msg_publish_condition = contains_object_list -# -# -# translators { -# command { -# topic = "/dn/#" -# qos = 0 -# } -# -# response { -# topic = "/up/resp" -# qos = 0 -# } -# -# notify { -# topic = "/up/notify" -# qos = 0 -# } -# -# register { -# topic = "/up/resp" -# qos = 0 -# } -# -# update { -# topic = "/up/resp" -# qos = 0 -# } -# } -# -# listeners.udp.default { -# bind = 5783 -# } -#} -# -#gateway.exproto { -# -# ## How long time the connection will be disconnected if the -# ## connection is established but no bytes received -# idle_timeout = 30s -# -# ## To control whether write statistics data into ETS table -# ## for dashbord to read. -# enable_stats = true -# -# ## When publishing or subscribing, prefix all topics with a mountpoint string. -# mountpoint = "" -# -# ## The gRPC server to accept requests -# server { -# bind = 9100 -# #ssl.keyfile: -# #ssl.certfile: -# #ssl.cacertfile: -# } -# -# handler { -# address = "http://127.0.0.1:9001" -# #ssl.keyfile: -# #ssl.certfile: -# #ssl.cacertfile: -# } -# -# listeners.tcp.default { -# bind = 7993 -# acceptors = 8 -# max_connections = 10240 -# max_conn_rate = 1000 -# } -# #listeners.ssl.default: {} -# #listeners.udp.default: {} -# #listeners.dtls.default: {} -#} +## No gateway by default. +## +## If you want to get how to config it, please see emqx_gateway.conf.example. diff --git a/apps/emqx_gateway/etc/emqx_gateway.conf.example b/apps/emqx_gateway/etc/emqx_gateway.conf.example new file mode 100644 index 000000000..184d998dc --- /dev/null +++ b/apps/emqx_gateway/etc/emqx_gateway.conf.example @@ -0,0 +1,346 @@ +##-------------------------------------------------------------------- +## EMQ X Gateway configurations +##-------------------------------------------------------------------- + +gateway.stomp { + + ## How long time the connection will be disconnected if the + ## connection is established but no bytes received + idle_timeout = 30s + + ## To control whether write statistics data into ETS table + ## for dashbord to read. + enable_stats = true + + ## When publishing or subscribing, prefix all topics with a mountpoint string. + mountpoint = "" + + frame { + max_headers = 10 + max_headers_length = 1024 + max_body_length = 8192 + } + + clientinfo_override { + username = "${Packet.headers.login}" + password = "${Packet.headers.passcode}" + } + + authentication: { + mechanism = password-based + backend = built-in-database + user_id_type = clientid + } + + listeners.tcp.default { + bind = 61613 + acceptors = 16 + max_connections = 1024000 + max_conn_rate = 1000 + + access_rules = [ + "allow all" + ] + + authentication: { + mechanism = password-based + backend = built-in-database + user_id_type = username + } + + ## TCP options + ## See ${example_common_tcp_options} for more information + tcp.active_n = 100 + tcp.backlog = 1024 + tcp.buffer = 4KB + } + + listeners.ssl.default { + bind = 61614 + acceptors = 16 + max_connections = 1024000 + max_conn_rate = 1000 + + ## TCP options + ## See ${example_common_tcp_options} for more information + tcp.active_n = 100 + tcp.backlog = 1024 + tcp.buffer = 4KB + + ## SSL options + ## See ${example_common_ssl_options} for more information + ssl.versions = ["tlsv1.3", "tlsv1.2", "tlsv1.1", "tlsv1"] + ssl.keyfile = "{{ platform_etc_dir }}/certs/key.pem" + ssl.certfile = "{{ platform_etc_dir }}/certs/cert.pem" + ssl.cacertfile = "{{ platform_etc_dir }}/certs/cacert.pem" + #ssl.verify = verify_none + #ssl.fail_if_no_peer_cert = false + #ssl.server_name_indication = disable + #ssl.secure_renegotiate = false + #ssl.reuse_sessions = false + #ssl.honor_cipher_order = false + #ssl.handshake_timeout = 15s + #ssl.depth = 10 + #ssl.password = foo + #ssl.dhfile = path-to-your-file + } +} + +gateway.coap { + + ## How long time the connection will be disconnected if the + ## connection is established but no bytes received + idle_timeout = 30s + + ## To control whether write statistics data into ETS table + ## for dashbord to read. + enable_stats = true + + ## When publishing or subscribing, prefix all topics with a mountpoint string. + mountpoint = "" + + ## Enable or disable connection mode + ## If true, you need to establish a connection before send any publish/subscribe + ## requests + ## + ## Default: false + #connection_required = false + + ## The Notification Message Type. + ## The notification message will be delivered to the CoAP client if a new + ## message received on an observed topic. + ## The type of delivered coap message can be set to: + ## - non: Non-confirmable + ## - con: Confirmable + ## - qos: Mapping from QoS type of the recevied message. + ## QoS0 -> non, QoS1,2 -> con. + ## + ## Enum: non | con | qos + ## Default: qos + #notify_type = qos + + ## The *Default QoS Level* indicator for subscribe request. + ## This option specifies the QoS level for the CoAP Client when establishing + ## a subscription membership, if the subscribe request is not carried `qos` + ## option. + ## The indicator can be set to: + ## - qos0, qos1, qos2: Fixed default QoS level + ## - coap: Dynamic QoS level by the message type of subscribe request + ## * qos0: If the subscribe request is non-confirmable + ## * qos1: If the subscribe request is confirmable + ## + ## Enum: qos0 | qos1 | qos2 | coap + ## Default: coap + #subscribe_qos = coap + + ## The *Default QoS Level* indicator for publish request. + ## This option specifies the QoS level for the CoAP Client when publishing a + ## message to EMQ X PUB/SUB system, if the publish request is not carried `qos` + ## option. + ## The indicator can be set to: + ## - qos0, qos1, qos2: Fixed default QoS level + ## - coap: Dynamic QoS level by the message type of publish request + ## * qos0: If the publish request is non-confirmable + ## * qos1: If the publish request is confirmable + ## + ## Enum: qos0 | qos1 | qos2 | coap + #publish_qos = coap + + listeners.udp.default { + bind = 5683 + max_connections = 102400 + max_conn_rate = 1000 + + ## UDP Options + ## See ${example_common_udp_options} for more information + udp.active_n = 100 + udp.buffer = 16KB + } + listeners.dtls.default { + bind = 5684 + acceptors = 4 + max_connections = 102400 + max_conn_rate = 1000 + + ## UDP Options + ## See ${example_common_udp_options} for more information + udp.active_n = 100 + udp.buffer = 16KB + + ## DTLS Options + ## See #{example_common_dtls_options} for more information + dtls.versions = ["dtlsv1.2", "dtlsv1"] + dtls.keyfile = "{{ platform_etc_dir }}/certs/key.pem" + dtls.certfile = "{{ platform_etc_dir }}/certs/cert.pem" + dtls.cacertfile = "{{ platform_etc_dir }}/certs/cacert.pem" + dtls.handshake_timeout = 15s + } +} + +gateway.mqttsn { + + ## How long time the connection will be disconnected if the + ## connection is established but no bytes received + idle_timeout = 30s + + ## To control whether write statistics data into ETS table + ## for dashbord to read. + enable_stats = true + + ## When publishing or subscribing, prefix all topics with a mountpoint string. + mountpoint = "" + + ## The MQTT-SN Gateway ID in ADVERTISE message. + gateway_id = 1 + + ## Enable broadcast this gateway to WLAN + broadcast = true + + ## To control whether accept and process the received + ## publish message with qos=-1. + enable_qos3 = true + + ## The pre-defined topic name corresponding to the pre-defined topic + ## id of N. + ## Note that the pre-defined topic id of 0 is reserved. + predefined = [ + { id = 1 + topic = "/predefined/topic/name/hello" + }, + { id = 2 + topic = "/predefined/topic/name/nice" + } + ] + + ### ClientInfo override + clientinfo_override { + username = "mqtt_sn_user" + password = "abc" + } + + listeners.udp.default { + bind = 1884 + max_connections = 10240000 + max_conn_rate = 1000 + } + + listeners.dtls.default { + bind = 1885 + acceptors = 4 + max_connections = 102400 + max_conn_rate = 1000 + + ## UDP Options + ## See ${example_common_udp_options} for more information + udp.active_n = 100 + udp.buffer = 16KB + + ## DTLS Options + ## See #{example_common_dtls_options} for more information + dtls.versions = ["dtlsv1.2", "dtlsv1"] + dtls.keyfile = "{{ platform_etc_dir }}/certs/key.pem" + dtls.certfile = "{{ platform_etc_dir }}/certs/cert.pem" + dtls.cacertfile = "{{ platform_etc_dir }}/certs/cacert.pem" + } + +} + +gateway.lwm2m { + + ## How long time the connection will be disconnected if the + ## connection is established but no bytes received + idle_timeout = 30s + + ## To control whether write statistics data into ETS table + ## for dashbord to read. + enable_stats = true + + ## When publishing or subscribing, prefix all topics with a mountpoint string. + mountpoint = "lwm2m/%u" + + xml_dir = "{{ platform_etc_dir }}/lwm2m_xml" + + ## + ## + lifetime_min = 1s + + lifetime_max = 86400s + + qmode_time_window = 22 + + auto_observe = false + + ## always | contains_object_list + update_msg_publish_condition = contains_object_list + + + translators { + command { + topic = "/dn/#" + qos = 0 + } + + response { + topic = "/up/resp" + qos = 0 + } + + notify { + topic = "/up/notify" + qos = 0 + } + + register { + topic = "/up/resp" + qos = 0 + } + + update { + topic = "/up/resp" + qos = 0 + } + } + + listeners.udp.default { + bind = 5783 + } +} + +gateway.exproto { + + ## How long time the connection will be disconnected if the + ## connection is established but no bytes received + idle_timeout = 30s + + ## To control whether write statistics data into ETS table + ## for dashbord to read. + enable_stats = true + + ## When publishing or subscribing, prefix all topics with a mountpoint string. + mountpoint = "" + + ## The gRPC server to accept requests + server { + bind = 9100 + #ssl.keyfile: + #ssl.certfile: + #ssl.cacertfile: + } + + handler { + address = "http://127.0.0.1:9001" + #ssl.keyfile: + #ssl.certfile: + #ssl.cacertfile: + } + + listeners.tcp.default { + bind = 7993 + acceptors = 8 + max_connections = 10240 + max_conn_rate = 1000 + } + #listeners.ssl.default: {} + #listeners.udp.default: {} + #listeners.dtls.default: {} +}