|
|
@@ -53,329 +53,29 @@
|
|
|
|
|
|
-export([proxy_protocol_opts/0]).
|
|
|
|
|
|
+-export([mountpoint/0, mountpoint/1, gateway_common_options/0, gateway_schema/1]).
|
|
|
+
|
|
|
namespace() -> gateway.
|
|
|
|
|
|
tags() ->
|
|
|
[<<"Gateway">>].
|
|
|
|
|
|
-roots() -> [gateway].
|
|
|
+roots() ->
|
|
|
+ [{gateway, sc(ref(?MODULE, gateway), #{importance => ?IMPORTANCE_HIDDEN})}].
|
|
|
|
|
|
fields(gateway) ->
|
|
|
- [
|
|
|
- {stomp,
|
|
|
- sc(
|
|
|
- ref(stomp),
|
|
|
- #{
|
|
|
- required => {false, recursively},
|
|
|
- desc => ?DESC(stomp)
|
|
|
- }
|
|
|
- )},
|
|
|
- {mqttsn,
|
|
|
- sc(
|
|
|
- ref(mqttsn),
|
|
|
- #{
|
|
|
- required => {false, recursively},
|
|
|
- desc => ?DESC(mqttsn)
|
|
|
- }
|
|
|
- )},
|
|
|
- {coap,
|
|
|
- sc(
|
|
|
- ref(coap),
|
|
|
- #{
|
|
|
- required => {false, recursively},
|
|
|
- desc => ?DESC(coap)
|
|
|
- }
|
|
|
- )},
|
|
|
- {lwm2m,
|
|
|
- sc(
|
|
|
- ref(lwm2m),
|
|
|
- #{
|
|
|
- required => {false, recursively},
|
|
|
- desc => ?DESC(lwm2m)
|
|
|
- }
|
|
|
- )},
|
|
|
- {exproto,
|
|
|
- sc(
|
|
|
- ref(exproto),
|
|
|
- #{
|
|
|
- required => {false, recursively},
|
|
|
- desc => ?DESC(exproto)
|
|
|
- }
|
|
|
- )}
|
|
|
- ];
|
|
|
-fields(stomp) ->
|
|
|
- [
|
|
|
- {frame, sc(ref(stomp_frame))},
|
|
|
- {mountpoint, mountpoint()},
|
|
|
- {listeners, sc(ref(tcp_listeners), #{desc => ?DESC(tcp_listeners)})}
|
|
|
- ] ++ gateway_common_options();
|
|
|
-fields(stomp_frame) ->
|
|
|
- [
|
|
|
- {max_headers,
|
|
|
- sc(
|
|
|
- non_neg_integer(),
|
|
|
- #{
|
|
|
- default => 10,
|
|
|
- desc => ?DESC(stom_frame_max_headers)
|
|
|
- }
|
|
|
- )},
|
|
|
- {max_headers_length,
|
|
|
- sc(
|
|
|
- non_neg_integer(),
|
|
|
- #{
|
|
|
- default => 1024,
|
|
|
- desc => ?DESC(stomp_frame_max_headers_length)
|
|
|
- }
|
|
|
- )},
|
|
|
- {max_body_length,
|
|
|
- sc(
|
|
|
- integer(),
|
|
|
- #{
|
|
|
- default => 65536,
|
|
|
- desc => ?DESC(stom_frame_max_body_length)
|
|
|
- }
|
|
|
- )}
|
|
|
- ];
|
|
|
-fields(mqttsn) ->
|
|
|
- [
|
|
|
- {gateway_id,
|
|
|
- sc(
|
|
|
- integer(),
|
|
|
- #{
|
|
|
- default => 1,
|
|
|
- required => true,
|
|
|
- desc => ?DESC(mqttsn_gateway_id)
|
|
|
- }
|
|
|
- )},
|
|
|
- {broadcast,
|
|
|
- sc(
|
|
|
- boolean(),
|
|
|
- #{
|
|
|
- default => false,
|
|
|
- desc => ?DESC(mqttsn_broadcast)
|
|
|
- }
|
|
|
- )},
|
|
|
- %% TODO: rename
|
|
|
- {enable_qos3,
|
|
|
- sc(
|
|
|
- boolean(),
|
|
|
- #{
|
|
|
- default => true,
|
|
|
- desc => ?DESC(mqttsn_enable_qos3)
|
|
|
- }
|
|
|
- )},
|
|
|
- {subs_resume,
|
|
|
- sc(
|
|
|
- boolean(),
|
|
|
- #{
|
|
|
- default => false,
|
|
|
- desc => ?DESC(mqttsn_subs_resume)
|
|
|
- }
|
|
|
- )},
|
|
|
- {predefined,
|
|
|
- sc(
|
|
|
- hoconsc:array(ref(mqttsn_predefined)),
|
|
|
- #{
|
|
|
- default => [],
|
|
|
- required => {false, recursively},
|
|
|
- desc => ?DESC(mqttsn_predefined)
|
|
|
- }
|
|
|
- )},
|
|
|
- {mountpoint, mountpoint()},
|
|
|
- {listeners, sc(ref(udp_listeners), #{desc => ?DESC(udp_listeners)})}
|
|
|
- ] ++ gateway_common_options();
|
|
|
-fields(mqttsn_predefined) ->
|
|
|
- [
|
|
|
- {id,
|
|
|
- sc(integer(), #{
|
|
|
- required => true,
|
|
|
- desc => ?DESC(mqttsn_predefined_id)
|
|
|
- })},
|
|
|
-
|
|
|
- {topic,
|
|
|
- sc(binary(), #{
|
|
|
- required => true,
|
|
|
- desc => ?DESC(mqttsn_predefined_topic)
|
|
|
- })}
|
|
|
- ];
|
|
|
-fields(coap) ->
|
|
|
- [
|
|
|
- {heartbeat,
|
|
|
- sc(
|
|
|
- duration(),
|
|
|
- #{
|
|
|
- default => <<"30s">>,
|
|
|
- desc => ?DESC(coap_heartbeat)
|
|
|
- }
|
|
|
- )},
|
|
|
- {connection_required,
|
|
|
- sc(
|
|
|
- boolean(),
|
|
|
- #{
|
|
|
- default => false,
|
|
|
- desc => ?DESC(coap_connection_required)
|
|
|
- }
|
|
|
- )},
|
|
|
- {notify_type,
|
|
|
- sc(
|
|
|
- hoconsc:enum([non, con, qos]),
|
|
|
- #{
|
|
|
- default => qos,
|
|
|
- desc => ?DESC(coap_notify_type)
|
|
|
- }
|
|
|
- )},
|
|
|
- {subscribe_qos,
|
|
|
- sc(
|
|
|
- hoconsc:enum([qos0, qos1, qos2, coap]),
|
|
|
- #{
|
|
|
- default => coap,
|
|
|
- desc => ?DESC(coap_subscribe_qos)
|
|
|
- }
|
|
|
- )},
|
|
|
- {publish_qos,
|
|
|
- sc(
|
|
|
- hoconsc:enum([qos0, qos1, qos2, coap]),
|
|
|
- #{
|
|
|
- default => coap,
|
|
|
- desc => ?DESC(coap_publish_qos)
|
|
|
- }
|
|
|
- )},
|
|
|
- {mountpoint, mountpoint()},
|
|
|
- {listeners,
|
|
|
- sc(
|
|
|
- ref(udp_listeners),
|
|
|
- #{desc => ?DESC(udp_listeners)}
|
|
|
- )}
|
|
|
- ] ++ gateway_common_options();
|
|
|
-fields(lwm2m) ->
|
|
|
- [
|
|
|
- {xml_dir,
|
|
|
- sc(
|
|
|
- binary(),
|
|
|
- #{
|
|
|
- %% since this is not packaged with emqx, nor
|
|
|
- %% present in the packages, we must let the user
|
|
|
- %% specify it rather than creating a dynamic
|
|
|
- %% default (especially difficult to handle when
|
|
|
- %% generating docs).
|
|
|
- example => <<"/etc/emqx/lwm2m_xml">>,
|
|
|
- required => true,
|
|
|
- desc => ?DESC(lwm2m_xml_dir)
|
|
|
- }
|
|
|
- )},
|
|
|
- {lifetime_min,
|
|
|
- sc(
|
|
|
- duration(),
|
|
|
- #{
|
|
|
- default => <<"15s">>,
|
|
|
- desc => ?DESC(lwm2m_lifetime_min)
|
|
|
- }
|
|
|
- )},
|
|
|
- {lifetime_max,
|
|
|
- sc(
|
|
|
- duration(),
|
|
|
- #{
|
|
|
- default => <<"86400s">>,
|
|
|
- desc => ?DESC(lwm2m_lifetime_max)
|
|
|
- }
|
|
|
- )},
|
|
|
- {qmode_time_window,
|
|
|
- sc(
|
|
|
- duration_s(),
|
|
|
- #{
|
|
|
- default => <<"22s">>,
|
|
|
- desc => ?DESC(lwm2m_qmode_time_window)
|
|
|
- }
|
|
|
- )},
|
|
|
- %% TODO: Support config resource path
|
|
|
- {auto_observe,
|
|
|
- sc(
|
|
|
- boolean(),
|
|
|
- #{
|
|
|
- default => false,
|
|
|
- desc => ?DESC(lwm2m_auto_observe)
|
|
|
- }
|
|
|
- )},
|
|
|
- %% FIXME: not working now
|
|
|
- {update_msg_publish_condition,
|
|
|
- sc(
|
|
|
- hoconsc:enum([always, contains_object_list]),
|
|
|
- #{
|
|
|
- default => contains_object_list,
|
|
|
- desc => ?DESC(lwm2m_update_msg_publish_condition)
|
|
|
- }
|
|
|
- )},
|
|
|
- {translators,
|
|
|
- sc(
|
|
|
- ref(lwm2m_translators),
|
|
|
- #{
|
|
|
- required => true,
|
|
|
- desc => ?DESC(lwm2m_translators)
|
|
|
- }
|
|
|
- )},
|
|
|
- {mountpoint, mountpoint("lwm2m/${endpoint_name}/")},
|
|
|
- {listeners, sc(ref(udp_listeners), #{desc => ?DESC(udp_listeners)})}
|
|
|
- ] ++ gateway_common_options();
|
|
|
-fields(exproto) ->
|
|
|
- [
|
|
|
- {server,
|
|
|
- sc(
|
|
|
- ref(exproto_grpc_server),
|
|
|
- #{
|
|
|
- required => true,
|
|
|
- desc => ?DESC(exproto_server)
|
|
|
- }
|
|
|
- )},
|
|
|
- {handler,
|
|
|
- sc(
|
|
|
- ref(exproto_grpc_handler),
|
|
|
- #{
|
|
|
- required => true,
|
|
|
- desc => ?DESC(exproto_handler)
|
|
|
- }
|
|
|
- )},
|
|
|
- {mountpoint, mountpoint()},
|
|
|
- {listeners, sc(ref(tcp_udp_listeners), #{desc => ?DESC(tcp_udp_listeners)})}
|
|
|
- ] ++ gateway_common_options();
|
|
|
-fields(exproto_grpc_server) ->
|
|
|
- [
|
|
|
- {bind,
|
|
|
- sc(
|
|
|
- hoconsc:union([ip_port(), integer()]),
|
|
|
- #{
|
|
|
- required => true,
|
|
|
- desc => ?DESC(exproto_grpc_server_bind)
|
|
|
- }
|
|
|
- )},
|
|
|
- {ssl_options,
|
|
|
- sc(
|
|
|
- ref(ssl_server_opts),
|
|
|
- #{
|
|
|
- required => {false, recursively},
|
|
|
- desc => ?DESC(exproto_grpc_server_ssl)
|
|
|
- }
|
|
|
- )}
|
|
|
- ];
|
|
|
-fields(exproto_grpc_handler) ->
|
|
|
- [
|
|
|
- {address, sc(binary(), #{required => true, desc => ?DESC(exproto_grpc_handler_address)})},
|
|
|
- {ssl_options,
|
|
|
- sc(
|
|
|
- ref(emqx_schema, "ssl_client_opts"),
|
|
|
- #{
|
|
|
- required => {false, recursively},
|
|
|
- desc => ?DESC(exproto_grpc_handler_ssl)
|
|
|
- }
|
|
|
- )}
|
|
|
- ];
|
|
|
-fields(ssl_server_opts) ->
|
|
|
- emqx_schema:server_ssl_opts_schema(
|
|
|
- #{
|
|
|
- depth => 10,
|
|
|
- reuse_sessions => true,
|
|
|
- versions => tls_all_available
|
|
|
- },
|
|
|
- true
|
|
|
+ lists:map(
|
|
|
+ fun(#{name := Name, config_schema_module := Mod}) ->
|
|
|
+ {Name,
|
|
|
+ sc(
|
|
|
+ ref(Mod, Name),
|
|
|
+ #{
|
|
|
+ required => {false, recursively},
|
|
|
+ desc => ?DESC(Name)
|
|
|
+ }
|
|
|
+ )}
|
|
|
+ end,
|
|
|
+ emqx_gateway_utils:find_gateway_definations()
|
|
|
);
|
|
|
fields(clientinfo_override) ->
|
|
|
[
|
|
|
@@ -389,68 +89,6 @@ fields(clientinfo_override) ->
|
|
|
})},
|
|
|
{clientid, sc(binary(), #{desc => ?DESC(gateway_common_clientinfo_override_clientid)})}
|
|
|
];
|
|
|
-fields(lwm2m_translators) ->
|
|
|
- [
|
|
|
- {command,
|
|
|
- sc(
|
|
|
- ref(translator),
|
|
|
- #{
|
|
|
- desc => ?DESC(lwm2m_translators_command),
|
|
|
- required => true
|
|
|
- }
|
|
|
- )},
|
|
|
- {response,
|
|
|
- sc(
|
|
|
- ref(translator),
|
|
|
- #{
|
|
|
- desc => ?DESC(lwm2m_translators_response),
|
|
|
- required => true
|
|
|
- }
|
|
|
- )},
|
|
|
- {notify,
|
|
|
- sc(
|
|
|
- ref(translator),
|
|
|
- #{
|
|
|
- desc => ?DESC(lwm2m_translators_notify),
|
|
|
- required => true
|
|
|
- }
|
|
|
- )},
|
|
|
- {register,
|
|
|
- sc(
|
|
|
- ref(translator),
|
|
|
- #{
|
|
|
- desc => ?DESC(lwm2m_translators_register),
|
|
|
- required => true
|
|
|
- }
|
|
|
- )},
|
|
|
- {update,
|
|
|
- sc(
|
|
|
- ref(translator),
|
|
|
- #{
|
|
|
- desc => ?DESC(lwm2m_translators_update),
|
|
|
- required => true
|
|
|
- }
|
|
|
- )}
|
|
|
- ];
|
|
|
-fields(translator) ->
|
|
|
- [
|
|
|
- {topic,
|
|
|
- sc(
|
|
|
- binary(),
|
|
|
- #{
|
|
|
- required => true,
|
|
|
- desc => ?DESC(translator_topic)
|
|
|
- }
|
|
|
- )},
|
|
|
- {qos,
|
|
|
- sc(
|
|
|
- emqx_schema:qos(),
|
|
|
- #{
|
|
|
- default => 0,
|
|
|
- desc => ?DESC(translator_qos)
|
|
|
- }
|
|
|
- )}
|
|
|
- ];
|
|
|
fields(udp_listeners) ->
|
|
|
[
|
|
|
{udp, sc(map(name, ref(udp_listener)), #{desc => ?DESC(listener_name_to_settings_map)})},
|
|
|
@@ -522,37 +160,8 @@ fields(dtls_opts) ->
|
|
|
|
|
|
desc(gateway) ->
|
|
|
"EMQX Gateway configuration root.";
|
|
|
-desc(stomp) ->
|
|
|
- "The STOMP protocol gateway provides EMQX with the ability to access STOMP\n"
|
|
|
- "(Simple (or Streaming) Text Orientated Messaging Protocol) protocol.";
|
|
|
-desc(stomp_frame) ->
|
|
|
- "Size limits for the STOMP frames.";
|
|
|
-desc(mqttsn) ->
|
|
|
- "The MQTT-SN (MQTT for Sensor Networks) protocol gateway.";
|
|
|
-desc(mqttsn_predefined) ->
|
|
|
- "The pre-defined topic name corresponding to the pre-defined topic\n"
|
|
|
- "ID of N.\n\n"
|
|
|
- "Note: the pre-defined topic ID of 0 is reserved.";
|
|
|
-desc(coap) ->
|
|
|
- "The CoAP protocol gateway provides EMQX with the access capability of the CoAP protocol.\n"
|
|
|
- "It allows publishing, subscribing, and receiving messages to EMQX in accordance\n"
|
|
|
- "with a certain defined CoAP message format.";
|
|
|
-desc(lwm2m) ->
|
|
|
- "The LwM2M protocol gateway.";
|
|
|
-desc(exproto) ->
|
|
|
- "Settings for EMQX extension protocol (exproto).";
|
|
|
-desc(exproto_grpc_server) ->
|
|
|
- "Settings for the exproto gRPC server.";
|
|
|
-desc(exproto_grpc_handler) ->
|
|
|
- "Settings for the exproto gRPC connection handler.";
|
|
|
-desc(ssl_server_opts) ->
|
|
|
- "SSL configuration for the server.";
|
|
|
desc(clientinfo_override) ->
|
|
|
"ClientInfo override.";
|
|
|
-desc(lwm2m_translators) ->
|
|
|
- "MQTT topics that correspond to LwM2M events.";
|
|
|
-desc(translator) ->
|
|
|
- "MQTT topic that corresponds to a particular type of event.";
|
|
|
desc(udp_listeners) ->
|
|
|
"Settings for the UDP listeners.";
|
|
|
desc(tcp_listeners) ->
|
|
|
@@ -715,8 +324,18 @@ proxy_protocol_opts() ->
|
|
|
)}
|
|
|
].
|
|
|
|
|
|
-sc(Type) ->
|
|
|
- sc(Type, #{}).
|
|
|
+%%--------------------------------------------------------------------
|
|
|
+%% dynamic schemas
|
|
|
+
|
|
|
+%% FIXME: don't hardcode the gateway names
|
|
|
+gateway_schema(stomp) -> emqx_stomp_schema:fields(stomp);
|
|
|
+gateway_schema(mqttsn) -> emqx_mqttsn_schema:fields(mqttsn);
|
|
|
+gateway_schema(coap) -> emqx_coap_schema:fields(coap);
|
|
|
+gateway_schema(lwm2m) -> emqx_lwm2m_schema:fields(lwm2m);
|
|
|
+gateway_schema(exproto) -> emqx_exproto_schema:fields(exproto).
|
|
|
+
|
|
|
+%%--------------------------------------------------------------------
|
|
|
+%% helpers
|
|
|
|
|
|
sc(Type, Meta) ->
|
|
|
hoconsc:mk(Type, Meta).
|