diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md new file mode 100644 index 000000000..0e2b17bb8 --- /dev/null +++ b/CONTRIBUTORS.md @@ -0,0 +1,26 @@ + +* [@callbay](https://github.com/callbay) + +* [@lsxredrain](https://github.com/lsxredrain) + +* [@hejin1026](https://github.com/hejin1026) + +* [@desoulter](https://github.com/desoulter) + +* [@turtleDeng](https://github.com/turtleDeng) + +* [@Hades32](https://github.com/Hades32) + +* [@huangdan](https://github.com/huangdan) + +* [@phanimahesh](https://github.com/phanimahesh) + +* [@dvliman](https://github.com/dvliman) + +* [@vowstar](https://github.com/vowstar) + +* [@TheWaWaR](https://github.com/TheWaWaR) + +* [@hejin1026](https://github.com/hejin1026) + +* [@farhadi](https://github.com/farhadi) diff --git a/Makefile b/Makefile index 98da008ac..ff2a5602f 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,8 @@ PROJECT = emqttd PROJECT_DESCRIPTION = Erlang MQTT Broker -PROJECT_VERSION = 2.0 +PROJECT_VERSION = 2.0.7 DEPS = gproc lager gen_logger esockd mochiweb -## getopt pbkdf2 clique time_compat rand_compat dep_gproc = git https://github.com/uwiger/gproc dep_getopt = git https://github.com/jcomellas/getopt v0.8.2 @@ -11,16 +10,15 @@ dep_lager = git https://github.com/basho/lager master dep_gen_logger = git https://github.com/emqtt/gen_logger dep_esockd = git https://github.com/emqtt/esockd proxy-protocol dep_mochiweb = git https://github.com/emqtt/mochiweb -#dep_clique = git https://github.com/basho/clique -#dep_pbkdf2 = git https://github.com/basho/erlang-pbkdf2 2.0.0 -#dep_time_compat = git https://github.com/lasp-lang/time_compat -#dep_rand_compat = git https://github.com/lasp-lang/rand_compat - -TEST_DEPS = cuttlefish -dep_cuttlefish = git https://github.com/emqtt/cuttlefish ERLC_OPTS += +'{parse_transform, lager_transform}' +TEST_DEPS = cuttlefish emqttc +dep_cuttlefish = git https://github.com/emqtt/cuttlefish +dep_emqttc = git https://github.com/emqtt/emqttc + +NO_AUTOPATCH = cuttlefish + TEST_ERLC_OPTS += +debug_info TEST_ERLC_OPTS += +'{parse_transform, lager_transform}' diff --git a/README.md b/README.md index a3c80b552..95a0a0d54 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,20 @@ -## Overview [![Build Status](https://travis-ci.org/emqtt/emqttd.svg?branch=master)](https://travis-ci.org/emqtt/emqttd) +# *EMQ* - Erlang MQTT Broker [![Build Status](https://travis-ci.org/emqtt/emqttd.svg?branch=master)](https://travis-ci.org/emqtt/emqttd) -emqttd is a massively scalable and clusterable MQTT V3.1/V3.1.1 broker written in Erlang/OTP. +*EMQ* (Erlang MQTT Broker) is a distributed, massively scalable, highly extensible MQTT message broker written in Erlang/OTP. -emqttd is fully open source and licensed under the Apache Version 2.0. emqttd implements both MQTT V3.1 and V3.1.1 protocol specifications, and supports WebSocket, STOMP, SockJS, CoAP and MQTT-SN at the same time. +*EMQ* is fully open source and licensed under the Apache Version 2.0. *EMQ* implements both MQTT V3.1 and V3.1.1 protocol specifications, and supports MQTT-SN, CoAP, WebSocket, STOMP and SockJS at the same time. -emqttd requires Erlang R18+ to build since 1.1 release. +*EMQ* provides a scalable, reliable, enterprise-grade MQTT message Hub for IoT, M2M, Smart Hardware and Mobile Messaging Applications. -Follow us on Twitter: [@emqtt](https://twitter.com/emqtt) +The 1.0 release of the EMQ broker has scaled to 1.3 million concurrent MQTT connections on a 12 Core, 32G CentOS server. -## Cluster - -The **q.emqtt.com** hosts a public emqttd cluster on [QingCloud](https://qingcloud.com): - -![qing_cluster](http://emqtt.io/static/img/public_cluster.png) - -## Goals - -The emqttd project is aimed to implement a scalable, distributed, extensible open-source MQTT broker for IoT, M2M and Mobile applications that hope to handle millions of concurrent MQTT clients. - -* Easy to install -* Massively scalable -* Easy to extend -* Solid stable +Please visit [emqtt.io](http://emqtt.io) for more service. Follow us on Twitter: [@emqtt](https://twitter.com/emqtt) ## Features -* Full MQTT V3.1/V3.1.1 protocol specification support -* QoS0, QoS1, QoS2 Publish and Subscribe +* Full MQTT V3.1/V3.1.1 support +* QoS0, QoS1, QoS2 Publish/Subscribe * Session Management and Offline Messages * Retained Message * Last Will Message @@ -42,17 +29,44 @@ The emqttd project is aimed to implement a scalable, distributed, extensible ope * IpAddress Authentication * Username and Password Authentication * Access control based on IpAddress, ClientID, Username -* Authentication with LDAP, Redis, MySQL, PostgreSQL and HTTP API -* Cluster brokers on several servers +* LDAP Authentication/ACL +* HTTP Authentication/ACL +* MySQL Authentication/ACL +* Redis Authentication/ACL +* PostgreSQL Authentication/ACL +* MongoDB Authentication/ACL +* Cluster brokers on several nodes * Bridge brokers locally or remotely * mosquitto, RSMB bridge -* Extensible architecture with Hooks, Modules and Plugins +* Extensible architecture with Hooks and Plugins * Passed eclipse paho interoperability tests * Local Subscription * Shared Subscription +## Installation + +The *EMQ* broker is cross-platform, which can be deployed on Linux, Unix, Mac, Windows and even Raspberry Pi. + +Download the binary package for your platform from http://emqtt.io/downloads. + +Documentation on [emqtt.io/docs/v2/](http://emqtt.io/docs/v2/install.html), [docs.emqtt.com](http://docs.emqtt.com/en/latest/install.html) for installation and configuration guide. + +## Build From Source + +The *EMQ* broker requires Erlang/OTP R18+ to build. + +``` +git clone https://github.com/emqtt/emq-relx.git + +cd emq-relx && make + +cd _rel/emqttd && ./bin/emqttd console +``` + ## Plugins +The *EMQ* broker is highly extensible, with many hooks and plugins for customizing the authentication/ACL and integrating with other systems: + Plugin | Description -----------------------------------------------------------------------|-------------------------------------- [emq_plugin_template](https://github.com/emqtt/emq_plugin_template) | Plugin template and demo @@ -76,98 +90,24 @@ Plugin | Descrip [emq_reloader](https://github.com/emqtt/emq_reloader) | Reloader Plugin [emq_sockjs](https://github.com/emqtt/emq_sockjs) | SockJS(Stomp) Plugin -## Dashboard - -A Web Dashboard will be loaded when the emqttd broker started successfully. - -The Dashboard helps monitor broker's running status, statistics and metrics of MQTT packets. - -Default Address: http://localhost:18083 - -Default Login/Password: admin/public - -## Design - -![emqttd architecture](http://emqtt.io/static/img/architecture.png) - -## QuickStart - -Download binary package for Linux, Mac and Freebsd from [http://emqtt.io/downloads](http://emqtt.io/downloads). - -Installing on Ubuntu64, for example: - -```sh -unzip emqttd-ubuntu64-2.0-rc.2-20161019.zip && cd emqttd - -# start console -./bin/emqttd console - -# start as daemon -./bin/emqttd start - -# check status -./bin/emqttd_ctl status - -# stop -./bin/emqttd stop -``` - -Installing from source: - -``` -git clone https://github.com/emqtt/emq-relx.git - -cd emq-relx && make - -cd _rel/emqttd && ./bin/emqttd console -``` - -## Documents - -Read Documents on [emqttd-docs.rtfd.org](http://emqttd-docs.rtfd.org) for installation and configuration guide. - -## Benchmark - -Latest release of emqttd broker is scaling to 1.3 million MQTT connections on a 12 Core, 32G CentOS server. - -Benchmark 0.12.0-beta on a CentOS6 server with 8 Core, 32G memory from QingCloud: - -250K Connections, 250K Topics, 250K Subscriptions, 4K Qos1 Messages/Sec In, 20K Qos1 Messages/Sec Out, 8M+(bps) In, 40M+(bps) Out Traffic - -Consumed about 3.6G memory and 400+% CPU. - -Benchmark Report: [benchmark for 0.12.0 release](https://github.com/emqtt/emqttd/wiki/benchmark-for-0.12.0-release) - ## Supports * Twitter: [@emqtt](https://twitter.com/emqtt) * Homepage: http://emqtt.io * Downloads: http://emqtt.io/downloads -* Wiki: https://github.com/emqtt/emqttd/wiki +* Documentation: http://emqtt.io/docs/v2/ * Forum: https://groups.google.com/d/forum/emqtt * Mailing List: * Issues: https://github.com/emqtt/emqttd/issues * QQ Group: 12222225 -## Contributors - -* [@callbay](https://github.com/callbay) -* [@lsxredrain](https://github.com/lsxredrain) -* [@hejin1026](https://github.com/hejin1026) -* [@desoulter](https://github.com/desoulter) -* [@turtleDeng](https://github.com/turtleDeng) -* [@Hades32](https://github.com/Hades32) -* [@huangdan](https://github.com/huangdan) -* [@phanimahesh](https://github.com/phanimahesh) -* [@dvliman](https://github.com/dvliman) - ## Partners [QingCloud](https://qingcloud.com) is the world’s first IaaS provider that can deliver any number of IT resources in seconds and adopts a second-based billing system. QingCloud is committed to providing a reliable, secure, on-demand and real-time IT resource platform with excellent performance, which includes all components of a complete IT infrastructure system: computing, storage, networking and security. -## Author +The **q.emqtt.com** hosts a public Four-Node *EMQ* cluster on [QingCloud](https://qingcloud.com): -Feng Lee +![qing_cluster](http://emqtt.io/static/img/public_cluster.png) ## License diff --git a/include/emqttd.hrl b/include/emqttd.hrl index 75a030c2e..53350ed6d 100644 --- a/include/emqttd.hrl +++ b/include/emqttd.hrl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ %% Banner %%-------------------------------------------------------------------- --define(COPYRIGHT, "Copyright (C) 2012-2016, Feng Lee "). +-define(COPYRIGHT, "Copyright (C) 2012-2017, Feng Lee "). -define(LICENSE_MESSAGE, "Licensed under the Apache License, Version 2.0"). diff --git a/include/emqttd_cli.hrl b/include/emqttd_cli.hrl index f8245f9a8..461306747 100644 --- a/include/emqttd_cli.hrl +++ b/include/emqttd_cli.hrl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/include/emqttd_internal.hrl b/include/emqttd_internal.hrl index 56522a62f..06102e26a 100644 --- a/include/emqttd_internal.hrl +++ b/include/emqttd_internal.hrl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/include/emqttd_protocol.hrl b/include/emqttd_protocol.hrl index 8a5e5d0ca..9ed3a993b 100644 --- a/include/emqttd_protocol.hrl +++ b/include/emqttd_protocol.hrl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/include/emqttd_trie.hrl b/include/emqttd_trie.hrl index e701d90cd..bd4184ad8 100644 --- a/include/emqttd_trie.hrl +++ b/include/emqttd_trie.hrl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2016 Feng Lee . +%% Copyright (c) 2016-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/priv/emq.schema b/priv/emq.schema index c8580287f..f562faeab 100644 --- a/priv/emq.schema +++ b/priv/emq.schema @@ -270,8 +270,7 @@ end}. %% @doc Allow Anonymous {mapping, "mqtt.allow_anonymous", "emqttd.allow_anonymous", [ {default, false}, - {datatype, {enum, [true, false]}}, - hidden + {datatype, {enum, [true, false]}} ]}. %% @doc Default ACL File @@ -283,8 +282,7 @@ end}. %% @doc Cache ACL for PUBLISH {mapping, "mqtt.cache_acl", "emqttd.cache_acl", [ {default, true}, - {datatype, {enum, [true, false]}}, - hidden + {datatype, {enum, [true, false]}} ]}. %%-------------------------------------------------------------------- @@ -351,8 +349,7 @@ end}. %% @doc Topic Priority: 0~255, Default is 0 {mapping, "mqtt.queue.priority", "emqttd.queue", [ {default, ""}, - {datatype, string}, - hidden + {datatype, string} ]}. %% @doc Max queue length. Enqueued messages when persistent client disconnected, or inflight window is full. @@ -364,15 +361,13 @@ end}. %% @doc Low-water mark of queued messages {mapping, "mqtt.queue.low_watermark", "emqttd.queue", [ {default, "20%"}, - {datatype, string}, - hidden + {datatype, string} ]}. %% @doc High-water mark of queued messages {mapping, "mqtt.queue.high_watermark", "emqttd.queue", [ {default, "60%"}, - {datatype, string}, - hidden + {datatype, string} ]}. %% @doc Queue Qos0 messages? @@ -425,8 +420,7 @@ end}. {mapping, "mqtt.pubsub.async", "emqttd.pubsub", [ {default, true}, - {datatype, {enum, [true, false]}}, - hidden + {datatype, {enum, [true, false]}} ]}. {translation, "emqttd.pubsub", fun(Conf) -> @@ -471,7 +465,7 @@ end}. %%-------------------------------------------------------------------- {mapping, "mqtt.listener.tcp", "emqttd.listeners", [ - {default, 1883}, + %% {default, 1883}, {datatype, [integer, ip]} ]}. @@ -487,8 +481,7 @@ end}. {mapping, "mqtt.listener.tcp.rate_limit", "emqttd.listeners", [ {default, undefined}, - {datatype, string}, - hidden + {datatype, string} ]}. {mapping, "mqtt.listener.tcp.proxy_protocol", "emqttd.listeners", [ @@ -530,7 +523,7 @@ end}. ]}. {mapping, "mqtt.listener.ssl", "emqttd.listeners", [ - {default, 8883}, + %% {default, 8883}, {datatype, [integer, ip]} ]}. @@ -587,7 +580,7 @@ end}. ]}. {mapping, "mqtt.listener.http", "emqttd.listeners", [ - {default, 8883}, + %% {default, 8083}, {datatype, [integer, ip]} ]}. @@ -615,9 +608,8 @@ end}. ]}. {mapping, "mqtt.listener.https", "emqttd.listeners", [ - {default, undefined}, - {datatype, [integer, ip]}, - hidden + %%{default, 8084}, + {datatype, [integer, ip]} ]}. {mapping, "mqtt.listener.https.acceptors", "emqttd.listeners", [ diff --git a/rebar.config b/rebar.config index a95234dee..c9e0dbcf0 100644 --- a/rebar.config +++ b/rebar.config @@ -1,4 +1,4 @@ {deps, [ -{gproc,".*",{git,"https://github.com/uwiger/gproc",""}},{lager,".*",{git,"https://github.com/basho/lager","master"}},{gen_logger,".*",{git,"https://github.com/emqtt/gen_logger",""}},{esockd,".*",{git,"https://github.com/emqtt/esockd","emq20"}},{mochiweb,".*",{git,"https://github.com/emqtt/mochiweb",""}} +{gproc,".*",{git,"https://github.com/uwiger/gproc",""}},{lager,".*",{git,"https://github.com/basho/lager","master"}},{gen_logger,".*",{git,"https://github.com/emqtt/gen_logger",""}},{esockd,".*",{git,"https://github.com/emqtt/esockd","master"}},{mochiweb,".*",{git,"https://github.com/emqtt/mochiweb",""}} ]}. {erl_opts, [{parse_transform,lager_transform}]}. diff --git a/src/emqttd.erl b/src/emqttd.erl index c360a5870..23db807cc 100644 --- a/src/emqttd.erl +++ b/src/emqttd.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ %% limitations under the License. %%-------------------------------------------------------------------- -%% Facade Module for The EMQTT Broker +%% Facade Module for The EMQ Broker -module(emqttd). @@ -22,7 +22,7 @@ -include("emqttd_protocol.hrl"). --export([start/0, env/1, env/2, is_running/1]). +-export([start/0, env/1, env/2, is_running/1, stop/0]). %% PubSub API -export([subscribe/1, subscribe/2, subscribe/3, publish/1, @@ -57,6 +57,10 @@ -spec(start() -> ok | {error, any()}). start() -> application:start(?APP). +%% @doc Stop emqttd application. +-spec(stop() -> ok | {error, any()}). +stop() -> application:stop(?APP). + %% @doc Environment -spec(env(Key:: atom()) -> {ok, any()} | undefined). env(Key) -> application:get_env(?APP, Key). diff --git a/src/emqttd_access_control.erl b/src/emqttd_access_control.erl index 688e244a4..7aea58e79 100644 --- a/src/emqttd_access_control.erl +++ b/src/emqttd_access_control.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_access_rule.erl b/src/emqttd_access_rule.erl index 88395b182..1590d2efe 100644 --- a/src/emqttd_access_rule.erl +++ b/src/emqttd_access_rule.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_acl_internal.erl b/src/emqttd_acl_internal.erl index 610cf91a3..74ab8519a 100644 --- a/src/emqttd_acl_internal.erl +++ b/src/emqttd_acl_internal.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_acl_mod.erl b/src/emqttd_acl_mod.erl index 2eb09a0fe..44c775460 100644 --- a/src/emqttd_acl_mod.erl +++ b/src/emqttd_acl_mod.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_alarm.erl b/src/emqttd_alarm.erl index 4ba752035..1ff4a5ae9 100644 --- a/src/emqttd_alarm.erl +++ b/src/emqttd_alarm.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_app.erl b/src/emqttd_app.erl index 048a196cd..bdbfc4a54 100644 --- a/src/emqttd_app.erl +++ b/src/emqttd_app.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_auth_mod.erl b/src/emqttd_auth_mod.erl index 845d5a0fb..d6d4a55b0 100644 --- a/src/emqttd_auth_mod.erl +++ b/src/emqttd_auth_mod.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_base62.erl b/src/emqttd_base62.erl index 1e9d0a1a2..5895fa245 100644 --- a/src/emqttd_base62.erl +++ b/src/emqttd_base62.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2016 Feng Lee . +%% Copyright (c) 2016-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_boot.erl b/src/emqttd_boot.erl index e2ca2b931..043eb08c3 100644 --- a/src/emqttd_boot.erl +++ b/src/emqttd_boot.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_bridge.erl b/src/emqttd_bridge.erl index de51b8f5d..3dca7bf0f 100644 --- a/src/emqttd_bridge.erl +++ b/src/emqttd_bridge.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_bridge_sup.erl b/src/emqttd_bridge_sup.erl index 64c3fcf83..dd418b2f6 100644 --- a/src/emqttd_bridge_sup.erl +++ b/src/emqttd_bridge_sup.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_bridge_sup_sup.erl b/src/emqttd_bridge_sup_sup.erl index 109f94764..47e246273 100644 --- a/src/emqttd_bridge_sup_sup.erl +++ b/src/emqttd_bridge_sup_sup.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_broker.erl b/src/emqttd_broker.erl index 409fe5c8b..96dd7d553 100644 --- a/src/emqttd_broker.erl +++ b/src/emqttd_broker.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_cli.erl b/src/emqttd_cli.erl index 16c6adb8d..085032b24 100644 --- a/src/emqttd_cli.erl +++ b/src/emqttd_cli.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -195,7 +195,8 @@ sessions(_) -> %%-------------------------------------------------------------------- %% @doc Routes Command routes(["list"]) -> - if_could_print(mqtt_route, fun print/1); + Routes = emqttd_router:dump(), + foreach(fun print/1, Routes); routes(["show", Topic]) -> print(mnesia:dirty_read(mqtt_route, bin(Topic))); @@ -506,9 +507,14 @@ print(#mqtt_client{client_id = ClientId, clean_sess = CleanSess, username = User %% print(#mqtt_topic{topic = Topic, flags = Flags}) -> %% ?PRINT("~s: ~s~n", [Topic, string:join([atom_to_list(F) || F <- Flags], ",")]); - +print({route, Routes}) -> + foreach(fun print/1, Routes); +print({local_route, Routes}) -> + foreach(fun print/1, Routes); print(#mqtt_route{topic = Topic, node = Node}) -> ?PRINT("~s -> ~s~n", [Topic, Node]); +print({Topic, Node}) -> + ?PRINT("~s -> ~s~n", [Topic, Node]); print({ClientId, _ClientPid, _Persistent, SessInfo}) -> InfoKeys = [clean_sess, @@ -528,6 +534,10 @@ print({ClientId, _ClientPid, _Persistent, SessInfo}) -> print(subscription, {Sub, Topic}) when is_pid(Sub) -> ?PRINT("~p -> ~s~n", [Sub, Topic]); +print(subscription, {Sub, {_Share, Topic}}) when is_pid(Sub) -> + ?PRINT("~p -> ~s~n", [Sub, Topic]); +print(subscription, {Sub, {_Share, Topic}}) -> + ?PRINT("~s -> ~s~n", [Sub, Topic]); print(subscription, {Sub, Topic}) -> ?PRINT("~s -> ~s~n", [Sub, Topic]). diff --git a/src/emqttd_client.erl b/src/emqttd_client.erl index 12bd2942a..6f15bdf8c 100644 --- a/src/emqttd_client.erl +++ b/src/emqttd_client.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -92,7 +92,7 @@ init([OriginConn, MqttEnv]) -> SendFun = fun(Packet) -> Data = emqttd_serializer:serialize(Packet), ?LOG(debug, "SEND ~p", [Data], #client_state{connname = ConnName}), - emqttd_metrics:inc('bytes/sent', size(Data)), + emqttd_metrics:inc('bytes/sent', iolist_size(Data)), try Connection:async_send(Data) of true -> ok catch @@ -184,7 +184,7 @@ handle_info(activate_sock, State) -> hibernate(run_socket(State#client_state{conn_state = running})); handle_info({inet_async, _Sock, _Ref, {ok, Data}}, State) -> - Size = size(Data), + Size = iolist_size(Data), ?LOG(debug, "RECV ~p", [Data], State), emqttd_metrics:inc('bytes/received', Size), received(Data, rate_limit(Size, State#client_state{await_recv = false})); diff --git a/src/emqttd_cluster.erl b/src/emqttd_cluster.erl index 834de2d71..7c83c079c 100644 --- a/src/emqttd_cluster.erl +++ b/src/emqttd_cluster.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -77,8 +77,10 @@ remove(Node) -> ok -> rpc:call(Node, ?MODULE, reboot, []); Error -> Error end; - Error -> - {error, Error} + {badrpc, nodedown} -> + emqttd_mnesia:remove_from_cluster(Node); + {badrpc, Reason} -> + {error, Reason} end. %% @doc Cluster status diff --git a/src/emqttd_cm.erl b/src/emqttd_cm.erl index da98dedd6..6b40a480f 100644 --- a/src/emqttd_cm.erl +++ b/src/emqttd_cm.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_cm_sup.erl b/src/emqttd_cm_sup.erl index 0def00005..dfa623cc3 100644 --- a/src/emqttd_cm_sup.erl +++ b/src/emqttd_cm_sup.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_ctl.erl b/src/emqttd_ctl.erl index 1cd5d3055..c0b7dcf70 100644 --- a/src/emqttd_ctl.erl +++ b/src/emqttd_ctl.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_gen_mod.erl b/src/emqttd_gen_mod.erl index 043c6e177..b201f7bdd 100644 --- a/src/emqttd_gen_mod.erl +++ b/src/emqttd_gen_mod.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_guid.erl b/src/emqttd_guid.erl index 03a4e6904..a4c2d1ea4 100644 --- a/src/emqttd_guid.erl +++ b/src/emqttd_guid.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_http.erl b/src/emqttd_http.erl index 2f1d32a44..69b9f827a 100644 --- a/src/emqttd_http.erl +++ b/src/emqttd_http.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ handle_request('GET', "/status", Req) -> handle_request('POST', "/mqtt/publish", Req) -> case authorized(Req) of true -> http_publish(Req); - false -> Req:respond({401, [], <<"Fobbiden">>}) + false -> Req:respond({401, [], <<"Unauthorized">>}) end; %%-------------------------------------------------------------------- diff --git a/src/emqttd_keepalive.erl b/src/emqttd_keepalive.erl index 0e79622c4..54a4d20e5 100644 --- a/src/emqttd_keepalive.erl +++ b/src/emqttd_keepalive.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_message.erl b/src/emqttd_message.erl index 7dfc4fdc6..ec4a02479 100644 --- a/src/emqttd_message.erl +++ b/src/emqttd_message.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_metrics.erl b/src/emqttd_metrics.erl index 651e5037a..6f7a53f5a 100644 --- a/src/emqttd_metrics.erl +++ b/src/emqttd_metrics.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_mnesia.erl b/src/emqttd_mnesia.erl index 4b58d88d1..52dca1d1b 100644 --- a/src/emqttd_mnesia.erl +++ b/src/emqttd_mnesia.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -187,8 +187,8 @@ remove_from_cluster(Node) when Node =/= node() -> ensure_ok(del_schema_copy(Node)), ensure_ok(rpc:call(Node, ?MODULE, delete_schema, [])); {true, false} -> - ensure_ok(del_schema_copy(Node)), - ensure_ok(rpc:call(Node, ?MODULE, delete_schema, [])); + ensure_ok(del_schema_copy(Node)); + %ensure_ok(rpc:call(Node, ?MODULE, delete_schema, [])); {false, _} -> {error, node_not_in_cluster} end. diff --git a/src/emqttd_mod_sup.erl b/src/emqttd_mod_sup.erl index a0f3cb9d3..57b13bc37 100644 --- a/src/emqttd_mod_sup.erl +++ b/src/emqttd_mod_sup.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_mqueue.erl b/src/emqttd_mqueue.erl index a554c9c83..53f37206f 100644 --- a/src/emqttd_mqueue.erl +++ b/src/emqttd_mqueue.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_net.erl b/src/emqttd_net.erl index a57e4a6ec..8278e1f74 100644 --- a/src/emqttd_net.erl +++ b/src/emqttd_net.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_node.erl b/src/emqttd_node.erl index 0b492253f..e48f71fae 100644 --- a/src/emqttd_node.erl +++ b/src/emqttd_node.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_opts.erl b/src/emqttd_opts.erl index b2250bad6..8f5f3fea5 100644 --- a/src/emqttd_opts.erl +++ b/src/emqttd_opts.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_packet.erl b/src/emqttd_packet.erl index 618b6730b..38de31fe0 100644 --- a/src/emqttd_packet.erl +++ b/src/emqttd_packet.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_parser.erl b/src/emqttd_parser.erl index 139c5c1fb..d6c09c42e 100644 --- a/src/emqttd_parser.erl +++ b/src/emqttd_parser.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_plugins.erl b/src/emqttd_plugins.erl index 0657b7799..78b543440 100644 --- a/src/emqttd_plugins.erl +++ b/src/emqttd_plugins.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_pool_sup.erl b/src/emqttd_pool_sup.erl index b47199cb0..e06d09e8f 100644 --- a/src/emqttd_pool_sup.erl +++ b/src/emqttd_pool_sup.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_pooler.erl b/src/emqttd_pooler.erl index a028b0046..2701c470e 100644 --- a/src/emqttd_pooler.erl +++ b/src/emqttd_pooler.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_protocol.erl b/src/emqttd_protocol.erl index 038d30b91..e892c6158 100644 --- a/src/emqttd_protocol.erl +++ b/src/emqttd_protocol.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_pubsub.erl b/src/emqttd_pubsub.erl index f4d6859a4..83a080ff6 100644 --- a/src/emqttd_pubsub.erl +++ b/src/emqttd_pubsub.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_pubsub_sup.erl b/src/emqttd_pubsub_sup.erl index 988dc6553..882fce57c 100644 --- a/src/emqttd_pubsub_sup.erl +++ b/src/emqttd_pubsub_sup.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_router.erl b/src/emqttd_router.erl index bcbbb42e8..e0e3962a2 100644 --- a/src/emqttd_router.erl +++ b/src/emqttd_router.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -284,11 +284,11 @@ code_change(_OldVsn, State, _Extra) -> clean_routes_(Node) -> Pattern = #mqtt_route{_ = '_', node = Node}, Clean = fun() -> - [mnesia:delete_object(route, R, write) || - R <- mnesia:match_object(route, Pattern, write)] + [mnesia:delete_object(mqtt_route, R, write) || + R <- mnesia:match_object(mqtt_route, Pattern, write)] end, mnesia:transaction(Clean). update_stats_() -> - emqttd_stats:setstats('routes/count', 'routes/max', mnesia:table_info(route, size)). + emqttd_stats:setstats('routes/count', 'routes/max', mnesia:table_info(mqtt_route, size)). diff --git a/src/emqttd_serializer.erl b/src/emqttd_serializer.erl index 00573067f..f08ed7eef 100644 --- a/src/emqttd_serializer.erl +++ b/src/emqttd_serializer.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_server.erl b/src/emqttd_server.erl index 83903736e..f21bd5d4b 100644 --- a/src/emqttd_server.erl +++ b/src/emqttd_server.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_session.erl b/src/emqttd_session.erl index f53f363a4..a73503479 100644 --- a/src/emqttd_session.erl +++ b/src/emqttd_session.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -332,10 +332,14 @@ handle_cast({unsubscribe, TopicTable}, Session = #session{client_id = Client end, Subscriptions, TopicTable), hibernate(Session#session{subscriptions = Subscriptions1}); -handle_cast({destroy, ClientId}, Session = #session{client_id = ClientId}) -> +handle_cast({destroy, ClientId}, Session = #session{client_id = ClientId, client_pid = undefined}) -> ?LOG(warning, "destroyed", [], Session), shutdown(destroy, Session); +handle_cast({destroy, ClientId}, Session = #session{client_id = ClientId, client_pid = OldClientPid}) -> + ?LOG(warning, "kickout ~p", [OldClientPid], Session), + shutdown(conflict, Session); + handle_cast({resume, ClientId, ClientPid}, Session = #session{client_id = ClientId, client_pid = OldClientPid, clean_sess = CleanSess, diff --git a/src/emqttd_session_sup.erl b/src/emqttd_session_sup.erl index 394cb84d0..88766b11a 100644 --- a/src/emqttd_session_sup.erl +++ b/src/emqttd_session_sup.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_sm.erl b/src/emqttd_sm.erl index 3a978b3fd..704242b2d 100644 --- a/src/emqttd_sm.erl +++ b/src/emqttd_sm.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_sm_helper.erl b/src/emqttd_sm_helper.erl index aa6a7e365..97b356c8d 100644 --- a/src/emqttd_sm_helper.erl +++ b/src/emqttd_sm_helper.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_sm_sup.erl b/src/emqttd_sm_sup.erl index 1935bcfde..c43f89f80 100644 --- a/src/emqttd_sm_sup.erl +++ b/src/emqttd_sm_sup.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_stats.erl b/src/emqttd_stats.erl index 9ffc08299..cae57207f 100644 --- a/src/emqttd_stats.erl +++ b/src/emqttd_stats.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_sup.erl b/src/emqttd_sup.erl index 709f30adb..59ffde2ea 100644 --- a/src/emqttd_sup.erl +++ b/src/emqttd_sup.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_sysmon.erl b/src/emqttd_sysmon.erl index 43db85de6..7c338a842 100644 --- a/src/emqttd_sysmon.erl +++ b/src/emqttd_sysmon.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_sysmon_sup.erl b/src/emqttd_sysmon_sup.erl index 9ba73b41e..0131c42db 100644 --- a/src/emqttd_sysmon_sup.erl +++ b/src/emqttd_sysmon_sup.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_time.erl b/src/emqttd_time.erl index 0ade04f6f..49cf4965c 100644 --- a/src/emqttd_time.erl +++ b/src/emqttd_time.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_topic.erl b/src/emqttd_topic.erl index 2a198c2e1..0afeacae8 100644 --- a/src/emqttd_topic.erl +++ b/src/emqttd_topic.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_trace.erl b/src/emqttd_trace.erl index ad938c502..069f44937 100644 --- a/src/emqttd_trace.erl +++ b/src/emqttd_trace.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_trace_sup.erl b/src/emqttd_trace_sup.erl index f0402a257..22736b1a2 100644 --- a/src/emqttd_trace_sup.erl +++ b/src/emqttd_trace_sup.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_trie.erl b/src/emqttd_trie.erl index 7266ea4b6..23bb40bcf 100644 --- a/src/emqttd_trie.erl +++ b/src/emqttd_trie.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_vm.erl b/src/emqttd_vm.erl index bdc6cef40..abf4d3b78 100644 --- a/src/emqttd_vm.erl +++ b/src/emqttd_vm.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_ws.erl b/src/emqttd_ws.erl index 58cb6dc43..a5b3b344f 100644 --- a/src/emqttd_ws.erl +++ b/src/emqttd_ws.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -55,6 +55,7 @@ ws_loop([<<>>], State, _ReplyChannel) -> ws_loop(Data, State = #wsocket_state{peer = Peer, client_pid = ClientPid, parser_fun = ParserFun}, ReplyChannel) -> ?WSLOG(debug, Peer, "RECV ~p", [Data]), + emqttd_metrics:inc('bytes/received', iolist_size(Data)), case catch ParserFun(iolist_to_binary(Data)) of {more, NewParser} -> State#wsocket_state{parser_fun = NewParser}; diff --git a/src/emqttd_ws_client.erl b/src/emqttd_ws_client.erl index 3ea9cdbdd..bd416fa27 100644 --- a/src/emqttd_ws_client.erl +++ b/src/emqttd_ws_client.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -62,6 +62,7 @@ unsubscribe(CPid, Topics) -> %%-------------------------------------------------------------------- init([MqttEnv, WsPid, Req, ReplyChannel]) -> + process_flag(trap_exit, true), true = link(WsPid), {ok, Peername} = Req:get(peername), Headers = mochiweb_headers:to_list( @@ -69,7 +70,7 @@ init([MqttEnv, WsPid, Req, ReplyChannel]) -> %% SendFun = fun(Payload) -> ReplyChannel({binary, Payload}) end, SendFun = fun(Packet) -> Data = emqttd_serializer:serialize(Packet), - emqttd_metrics:inc('bytes/sent', size(Data)), + emqttd_metrics:inc('bytes/sent', iolist_size(Data)), ReplyChannel({binary, Data}) end, ProtoState = emqttd_protocol:init(Peername, SendFun, @@ -107,6 +108,7 @@ handle_cast({unsubscribe, Topics}, State) -> end, State); handle_cast({received, Packet}, State = #wsclient_state{peer = Peer, proto_state = ProtoState}) -> + emqttd_metrics:received(Packet), case emqttd_protocol:received(Packet, ProtoState) of {ok, ProtoState1} -> noreply(State#wsclient_state{proto_state = ProtoState1}); @@ -170,6 +172,13 @@ handle_info({keepalive, check}, State = #wsclient_state{peer = Peer, shutdown(keepalive_error, State) end; +handle_info({'EXIT', WsPid, normal}, State = #wsclient_state{ws_pid = WsPid}) -> + stop(normal, State); + +handle_info({'EXIT', WsPid, Reason}, State = #wsclient_state{peer = Peer, ws_pid = WsPid}) -> + ?WSLOG(error, Peer, "shutdown: ~p",[Reason]), + shutdown(Reason, State); + handle_info(Info, State = #wsclient_state{peer = Peer}) -> ?WSLOG(critical, Peer, "Unexpected Info: ~p", [Info]), noreply(State). diff --git a/src/emqttd_ws_client_sup.erl b/src/emqttd_ws_client_sup.erl index 3af715337..d01055115 100644 --- a/src/emqttd_ws_client_sup.erl +++ b/src/emqttd_ws_client_sup.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/lager_emqtt_backend.erl b/src/lager_emqtt_backend.erl index c98e87de9..214182b8d 100644 --- a/src/lager_emqtt_backend.erl +++ b/src/lager_emqtt_backend.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/test/emqttd_SUITE.erl b/test/emqttd_SUITE.erl index aeed5051f..a7ab2fb5f 100644 --- a/test/emqttd_SUITE.erl +++ b/test/emqttd_SUITE.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -26,25 +26,34 @@ -define(CONTENT_TYPE, "application/x-www-form-urlencoded"). +-define(MQTT_SSL_TWOWAY, [{cacertfile, "certs/cacert.pem"}, + {verify, verify_peer}, + {fail_if_no_peer_cert, true}]). + +-define(MQTT_SSL_CLIENT, [{keyfile, "certs/client-key.pem"}, + {cacertfile, "certs/cacert.pem"}, + {certfile, "certs/client-cert.pem"}]). + + all() -> [{group, protocol}, {group, pubsub}, {group, router}, {group, session}, - %%{group, retainer}, {group, broker}, {group, metrics}, {group, stats}, {group, hook}, {group, http}, {group, cluster}, - %%{group, backend}, {group, alarms}, {group, cli}]. groups() -> [{protocol, [sequence], - [mqtt_connect]}, + [mqtt_connect, + mqtt_ssl_oneway, + mqtt_ssl_twoway]}, {pubsub, [sequence], [subscribe_unsubscribe, publish, pubsub, @@ -66,8 +75,6 @@ groups() -> {hook, [sequence], [add_delete_hook, run_hooks]}, - {backend, [sequence], - []}, {http, [sequence], [request_status, request_publish @@ -101,9 +108,11 @@ groups() -> init_per_suite(Config) -> application:start(lager), DataDir = proplists:get_value(data_dir, Config), - peg_com(DataDir), - start_apps(emqttd, DataDir), - Config. + NewConfig = emqttd_config(DataDir), + Vals = change_opts(ssl_oneway, DataDir, proplists:get_value(emqttd, NewConfig)), + [application:set_env(emqttd, Par, Value) || {Par, Value} <- Vals], + application:ensure_all_started(emqttd), + [{config, NewConfig} | Config]. end_per_suite(_Config) -> application:stop(emqttd), @@ -129,6 +138,48 @@ connect_broker_(Packet, RecvSize) -> gen_tcp:close(Sock), Data. +mqtt_ssl_oneway(_) -> + {ok, SslOneWay} = emqttc:start_link([{host, "localhost"}, + {port, 8883}, + {client_id, <<"ssloneway">>}, ssl]), + timer:sleep(10), + emqttc:subscribe(SslOneWay, <<"topic">>, qos1), + {ok, Pub} = emqttc:start_link([{host, "localhost"}, + {client_id, <<"pub">>}]), + emqttc:publish(Pub, <<"topic">>, <<"SSL oneWay test">>, [{qos, 1}]), + timer:sleep(10), + receive {publish, _Topic, RM} -> + ?assertEqual(<<"SSL oneWay test">>, RM) + after 1000 -> false + end, + emqttc:disconnect(SslOneWay), + emqttc:disconnect(Pub). + +mqtt_ssl_twoway(Config) -> + emqttd_cluster:prepare(), + DataDir = proplists:get_value(data_dir, Config), + EmqConfig = proplists:get_value(config, Config), + Vals = change_opts(ssl_twoway, DataDir, proplists:get_value(emqttd, EmqConfig)), + [application:set_env(emqttd, Par, Value) || {Par, Value} <- Vals], + emqttd_cluster:reboot(), + ClientSSl = [{Key, filename:join([DataDir, File])} || + {Key, File} <- ?MQTT_SSL_CLIENT ], + {ok, SslTwoWay} = emqttc:start_link([{host, "localhost"}, + {port, 8883}, + {client_id, <<"ssltwoway">>}, + {ssl, ClientSSl}]), + {ok, Sub} = emqttc:start_link([{host, "localhost"}, + {client_id, <<"sub">>}]), + emqttc:subscribe(Sub, <<"topic">>, qos1), + emqttc:publish(SslTwoWay, <<"topic">>, <<"ssl client pub message">>, [{qos, 1}]), + timer:sleep(10), + receive {publish, _Topic, RM} -> + ?assertEqual(<<"ssl client pub message">>, RM) + after 1000 -> false + end, + emqttc:disconnect(SslTwoWay), + emqttc:disconnect(Sub). + %%-------------------------------------------------------------------- %% PubSub Test %%-------------------------------------------------------------------- @@ -480,7 +531,7 @@ cluster_node_down(_) -> [<<"#">>, <<"a/b/c">>] = [Topic || #mqtt_route{topic = Topic} <- Routes], slave:stop(Z), timer:sleep(1000), - Routes = lists:sort(emqttd_router:match(<<"a/b/c">>)). + [] = lists:sort(emqttd_router:match(<<"a/b/c">>)). set_alarms(_) -> AlarmTest = #mqtt_alarm{id = <<"1">>, severity = error, title="alarm title", summary="alarm summary"}, @@ -593,31 +644,34 @@ slave(node, Node) -> {ok, N} = slave:start(host(), Node, "-pa ../../ebin -pa ../../deps/*/ebin"), N. -start_apps(App, DataDir) -> - Schema = cuttlefish_schema:files([filename:join([DataDir, atom_to_list(App) ++ ".schema"])]), - Conf = conf_parse:file(filename:join([DataDir, atom_to_list(App) ++ ".conf"])), - NewConfig = cuttlefish_generator:map(Schema, Conf), - Vals = proplists:get_value(App, NewConfig), - [application:set_env(App, Par, Value) || {Par, Value} <- Vals], - application:ensure_all_started(App). - -peg_com(DataDir) -> - ParsePeg = file2(3, DataDir, "conf_parse.peg"), - neotoma:file(ParsePeg), - ParseErl = file2(3, DataDir, "conf_parse.erl"), - compile:file(ParseErl, []), - - DurationPeg = file2(3, DataDir, "cuttlefish_duration_parse.peg"), - neotoma:file(DurationPeg), - DurationErl = file2(3, DataDir, "cuttlefish_duration_parse.erl"), - compile:file(DurationErl, []). - - -file2(Times, Dir, FileName) when Times < 1 -> - filename:join([Dir, "deps", "cuttlefish","src", FileName]); - -file2(Times, Dir, FileName) -> - Dir1 = filename:dirname(Dir), - file2(Times - 1, Dir1, FileName). - +emqttd_config(DataDir) -> + Schema = cuttlefish_schema:files([filename:join([DataDir, "emqttd.schema"])]), + Conf = conf_parse:file(filename:join([DataDir, "emqttd.conf"])), + cuttlefish_generator:map(Schema, Conf). +change_opts(SslType, DataDir, Vals) -> + Listeners = proplists:get_value(listeners, Vals), + NewListeners = + lists:foldl(fun({Protocol, Port, Opts} = Listener, Acc) -> + case Protocol of + ssl -> + SslOpts = proplists:get_value(ssl, Opts), + Keyfile = filename:join([DataDir, proplists:get_value(keyfile, SslOpts)]), + Certfile = filename:join([DataDir, proplists:get_value(certfile, SslOpts)]), + TupleList1 = lists:keyreplace(keyfile, 1, SslOpts, {keyfile, Keyfile}), + TupleList2 = lists:keyreplace(certfile, 1, TupleList1, {certfile, Certfile}), + TupleList3 = + case SslType of + ssl_twoway-> + CAfile = filename:join([DataDir, proplists:get_value(cacertfile, ?MQTT_SSL_TWOWAY)]), + MutSslList = lists:keyreplace(cacertfile, 1, ?MQTT_SSL_TWOWAY, {cacertfile, CAfile}), + lists:merge(TupleList2, MutSslList); + _ -> + TupleList2 + end, + [{Protocol, Port, [{ssl, TupleList3}]} | Acc]; + _ -> + [Listener | Acc] + end + end, [], Listeners), + lists:keyreplace(listeners, 1, Vals, {listeners, NewListeners}). diff --git a/test/emqttd_SUITE_data/certs/cacert.pem b/test/emqttd_SUITE_data/certs/cacert.pem new file mode 100644 index 000000000..ca4948ed9 --- /dev/null +++ b/test/emqttd_SUITE_data/certs/cacert.pem @@ -0,0 +1,17 @@ +-----BEGIN CERTIFICATE----- +MIICxjCCAa6gAwIBAgIJAPhU8tv3KMe/MA0GCSqGSIb3DQEBCwUAMBMxETAPBgNV +BAMMCE15VGVzdENBMB4XDTE2MTAzMTA3MTU0NVoXDTE3MTAzMTA3MTU0NVowEzER +MA8GA1UEAwwITXlUZXN0Q0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB +AQCtPcDnmjiVl7ScDhYvGaW+PUgfp7P5cM39mnrW6fkxhA0tgunWpWlYVKbcuh5y +4bTNYrOQpcFO3Zg62tva4XEL8O1huqTlGsAeysZ3vWE4/8NGN/3wZy0TKDvwiwOB +tbS3C5wcRQZohExL6yEL4XzDGk44x2mIs8/NzeG7Zycqybh9tsCJiHbLiTxnLa24 +v5USOtlvWye0hA0yUUqc2k7tKVmIMT4A4ulMb2sDVRrSLjyFDTI0c8grlPLfKbG8 +gpYLsHn9aAjqviyvmJdRLxwauqn+ghNWn1TyZwgAUxpoTtWeC0ilzEt18RP8vZjm +eCbEP4qQDDvSCdLrie5CezyxAgMBAAGjHTAbMAwGA1UdEwQFMAMBAf8wCwYDVR0P +BAQDAgEGMA0GCSqGSIb3DQEBCwUAA4IBAQBJ/I/QJjU+mgkIaaHImFcIYFrfBirC +vDiWo2W+zRh7CbcSf+jsksI99d230ixSDY36CPLKZeZhELST7xWKEELKbPdNbtOO +EM10+XteLSXKVNGXfrEbW973eum3FGLobMA9OcH6+qDaf08pibe7kuv10aAgSs/I +0Qg5H/UTAKQJKO9hhOgERM/FettuF+WGJaaZZZb9Y2YYBNRf/GtM8KHCjpCX9+XD +kdeQGO8Hn10H9tOmggyfdIpsunBcs2/6/exCp8RPBWurN2GSW2RcnS5xVL0r+SVW +VOhSDy1JwnNPczpqkqE74qAbAah0dTJFcFWzeGLVk7Kp+2pissAiU3gg +-----END CERTIFICATE----- diff --git a/test/emqttd_SUITE_data/certs/cert.pem b/test/emqttd_SUITE_data/certs/cert.pem new file mode 100644 index 000000000..58aa2c4ef --- /dev/null +++ b/test/emqttd_SUITE_data/certs/cert.pem @@ -0,0 +1,18 @@ +-----BEGIN CERTIFICATE----- +MIIC9jCCAd6gAwIBAgIBATANBgkqhkiG9w0BAQsFADATMREwDwYDVQQDDAhNeVRl +c3RDQTAeFw0xNjEwMzEwNzE1NDVaFw0xNzEwMzEwNzE1NDVaMDkxJjAkBgNVBAMT +HWRlbmdoYWlndWlkZU1hY0Jvb2stQWlyLmxvY2FsMQ8wDQYDVQQKEwZzZXJ2ZXIw +ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC4Ena4vgWrzwUB0hGW1v0v +K986FhU5ZdYz5H5MGonfWwv89nR2DlftSDXEvKFyc2MT81GGm16VJv3mVpQJLuKA +xLBLY7a1zSrJdugXWy+mgJJTPW6KjTY4jPtfCl6x/yVr8YclVa8XO0JFzOme2LMV +Ylc/ixVEa66UpxRNrg5yWHS26KcB1lE3GLERoRBKF7nsyGqGY4X9TypBwglCVoqK +3dKVGwCvFur+oPnt/C5pwR6UmUV/Ppf1EaRD7Po+xcyJSeCvszG3FH4iHsDHnjLe +DR6lxouvMCb+aKJi9d0xowOjhbKoFMF179t4SVnptQeq+U6ui3cPKUjia7Zh1tZT +AgMBAAGjLzAtMAkGA1UdEwQCMAAwCwYDVR0PBAQDAgUgMBMGA1UdJQQMMAoGCCsG +AQUFBwMBMA0GCSqGSIb3DQEBCwUAA4IBAQB2jlDPiZfP/whsvvFn43g37QMwX5ST +Z5OpmEFnFjAH3ec0PPqPrKYEu00q5wEC+8L6uVH8FHOFf11JLH4wl11/C/mvE92D +qZtGG8KCnG2+rk5OJPGX+28Z+OnCZlXOjQ8qd2x5KtIW50JuXJ3cbDRHtF/TVanm +Exu+TCBeToNwbcU2sfQnbljkUTj4idUFz0pq3uvw3dA4R1J2foungPAYXSWcVhtb +RYtG8epIvkAyyUE5nY3kC05AUml6gSZkrJiYM5I1IJTX1lQ7Pv2yxRBZUtTx33rP +ccnsW6tbHTDBG8UDHx4LKHErdWFgCJWI81EUEcTip9g2zCOGTWKnpz+z +-----END CERTIFICATE----- diff --git a/test/emqttd_SUITE_data/certs/client-cert.pem b/test/emqttd_SUITE_data/certs/client-cert.pem new file mode 100644 index 000000000..e1690d9aa --- /dev/null +++ b/test/emqttd_SUITE_data/certs/client-cert.pem @@ -0,0 +1,18 @@ +-----BEGIN CERTIFICATE----- +MIIC9jCCAd6gAwIBAgIBAjANBgkqhkiG9w0BAQsFADATMREwDwYDVQQDDAhNeVRl +c3RDQTAeFw0xNjEwMzEwNzE1NDZaFw0xNzEwMzEwNzE1NDZaMDkxJjAkBgNVBAMT +HWRlbmdoYWlndWlkZU1hY0Jvb2stQWlyLmxvY2FsMQ8wDQYDVQQKEwZjbGllbnQw +ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCmPMkieMtJO4PGIQG30uxI +SEoRJoF2w0ufFhZGYCEaqFlHaSoc6nTiCUmnxadDpjkNBs4R6RDfM9zPJ0QdgSFO +OJsWgQEHym/EQTcEx11+/2NDZWMJyZdpWZlU57SwHfWDwYa2XFX1bV+pAvhB8cli +wCkygTwp1cZcwQpb8TfZySy8r5mwrWq2nhCQPtYqMxjNjpR/UeeZzt+Uh3CEXQ8h +omjGinDXnnGwrYwBEP9G6fzTvyCWTyrsWC1Q37oAMzbkwFRoIBSAQWXBv9hgI08s +IBYvXnRGKWOJZGxAP4a4TvpFS+nqi+fFVn4ktUfcH3PoSMh7PKavrFT2hQaryLt1 +AgMBAAGjLzAtMAkGA1UdEwQCMAAwCwYDVR0PBAQDAgeAMBMGA1UdJQQMMAoGCCsG +AQUFBwMCMA0GCSqGSIb3DQEBCwUAA4IBAQAeimI8AQBFWiE9/Nf/0radux355mod +5vPLbKn6I6nzb/sS/Ug8SMoFnkhncwj+XOgTSliUyWcwOB11UDVJbUIkB/x+Qo3w +hvrATTdby2WdFNQvH4X7PmP8asDDN7ZxoLyRmuhjL4avJ3giwRcuQK4cB35b+Lb2 +p1e7hW81RaV7OEc0o4/vJgPvv9N7wvUuipwJns6PrN7VDn99lT8zWrt2pQ06e2mk +jDuXulVpiUtLHJhTnABkCaKiHWCYAFfMjFeRb3gUXKqShzOyDSGWY91YMID/HE4r +sVLm2mD1zurue8EmYtQQ6uiJIW9SzvshMHG6EA5QWA1ytoalfePbvf+c +-----END CERTIFICATE----- diff --git a/test/emqttd_SUITE_data/certs/client-key.pem b/test/emqttd_SUITE_data/certs/client-key.pem new file mode 100644 index 000000000..74cf487cb --- /dev/null +++ b/test/emqttd_SUITE_data/certs/client-key.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpQIBAAKCAQEApjzJInjLSTuDxiEBt9LsSEhKESaBdsNLnxYWRmAhGqhZR2kq +HOp04glJp8WnQ6Y5DQbOEekQ3zPczydEHYEhTjibFoEBB8pvxEE3BMddfv9jQ2Vj +CcmXaVmZVOe0sB31g8GGtlxV9W1fqQL4QfHJYsApMoE8KdXGXMEKW/E32cksvK+Z +sK1qtp4QkD7WKjMYzY6Uf1Hnmc7flIdwhF0PIaJoxopw155xsK2MARD/Run8078g +lk8q7FgtUN+6ADM25MBUaCAUgEFlwb/YYCNPLCAWL150RiljiWRsQD+GuE76RUvp +6ovnxVZ+JLVH3B9z6EjIezymr6xU9oUGq8i7dQIDAQABAoIBAFkHEMjPXD96ChZf +suXZpgUIAfKxZoBOEv+9+mvyK4h1RGsEHTOjNLmhM7sQFYYbTU52qIHbCdgflE+0 +vbv3XfjgQ96HdB/SAI1gR7DdfGr5JxX/BE1HkzkubPmVpaT0RnoreJPNW5O24ZZI +KuBWNv4V33pWz/uvqy4djAi1ZK3TPDhn9cVCMwV/ISCPlofrNDB/4ZNOMeaQgiR+ +sGqv+Q0ok2ao7Y04QHPh5i+5o+5oBoiJAO/49q9uPdpO181/8H71jll0QL+h5Off +nyWkAAOcgEeX9T4ZnfTUivGdSwB/Y+LS97Ozdr6kp5Fdk8WdDn0DL4fHRrnJ4IJD +EIAn/sECgYEA2oOCRBMccr49wbu+cKlkICt/4ARzJWKysdLlK0tYQknkDK1bzoHO +9JerRJL4E9bKp8zNlobfP1hWV0TFpwYsK3RvZoLvCwaSHeqUCZ4wQvKrWP1FieJ2 +5kjO5iMvXiy/kNHdTEXsj0x6RKuUSVgzNIuILvCCQ9Z7JVa/3NWS1SkCgYEAwsF0 +TWxCjryQv8y4mFSUlyF+y+ntnWAvpe/1Wv3+dNdhsccUfcq3zPMuLEj5DEoIvlTy +jLkFLVJ468Ou7S1oSVetVT3wWoLP2eFDEU/sYjjPdf4IMSO1jWIPLC3WV7zsFb62 +jwG2en1qfz8AxrVl+zj4lWCbgA9Soi41NMiCUW0CgYEAokQEST8T4hVp0OL1Qb5Y +bxc+Z4GGbF3Fqw2cRrE1wkwSwGNACLMWl0XF1i95b2oSpdcNWFmhkO2teDLGwAhy +ZnaZfzt9/ecMPJEFC7tfxWdlXLj/mawFdW7dzcKVG08JlqZxuoE2cRduuG3duTV5 +GO0A3TKW2X99hTXNVlV3KzkCgYEAsaE8cHkzY3h9FVKlctqCBC3atiWQQZ+/Fbv8 +rpdHBE6Fnl4TRIAmj9mk3WNZM2o6+04DQ3JlVGcKPw7ldxGZMnuzbjHmDMeOyAx6 +3UlmMlfacKXX1unY5zDu4b6U5sU7FsIxQ9GuG55UCebu0E4Wy8G0iJnqeix/k8hN +Yu0WXykCgYEAo0kIm7sh9j0+r419Lo2kT4zlzFlNdJEa4+lFVISRqouDuhUO8VFE +/ZpGRcqIM7dH6iBM2Htasf7l/hyWKzDEvWCEpa4icicFYAJ92AgK7UBWbNbhueof +PyVx5G2o7amvyZNtJYUo4TpJ9eH5YbsBRBqWCJcBUAfrItrprxB1LMs= +-----END RSA PRIVATE KEY----- diff --git a/test/emqttd_SUITE_data/certs/key.pem b/test/emqttd_SUITE_data/certs/key.pem new file mode 100644 index 000000000..7001093ef --- /dev/null +++ b/test/emqttd_SUITE_data/certs/key.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEAuBJ2uL4Fq88FAdIRltb9LyvfOhYVOWXWM+R+TBqJ31sL/PZ0 +dg5X7Ug1xLyhcnNjE/NRhptelSb95laUCS7igMSwS2O2tc0qyXboF1svpoCSUz1u +io02OIz7Xwpesf8la/GHJVWvFztCRczpntizFWJXP4sVRGuulKcUTa4Oclh0tuin +AdZRNxixEaEQShe57MhqhmOF/U8qQcIJQlaKit3SlRsArxbq/qD57fwuacEelJlF +fz6X9RGkQ+z6PsXMiUngr7MxtxR+Ih7Ax54y3g0epcaLrzAm/miiYvXdMaMDo4Wy +qBTBde/beElZ6bUHqvlOrot3DylI4mu2YdbWUwIDAQABAoIBADXYWNhT5c7LYTiW +HcUVIL0CxWr1eMHwk0dcyME0Zi5rMMePxKOgMIJdxDTHxSZ4sHvuimOo4XMaE92k +Z+uDxohKgROcmJ735FNIsD3c08SOCb/F0adABaNnQkUcAHVrIKRB4/m85doS4KEQ +fyqTU1enC8Svx8nbAhfEBEFw8BLsZD9UnQAEAU5W9S5aKPHNrYRDz5UE0ZP28ixC +4PtCew96uCqA0u+xZnWCGawF27FD9P88pcYSJqebF1iFYkXrAwdhAbqewHOqQJXf +KJpbpjflBvZr/oTVZ3GAnnHnZDiusFmCKIHB9dKimHMdTFVIU2ikOeJZLtgXsBjb +Wn3Fa8kCgYEA2fK0t9NPmELw43D7VoCNeUmu6KmLLd7CeRiQ/OkPLKTqrudnUZGi +uMinPFijGTLX3SmByAVOkzMKBQOYF+eB1X24kbRLmL4JKzr04hSqOKqG5gJctC+x +V5qQX7ZxrNxFRiSodILbnQN/z1gwZMfrAU0t0EKIKjZR3lpj8CELv1cCgYEA2DWn +9V6PCZPcHzoFabhb8DJFglUTHk0zINVe97qldvMvn0MgsjgyS2j954nX8ef7uE1O +Cf+9nN709Fu8kEC7/KzWXxP3/O58TfJ6NivCQSr5i0OJLumQMVNrS+u/VG1PaVbS +2oCwP3QFayOxZSj9wq2MARd1JkqzHmi8skZLz2UCgYEAgtnv3En3CLBwFe14SPgH +eGFfrPpVwGV0luXD7sQyQxiEehwecN+iNZTqqxWAXpmi9np8G83r3f6PrnD4+Kka +z0Wa8Yewt3So5paP/chwZnMjaKbUZ64WqET5Fy3fU+wvfyx1IvaJydwW+TK2Y1uP +4Yknz1iSjd1tC7VzOPFuLyMCgYBrTFWKQ98glayMIrNFACVAUvKD98yBITbaeImk +z5AGNDHSC/JR/+mV2wkGuzXb65DUqiisdaqYC13tVwmBXV7tyqiojrRnZcNyu39D +GvxQcw9cuat/CJJyqD97cgeF0qmyUVBa97qAAwgdX51N4sXss0vjzsxosHGsCbZ7 +kr9UsQKBgQCMTtdCeA+uK/OeJtzf4CYZKR9xllQ+P6gCtbQ7WHuLBX/x+ZhvTC0p +qVLVWwFsJ6ivc1f74sy8hZPiePk9fqAqA1JIjDHrof0M3TxRVFvB7dej5XIYVirn +521DyZGfE+N7HA7qW5cGKZT0+UYLVp4gnv88nNKDuS18lafy8JRrfQ== +-----END RSA PRIVATE KEY----- diff --git a/test/emqttd_SUITE_data/emqttd.conf b/test/emqttd_SUITE_data/emqttd.conf index e4434283a..4aaa60eff 100644 --- a/test/emqttd_SUITE_data/emqttd.conf +++ b/test/emqttd_SUITE_data/emqttd.conf @@ -207,8 +207,8 @@ mqtt.listener.ssl.max_clients = 512 ## Configuring SSL Options ## See http://erlang.org/doc/man/ssl.html mqtt.listener.ssl.handshake_timeout = 15 -mqtt.listener.ssl.keyfile = etc/certs/key.pem -mqtt.listener.ssl.certfile = etc/certs/cert.pem +mqtt.listener.ssl.keyfile = certs/key.pem +mqtt.listener.ssl.certfile = certs/cert.pem ## mqtt.listener.ssl.cacertfile = etc/certs/cacert.pem ## mqtt.listener.ssl.verify = verify_peer ## mqtt.listener.ssl.fail_if_no_peer_cert = true diff --git a/test/emqttd_access_SUITE.erl b/test/emqttd_access_SUITE.erl index e127cf601..5ab7e992b 100644 --- a/test/emqttd_access_SUITE.erl +++ b/test/emqttd_access_SUITE.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/test/emqttd_acl_test_mod.erl b/test/emqttd_acl_test_mod.erl index c9ddf057e..196337fa4 100644 --- a/test/emqttd_acl_test_mod.erl +++ b/test/emqttd_acl_test_mod.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/test/emqttd_auth_anonymous_test_mod.erl b/test/emqttd_auth_anonymous_test_mod.erl index 8424b467a..8e93be0bc 100644 --- a/test/emqttd_auth_anonymous_test_mod.erl +++ b/test/emqttd_auth_anonymous_test_mod.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/test/emqttd_auth_dashboard.erl b/test/emqttd_auth_dashboard.erl index d36390a09..0e509c08a 100644 --- a/test/emqttd_auth_dashboard.erl +++ b/test/emqttd_auth_dashboard.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/test/emqttd_lib_SUITE.erl b/test/emqttd_lib_SUITE.erl index 51dd499ba..e51e778f0 100644 --- a/test/emqttd_lib_SUITE.erl +++ b/test/emqttd_lib_SUITE.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/test/emqttd_mod_SUITE.erl b/test/emqttd_mod_SUITE.erl index 9240b8a3f..a258eabe0 100644 --- a/test/emqttd_mod_SUITE.erl +++ b/test/emqttd_mod_SUITE.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2016 Feng Lee . +%% Copyright (c) 2016-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/test/emqttd_mqueue_SUITE.erl b/test/emqttd_mqueue_SUITE.erl index 76ab62044..eaa0ecc68 100644 --- a/test/emqttd_mqueue_SUITE.erl +++ b/test/emqttd_mqueue_SUITE.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/test/emqttd_net_SUITE.erl b/test/emqttd_net_SUITE.erl index 22641c2b2..7d70f4291 100644 --- a/test/emqttd_net_SUITE.erl +++ b/test/emqttd_net_SUITE.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2016 Feng Lee . +%% Copyright (c) 2016-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/test/emqttd_protocol_SUITE.erl b/test/emqttd_protocol_SUITE.erl index 96b969278..49189bb90 100644 --- a/test/emqttd_protocol_SUITE.erl +++ b/test/emqttd_protocol_SUITE.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/test/emqttd_topic_SUITE.erl b/test/emqttd_topic_SUITE.erl index 5692dbb43..f8be7df1a 100644 --- a/test/emqttd_topic_SUITE.erl +++ b/test/emqttd_topic_SUITE.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2016 Feng Lee . +%% Copyright (c) 2016-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/test/emqttd_trie_SUITE.erl b/test/emqttd_trie_SUITE.erl index ceda3abcb..37d247755 100644 --- a/test/emqttd_trie_SUITE.erl +++ b/test/emqttd_trie_SUITE.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/test/emqttd_vm_SUITE.erl b/test/emqttd_vm_SUITE.erl index a26bde4f4..ba56ef97f 100644 --- a/test/emqttd_vm_SUITE.erl +++ b/test/emqttd_vm_SUITE.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2016 Feng Lee . +%% Copyright (c) 2012-2017 Feng Lee . %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License.