Merge branch 'develop' into ws-proxy
This commit is contained in:
commit
707d338b0e
|
@ -30,3 +30,4 @@ _build
|
||||||
.rebar3
|
.rebar3
|
||||||
rebar3.crashdump
|
rebar3.crashdump
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
rebar.config
|
||||||
|
|
|
@ -0,0 +1,455 @@
|
||||||
|
MOZILLA PUBLIC LICENSE
|
||||||
|
Version 1.1
|
||||||
|
|
||||||
|
---------------
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
1.0.1. "Commercial Use" means distribution or otherwise making the
|
||||||
|
Covered Code available to a third party.
|
||||||
|
|
||||||
|
1.1. "Contributor" means each entity that creates or contributes to
|
||||||
|
the creation of Modifications.
|
||||||
|
|
||||||
|
1.2. "Contributor Version" means the combination of the Original
|
||||||
|
Code, prior Modifications used by a Contributor, and the Modifications
|
||||||
|
made by that particular Contributor.
|
||||||
|
|
||||||
|
1.3. "Covered Code" means the Original Code or Modifications or the
|
||||||
|
combination of the Original Code and Modifications, in each case
|
||||||
|
including portions thereof.
|
||||||
|
|
||||||
|
1.4. "Electronic Distribution Mechanism" means a mechanism generally
|
||||||
|
accepted in the software development community for the electronic
|
||||||
|
transfer of data.
|
||||||
|
|
||||||
|
1.5. "Executable" means Covered Code in any form other than Source
|
||||||
|
Code.
|
||||||
|
|
||||||
|
1.6. "Initial Developer" means the individual or entity identified
|
||||||
|
as the Initial Developer in the Source Code notice required by Exhibit
|
||||||
|
A.
|
||||||
|
|
||||||
|
1.7. "Larger Work" means a work which combines Covered Code or
|
||||||
|
portions thereof with code not governed by the terms of this License.
|
||||||
|
|
||||||
|
1.8. "License" means this document.
|
||||||
|
|
||||||
|
1.8.1. "Licensable" means having the right to grant, to the maximum
|
||||||
|
extent possible, whether at the time of the initial grant or
|
||||||
|
subsequently acquired, any and all of the rights conveyed herein.
|
||||||
|
|
||||||
|
1.9. "Modifications" means any addition to or deletion from the
|
||||||
|
substance or structure of either the Original Code or any previous
|
||||||
|
Modifications. When Covered Code is released as a series of files, a
|
||||||
|
Modification is:
|
||||||
|
A. Any addition to or deletion from the contents of a file
|
||||||
|
containing Original Code or previous Modifications.
|
||||||
|
|
||||||
|
B. Any new file that contains any part of the Original Code or
|
||||||
|
previous Modifications.
|
||||||
|
|
||||||
|
1.10. "Original Code" means Source Code of computer software code
|
||||||
|
which is described in the Source Code notice required by Exhibit A as
|
||||||
|
Original Code, and which, at the time of its release under this
|
||||||
|
License is not already Covered Code governed by this License.
|
||||||
|
|
||||||
|
1.10.1. "Patent Claims" means any patent claim(s), now owned or
|
||||||
|
hereafter acquired, including without limitation, method, process,
|
||||||
|
and apparatus claims, in any patent Licensable by grantor.
|
||||||
|
|
||||||
|
1.11. "Source Code" means the preferred form of the Covered Code for
|
||||||
|
making modifications to it, including all modules it contains, plus
|
||||||
|
any associated interface definition files, scripts used to control
|
||||||
|
compilation and installation of an Executable, or source code
|
||||||
|
differential comparisons against either the Original Code or another
|
||||||
|
well known, available Covered Code of the Contributor's choice. The
|
||||||
|
Source Code can be in a compressed or archival form, provided the
|
||||||
|
appropriate decompression or de-archiving software is widely available
|
||||||
|
for no charge.
|
||||||
|
|
||||||
|
1.12. "You" (or "Your") means an individual or a legal entity
|
||||||
|
exercising rights under, and complying with all of the terms of, this
|
||||||
|
License or a future version of this License issued under Section 6.1.
|
||||||
|
For legal entities, "You" includes any entity which controls, is
|
||||||
|
controlled by, or is under common control with You. For purposes of
|
||||||
|
this definition, "control" means (a) the power, direct or indirect,
|
||||||
|
to cause the direction or management of such entity, whether by
|
||||||
|
contract or otherwise, or (b) ownership of more than fifty percent
|
||||||
|
(50%) of the outstanding shares or beneficial ownership of such
|
||||||
|
entity.
|
||||||
|
|
||||||
|
2. Source Code License.
|
||||||
|
|
||||||
|
2.1. The Initial Developer Grant.
|
||||||
|
The Initial Developer hereby grants You a world-wide, royalty-free,
|
||||||
|
non-exclusive license, subject to third party intellectual property
|
||||||
|
claims:
|
||||||
|
(a) under intellectual property rights (other than patent or
|
||||||
|
trademark) Licensable by Initial Developer to use, reproduce,
|
||||||
|
modify, display, perform, sublicense and distribute the Original
|
||||||
|
Code (or portions thereof) with or without Modifications, and/or
|
||||||
|
as part of a Larger Work; and
|
||||||
|
|
||||||
|
(b) under Patents Claims infringed by the making, using or
|
||||||
|
selling of Original Code, to make, have made, use, practice,
|
||||||
|
sell, and offer for sale, and/or otherwise dispose of the
|
||||||
|
Original Code (or portions thereof).
|
||||||
|
|
||||||
|
(c) the licenses granted in this Section 2.1(a) and (b) are
|
||||||
|
effective on the date Initial Developer first distributes
|
||||||
|
Original Code under the terms of this License.
|
||||||
|
|
||||||
|
(d) Notwithstanding Section 2.1(b) above, no patent license is
|
||||||
|
granted: 1) for code that You delete from the Original Code; 2)
|
||||||
|
separate from the Original Code; or 3) for infringements caused
|
||||||
|
by: i) the modification of the Original Code or ii) the
|
||||||
|
combination of the Original Code with other software or devices.
|
||||||
|
|
||||||
|
2.2. Contributor Grant.
|
||||||
|
Subject to third party intellectual property claims, each Contributor
|
||||||
|
hereby grants You a world-wide, royalty-free, non-exclusive license
|
||||||
|
|
||||||
|
(a) under intellectual property rights (other than patent or
|
||||||
|
trademark) Licensable by Contributor, to use, reproduce, modify,
|
||||||
|
display, perform, sublicense and distribute the Modifications
|
||||||
|
created by such Contributor (or portions thereof) either on an
|
||||||
|
unmodified basis, with other Modifications, as Covered Code
|
||||||
|
and/or as part of a Larger Work; and
|
||||||
|
|
||||||
|
(b) under Patent Claims infringed by the making, using, or
|
||||||
|
selling of Modifications made by that Contributor either alone
|
||||||
|
and/or in combination with its Contributor Version (or portions
|
||||||
|
of such combination), to make, use, sell, offer for sale, have
|
||||||
|
made, and/or otherwise dispose of: 1) Modifications made by that
|
||||||
|
Contributor (or portions thereof); and 2) the combination of
|
||||||
|
Modifications made by that Contributor with its Contributor
|
||||||
|
Version (or portions of such combination).
|
||||||
|
|
||||||
|
(c) the licenses granted in Sections 2.2(a) and 2.2(b) are
|
||||||
|
effective on the date Contributor first makes Commercial Use of
|
||||||
|
the Covered Code.
|
||||||
|
|
||||||
|
(d) Notwithstanding Section 2.2(b) above, no patent license is
|
||||||
|
granted: 1) for any code that Contributor has deleted from the
|
||||||
|
Contributor Version; 2) separate from the Contributor Version;
|
||||||
|
3) for infringements caused by: i) third party modifications of
|
||||||
|
Contributor Version or ii) the combination of Modifications made
|
||||||
|
by that Contributor with other software (except as part of the
|
||||||
|
Contributor Version) or other devices; or 4) under Patent Claims
|
||||||
|
infringed by Covered Code in the absence of Modifications made by
|
||||||
|
that Contributor.
|
||||||
|
|
||||||
|
3. Distribution Obligations.
|
||||||
|
|
||||||
|
3.1. Application of License.
|
||||||
|
The Modifications which You create or to which You contribute are
|
||||||
|
governed by the terms of this License, including without limitation
|
||||||
|
Section 2.2. The Source Code version of Covered Code may be
|
||||||
|
distributed only under the terms of this License or a future version
|
||||||
|
of this License released under Section 6.1, and You must include a
|
||||||
|
copy of this License with every copy of the Source Code You
|
||||||
|
distribute. You may not offer or impose any terms on any Source Code
|
||||||
|
version that alters or restricts the applicable version of this
|
||||||
|
License or the recipients' rights hereunder. However, You may include
|
||||||
|
an additional document offering the additional rights described in
|
||||||
|
Section 3.5.
|
||||||
|
|
||||||
|
3.2. Availability of Source Code.
|
||||||
|
Any Modification which You create or to which You contribute must be
|
||||||
|
made available in Source Code form under the terms of this License
|
||||||
|
either on the same media as an Executable version or via an accepted
|
||||||
|
Electronic Distribution Mechanism to anyone to whom you made an
|
||||||
|
Executable version available; and if made available via Electronic
|
||||||
|
Distribution Mechanism, must remain available for at least twelve (12)
|
||||||
|
months after the date it initially became available, or at least six
|
||||||
|
(6) months after a subsequent version of that particular Modification
|
||||||
|
has been made available to such recipients. You are responsible for
|
||||||
|
ensuring that the Source Code version remains available even if the
|
||||||
|
Electronic Distribution Mechanism is maintained by a third party.
|
||||||
|
|
||||||
|
3.3. Description of Modifications.
|
||||||
|
You must cause all Covered Code to which You contribute to contain a
|
||||||
|
file documenting the changes You made to create that Covered Code and
|
||||||
|
the date of any change. You must include a prominent statement that
|
||||||
|
the Modification is derived, directly or indirectly, from Original
|
||||||
|
Code provided by the Initial Developer and including the name of the
|
||||||
|
Initial Developer in (a) the Source Code, and (b) in any notice in an
|
||||||
|
Executable version or related documentation in which You describe the
|
||||||
|
origin or ownership of the Covered Code.
|
||||||
|
|
||||||
|
3.4. Intellectual Property Matters
|
||||||
|
(a) Third Party Claims.
|
||||||
|
If Contributor has knowledge that a license under a third party's
|
||||||
|
intellectual property rights is required to exercise the rights
|
||||||
|
granted by such Contributor under Sections 2.1 or 2.2,
|
||||||
|
Contributor must include a text file with the Source Code
|
||||||
|
distribution titled "LEGAL" which describes the claim and the
|
||||||
|
party making the claim in sufficient detail that a recipient will
|
||||||
|
know whom to contact. If Contributor obtains such knowledge after
|
||||||
|
the Modification is made available as described in Section 3.2,
|
||||||
|
Contributor shall promptly modify the LEGAL file in all copies
|
||||||
|
Contributor makes available thereafter and shall take other steps
|
||||||
|
(such as notifying appropriate mailing lists or newsgroups)
|
||||||
|
reasonably calculated to inform those who received the Covered
|
||||||
|
Code that new knowledge has been obtained.
|
||||||
|
|
||||||
|
(b) Contributor APIs.
|
||||||
|
If Contributor's Modifications include an application programming
|
||||||
|
interface and Contributor has knowledge of patent licenses which
|
||||||
|
are reasonably necessary to implement that API, Contributor must
|
||||||
|
also include this information in the LEGAL file.
|
||||||
|
|
||||||
|
(c) Representations.
|
||||||
|
Contributor represents that, except as disclosed pursuant to
|
||||||
|
Section 3.4(a) above, Contributor believes that Contributor's
|
||||||
|
Modifications are Contributor's original creation(s) and/or
|
||||||
|
Contributor has sufficient rights to grant the rights conveyed by
|
||||||
|
this License.
|
||||||
|
|
||||||
|
3.5. Required Notices.
|
||||||
|
You must duplicate the notice in Exhibit A in each file of the Source
|
||||||
|
Code. If it is not possible to put such notice in a particular Source
|
||||||
|
Code file due to its structure, then You must include such notice in a
|
||||||
|
location (such as a relevant directory) where a user would be likely
|
||||||
|
to look for such a notice. If You created one or more Modification(s)
|
||||||
|
You may add your name as a Contributor to the notice described in
|
||||||
|
Exhibit A. You must also duplicate this License in any documentation
|
||||||
|
for the Source Code where You describe recipients' rights or ownership
|
||||||
|
rights relating to Covered Code. You may choose to offer, and to
|
||||||
|
charge a fee for, warranty, support, indemnity or liability
|
||||||
|
obligations to one or more recipients of Covered Code. However, You
|
||||||
|
may do so only on Your own behalf, and not on behalf of the Initial
|
||||||
|
Developer or any Contributor. You must make it absolutely clear than
|
||||||
|
any such warranty, support, indemnity or liability obligation is
|
||||||
|
offered by You alone, and You hereby agree to indemnify the Initial
|
||||||
|
Developer and every Contributor for any liability incurred by the
|
||||||
|
Initial Developer or such Contributor as a result of warranty,
|
||||||
|
support, indemnity or liability terms You offer.
|
||||||
|
|
||||||
|
3.6. Distribution of Executable Versions.
|
||||||
|
You may distribute Covered Code in Executable form only if the
|
||||||
|
requirements of Section 3.1-3.5 have been met for that Covered Code,
|
||||||
|
and if You include a notice stating that the Source Code version of
|
||||||
|
the Covered Code is available under the terms of this License,
|
||||||
|
including a description of how and where You have fulfilled the
|
||||||
|
obligations of Section 3.2. The notice must be conspicuously included
|
||||||
|
in any notice in an Executable version, related documentation or
|
||||||
|
collateral in which You describe recipients' rights relating to the
|
||||||
|
Covered Code. You may distribute the Executable version of Covered
|
||||||
|
Code or ownership rights under a license of Your choice, which may
|
||||||
|
contain terms different from this License, provided that You are in
|
||||||
|
compliance with the terms of this License and that the license for the
|
||||||
|
Executable version does not attempt to limit or alter the recipient's
|
||||||
|
rights in the Source Code version from the rights set forth in this
|
||||||
|
License. If You distribute the Executable version under a different
|
||||||
|
license You must make it absolutely clear that any terms which differ
|
||||||
|
from this License are offered by You alone, not by the Initial
|
||||||
|
Developer or any Contributor. You hereby agree to indemnify the
|
||||||
|
Initial Developer and every Contributor for any liability incurred by
|
||||||
|
the Initial Developer or such Contributor as a result of any such
|
||||||
|
terms You offer.
|
||||||
|
|
||||||
|
3.7. Larger Works.
|
||||||
|
You may create a Larger Work by combining Covered Code with other code
|
||||||
|
not governed by the terms of this License and distribute the Larger
|
||||||
|
Work as a single product. In such a case, You must make sure the
|
||||||
|
requirements of this License are fulfilled for the Covered Code.
|
||||||
|
|
||||||
|
4. Inability to Comply Due to Statute or Regulation.
|
||||||
|
|
||||||
|
If it is impossible for You to comply with any of the terms of this
|
||||||
|
License with respect to some or all of the Covered Code due to
|
||||||
|
statute, judicial order, or regulation then You must: (a) comply with
|
||||||
|
the terms of this License to the maximum extent possible; and (b)
|
||||||
|
describe the limitations and the code they affect. Such description
|
||||||
|
must be included in the LEGAL file described in Section 3.4 and must
|
||||||
|
be included with all distributions of the Source Code. Except to the
|
||||||
|
extent prohibited by statute or regulation, such description must be
|
||||||
|
sufficiently detailed for a recipient of ordinary skill to be able to
|
||||||
|
understand it.
|
||||||
|
|
||||||
|
5. Application of this License.
|
||||||
|
|
||||||
|
This License applies to code to which the Initial Developer has
|
||||||
|
attached the notice in Exhibit A and to related Covered Code.
|
||||||
|
|
||||||
|
6. Versions of the License.
|
||||||
|
|
||||||
|
6.1. New Versions.
|
||||||
|
Netscape Communications Corporation ("Netscape") may publish revised
|
||||||
|
and/or new versions of the License from time to time. Each version
|
||||||
|
will be given a distinguishing version number.
|
||||||
|
|
||||||
|
6.2. Effect of New Versions.
|
||||||
|
Once Covered Code has been published under a particular version of the
|
||||||
|
License, You may always continue to use it under the terms of that
|
||||||
|
version. You may also choose to use such Covered Code under the terms
|
||||||
|
of any subsequent version of the License published by Netscape. No one
|
||||||
|
other than Netscape has the right to modify the terms applicable to
|
||||||
|
Covered Code created under this License.
|
||||||
|
|
||||||
|
6.3. Derivative Works.
|
||||||
|
If You create or use a modified version of this License (which you may
|
||||||
|
only do in order to apply it to code which is not already Covered Code
|
||||||
|
governed by this License), You must (a) rename Your license so that
|
||||||
|
the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape",
|
||||||
|
"MPL", "NPL" or any confusingly similar phrase do not appear in your
|
||||||
|
license (except to note that your license differs from this License)
|
||||||
|
and (b) otherwise make it clear that Your version of the license
|
||||||
|
contains terms which differ from the Mozilla Public License and
|
||||||
|
Netscape Public License. (Filling in the name of the Initial
|
||||||
|
Developer, Original Code or Contributor in the notice described in
|
||||||
|
Exhibit A shall not of themselves be deemed to be modifications of
|
||||||
|
this License.)
|
||||||
|
|
||||||
|
7. DISCLAIMER OF WARRANTY.
|
||||||
|
|
||||||
|
COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||||
|
WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF
|
||||||
|
DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING.
|
||||||
|
THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE
|
||||||
|
IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT,
|
||||||
|
YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE
|
||||||
|
COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER
|
||||||
|
OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
|
||||||
|
ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
|
||||||
|
|
||||||
|
8. TERMINATION.
|
||||||
|
|
||||||
|
8.1. This License and the rights granted hereunder will terminate
|
||||||
|
automatically if You fail to comply with terms herein and fail to cure
|
||||||
|
such breach within 30 days of becoming aware of the breach. All
|
||||||
|
sublicenses to the Covered Code which are properly granted shall
|
||||||
|
survive any termination of this License. Provisions which, by their
|
||||||
|
nature, must remain in effect beyond the termination of this License
|
||||||
|
shall survive.
|
||||||
|
|
||||||
|
8.2. If You initiate litigation by asserting a patent infringement
|
||||||
|
claim (excluding declatory judgment actions) against Initial Developer
|
||||||
|
or a Contributor (the Initial Developer or Contributor against whom
|
||||||
|
You file such action is referred to as "Participant") alleging that:
|
||||||
|
|
||||||
|
(a) such Participant's Contributor Version directly or indirectly
|
||||||
|
infringes any patent, then any and all rights granted by such
|
||||||
|
Participant to You under Sections 2.1 and/or 2.2 of this License
|
||||||
|
shall, upon 60 days notice from Participant terminate prospectively,
|
||||||
|
unless if within 60 days after receipt of notice You either: (i)
|
||||||
|
agree in writing to pay Participant a mutually agreeable reasonable
|
||||||
|
royalty for Your past and future use of Modifications made by such
|
||||||
|
Participant, or (ii) withdraw Your litigation claim with respect to
|
||||||
|
the Contributor Version against such Participant. If within 60 days
|
||||||
|
of notice, a reasonable royalty and payment arrangement are not
|
||||||
|
mutually agreed upon in writing by the parties or the litigation claim
|
||||||
|
is not withdrawn, the rights granted by Participant to You under
|
||||||
|
Sections 2.1 and/or 2.2 automatically terminate at the expiration of
|
||||||
|
the 60 day notice period specified above.
|
||||||
|
|
||||||
|
(b) any software, hardware, or device, other than such Participant's
|
||||||
|
Contributor Version, directly or indirectly infringes any patent, then
|
||||||
|
any rights granted to You by such Participant under Sections 2.1(b)
|
||||||
|
and 2.2(b) are revoked effective as of the date You first made, used,
|
||||||
|
sold, distributed, or had made, Modifications made by that
|
||||||
|
Participant.
|
||||||
|
|
||||||
|
8.3. If You assert a patent infringement claim against Participant
|
||||||
|
alleging that such Participant's Contributor Version directly or
|
||||||
|
indirectly infringes any patent where such claim is resolved (such as
|
||||||
|
by license or settlement) prior to the initiation of patent
|
||||||
|
infringement litigation, then the reasonable value of the licenses
|
||||||
|
granted by such Participant under Sections 2.1 or 2.2 shall be taken
|
||||||
|
into account in determining the amount or value of any payment or
|
||||||
|
license.
|
||||||
|
|
||||||
|
8.4. In the event of termination under Sections 8.1 or 8.2 above,
|
||||||
|
all end user license agreements (excluding distributors and resellers)
|
||||||
|
which have been validly granted by You or any distributor hereunder
|
||||||
|
prior to termination shall survive termination.
|
||||||
|
|
||||||
|
9. LIMITATION OF LIABILITY.
|
||||||
|
|
||||||
|
UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
|
||||||
|
(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL
|
||||||
|
DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE,
|
||||||
|
OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR
|
||||||
|
ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY
|
||||||
|
CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL,
|
||||||
|
WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
|
||||||
|
COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
|
||||||
|
INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
|
||||||
|
LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY
|
||||||
|
RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
|
||||||
|
PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
|
||||||
|
EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO
|
||||||
|
THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
|
||||||
|
|
||||||
|
10. U.S. GOVERNMENT END USERS.
|
||||||
|
|
||||||
|
The Covered Code is a "commercial item," as that term is defined in
|
||||||
|
48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer
|
||||||
|
software" and "commercial computer software documentation," as such
|
||||||
|
terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48
|
||||||
|
C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995),
|
||||||
|
all U.S. Government End Users acquire Covered Code with only those
|
||||||
|
rights set forth herein.
|
||||||
|
|
||||||
|
11. MISCELLANEOUS.
|
||||||
|
|
||||||
|
This License represents the complete agreement concerning subject
|
||||||
|
matter hereof. If any provision of this License is held to be
|
||||||
|
unenforceable, such provision shall be reformed only to the extent
|
||||||
|
necessary to make it enforceable. This License shall be governed by
|
||||||
|
California law provisions (except to the extent applicable law, if
|
||||||
|
any, provides otherwise), excluding its conflict-of-law provisions.
|
||||||
|
With respect to disputes in which at least one party is a citizen of,
|
||||||
|
or an entity chartered or registered to do business in the United
|
||||||
|
States of America, any litigation relating to this License shall be
|
||||||
|
subject to the jurisdiction of the Federal Courts of the Northern
|
||||||
|
District of California, with venue lying in Santa Clara County,
|
||||||
|
California, with the losing party responsible for costs, including
|
||||||
|
without limitation, court costs and reasonable attorneys' fees and
|
||||||
|
expenses. The application of the United Nations Convention on
|
||||||
|
Contracts for the International Sale of Goods is expressly excluded.
|
||||||
|
Any law or regulation which provides that the language of a contract
|
||||||
|
shall be construed against the drafter shall not apply to this
|
||||||
|
License.
|
||||||
|
|
||||||
|
12. RESPONSIBILITY FOR CLAIMS.
|
||||||
|
|
||||||
|
As between Initial Developer and the Contributors, each party is
|
||||||
|
responsible for claims and damages arising, directly or indirectly,
|
||||||
|
out of its utilization of rights under this License and You agree to
|
||||||
|
work with Initial Developer and Contributors to distribute such
|
||||||
|
responsibility on an equitable basis. Nothing herein is intended or
|
||||||
|
shall be deemed to constitute any admission of liability.
|
||||||
|
|
||||||
|
13. MULTIPLE-LICENSED CODE.
|
||||||
|
|
||||||
|
Initial Developer may designate portions of the Covered Code as
|
||||||
|
"Multiple-Licensed". "Multiple-Licensed" means that the Initial
|
||||||
|
Developer permits you to utilize portions of the Covered Code under
|
||||||
|
Your choice of the NPL or the alternative licenses, if any, specified
|
||||||
|
by the Initial Developer in the file described in Exhibit A.
|
||||||
|
|
||||||
|
EXHIBIT A -Mozilla Public License.
|
||||||
|
|
||||||
|
``The contents of this file are subject to the Mozilla Public License
|
||||||
|
Version 1.1 (the "License"); you may not use this file except in
|
||||||
|
compliance with the License. You may obtain a copy of the License at
|
||||||
|
http://www.mozilla.org/MPL/
|
||||||
|
|
||||||
|
Software distributed under the License is distributed on an "AS IS"
|
||||||
|
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||||
|
License for the specific language governing rights and limitations
|
||||||
|
under the License.
|
||||||
|
|
||||||
|
The Original Code is RabbitMQ.
|
||||||
|
|
||||||
|
The Initial Developer of the Original Code is Pivotal Software, Inc.
|
||||||
|
Copyright (c) 2007-2016 Pivotal Software, Inc. All rights reserved.''
|
||||||
|
|
||||||
|
[NOTE: The text of this Exhibit A may differ slightly from the text of
|
||||||
|
the notices in the Source Code files of the Original Code. You should
|
||||||
|
use the text of this Exhibit A rather than the text found in the
|
||||||
|
Original Code Source Code for Your Modifications.]
|
10
Makefile
10
Makefile
|
@ -1,6 +1,6 @@
|
||||||
PROJECT = emqttd
|
PROJECT = emqttd
|
||||||
PROJECT_DESCRIPTION = Erlang MQTT Broker
|
PROJECT_DESCRIPTION = Erlang MQTT Broker
|
||||||
PROJECT_VERSION = 2.3.1
|
PROJECT_VERSION = 2.3.4
|
||||||
|
|
||||||
DEPS = goldrush gproc lager esockd ekka mochiweb pbkdf2 lager_syslog bcrypt clique jsx
|
DEPS = goldrush gproc lager esockd ekka mochiweb pbkdf2 lager_syslog bcrypt clique jsx
|
||||||
|
|
||||||
|
@ -8,9 +8,9 @@ dep_goldrush = git https://github.com/basho/goldrush 0.1.9
|
||||||
dep_gproc = git https://github.com/uwiger/gproc
|
dep_gproc = git https://github.com/uwiger/gproc
|
||||||
dep_getopt = git https://github.com/jcomellas/getopt v0.8.2
|
dep_getopt = git https://github.com/jcomellas/getopt v0.8.2
|
||||||
dep_lager = git https://github.com/basho/lager master
|
dep_lager = git https://github.com/basho/lager master
|
||||||
dep_esockd = git https://github.com/emqtt/esockd master
|
dep_esockd = git https://github.com/emqtt/esockd v5.2
|
||||||
dep_ekka = git https://github.com/emqtt/ekka master
|
dep_ekka = git https://github.com/emqtt/ekka v0.2.2
|
||||||
dep_mochiweb = git https://github.com/emqtt/mochiweb develop
|
dep_mochiweb = git https://github.com/emqtt/mochiweb v4.2.1
|
||||||
dep_pbkdf2 = git https://github.com/emqtt/pbkdf2 2.0.1
|
dep_pbkdf2 = git https://github.com/emqtt/pbkdf2 2.0.1
|
||||||
dep_lager_syslog = git https://github.com/basho/lager_syslog
|
dep_lager_syslog = git https://github.com/basho/lager_syslog
|
||||||
dep_bcrypt = git https://github.com/smarkets/erlang-bcrypt master
|
dep_bcrypt = git https://github.com/smarkets/erlang-bcrypt master
|
||||||
|
@ -27,7 +27,7 @@ dep_cuttlefish = git https://github.com/emqtt/cuttlefish
|
||||||
|
|
||||||
TEST_DEPS = emqttc emq_dashboard
|
TEST_DEPS = emqttc emq_dashboard
|
||||||
dep_emqttc = git https://github.com/emqtt/emqttc
|
dep_emqttc = git https://github.com/emqtt/emqttc
|
||||||
dep_emq_dashboard = git https://github.com/emqtt/emq_dashboard
|
dep_emq_dashboard = git https://github.com/emqtt/emq_dashboard develop
|
||||||
|
|
||||||
TEST_ERLC_OPTS += +debug_info
|
TEST_ERLC_OPTS += +debug_info
|
||||||
TEST_ERLC_OPTS += +'{parse_transform, lager_transform}'
|
TEST_ERLC_OPTS += +'{parse_transform, lager_transform}'
|
||||||
|
|
|
@ -77,7 +77,7 @@ Plugin | Descrip
|
||||||
-----------------------------------------------------------------------|--------------------------------------
|
-----------------------------------------------------------------------|--------------------------------------
|
||||||
[emq_plugin_template](https://github.com/emqtt/emq_plugin_template) | Plugin template and demo
|
[emq_plugin_template](https://github.com/emqtt/emq_plugin_template) | Plugin template and demo
|
||||||
[emq_dashboard](https://github.com/emqtt/emq_dashboard) | Web Dashboard
|
[emq_dashboard](https://github.com/emqtt/emq_dashboard) | Web Dashboard
|
||||||
[emq_retainer](https://github.com/emqtt/emq_retainer) | Store MQTT Retained Messages
|
[emq_retainer](https://github.com/emqtt/emq-retainer) | Store MQTT Retained Messages
|
||||||
[emq_modules](https://github.com/emqtt/emq-modules) | Presence, Subscription and Rewrite Modules
|
[emq_modules](https://github.com/emqtt/emq-modules) | Presence, Subscription and Rewrite Modules
|
||||||
[emq_auth_username](https://github.com/emqtt/emq_auth_username) | Username/Password Authentication Plugin
|
[emq_auth_username](https://github.com/emqtt/emq_auth_username) | Username/Password Authentication Plugin
|
||||||
[emq_auth_clientid](https://github.com/emqtt/emq_auth_clientid) | ClientId Authentication Plugin
|
[emq_auth_clientid](https://github.com/emqtt/emq_auth_clientid) | ClientId Authentication Plugin
|
||||||
|
@ -93,7 +93,7 @@ Plugin | Descrip
|
||||||
[emq_sn](https://github.com/emqtt/emq_sn) | MQTT-SN Protocol Plugin
|
[emq_sn](https://github.com/emqtt/emq_sn) | MQTT-SN Protocol Plugin
|
||||||
[emq_coap](https://github.com/emqtt/emq_coap) | CoAP Protocol Plugin
|
[emq_coap](https://github.com/emqtt/emq_coap) | CoAP Protocol Plugin
|
||||||
[emq_stomp](https://github.com/emqtt/emq_stomp) | Stomp Protocol Plugin
|
[emq_stomp](https://github.com/emqtt/emq_stomp) | Stomp Protocol Plugin
|
||||||
[emq_lwm2m](https://github.com/emqtt/emq-lwm2m) | LWM2M Prototol Plugin
|
[emq_lwm2m](https://github.com/emqx/emqx-lwm2m) | LWM2M Prototol Plugin
|
||||||
[emq_recon](https://github.com/emqtt/emq_recon) | Recon Plugin
|
[emq_recon](https://github.com/emqtt/emq_recon) | Recon Plugin
|
||||||
[emq_reloader](https://github.com/emqtt/emq_reloader) | Reloader Plugin
|
[emq_reloader](https://github.com/emqtt/emq_reloader) | Reloader Plugin
|
||||||
[emq_sockjs](https://github.com/emqtt/emq_sockjs) | SockJS(Stomp) Plugin
|
[emq_sockjs](https://github.com/emqtt/emq_sockjs) | SockJS(Stomp) Plugin
|
||||||
|
@ -109,9 +109,7 @@ Plugin | Descrip
|
||||||
* Issues: https://github.com/emqtt/emqttd/issues
|
* Issues: https://github.com/emqtt/emqttd/issues
|
||||||
* QQ Group: 12222225
|
* QQ Group: 12222225
|
||||||
|
|
||||||
## Partners
|
## Test Servers
|
||||||
|
|
||||||
[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.
|
|
||||||
|
|
||||||
The **q.emqtt.com** hosts a public Four-Node *EMQ* cluster on [QingCloud](https://qingcloud.com):
|
The **q.emqtt.com** hosts a public Four-Node *EMQ* cluster on [QingCloud](https://qingcloud.com):
|
||||||
|
|
||||||
|
|
1244
etc/emq.conf
1244
etc/emq.conf
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
%% Banner
|
%% Banner
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
-define(COPYRIGHT, "Copyright (c) 2013-2017 EMQ Enterprise, Inc.").
|
-define(COPYRIGHT, "Copyright (c) 2013-2018 EMQ Enterprise, Inc.").
|
||||||
|
|
||||||
-define(LICENSE_MESSAGE, "Licensed under the Apache License, Version 2.0").
|
-define(LICENSE_MESSAGE, "Licensed under the Apache License, Version 2.0").
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
161
priv/emq.schema
161
priv/emq.schema
|
@ -168,6 +168,11 @@ end}.
|
||||||
{default, "emq@127.0.0.1"}
|
{default, "emq@127.0.0.1"}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
%% @doc The erlang distributed protocol
|
||||||
|
{mapping, "node.proto_dist", "vm_args.-proto_dist", [
|
||||||
|
%%{default, "inet_tcp"}
|
||||||
|
]}.
|
||||||
|
|
||||||
%% @doc Secret cookie for distributed erlang node
|
%% @doc Secret cookie for distributed erlang node
|
||||||
{mapping, "node.cookie", "vm_args.-setcookie", [
|
{mapping, "node.cookie", "vm_args.-setcookie", [
|
||||||
{default, "emqsecretcookie"}
|
{default, "emqsecretcookie"}
|
||||||
|
@ -400,7 +405,7 @@ end}.
|
||||||
{translation,
|
{translation,
|
||||||
"lager.handlers",
|
"lager.handlers",
|
||||||
fun(Conf) ->
|
fun(Conf) ->
|
||||||
ErrorHandler = case cuttlefish:conf_get("log.error.file", Conf) of
|
ErrorHandler = case cuttlefish:conf_get("log.error.file", Conf, undefined) of
|
||||||
undefined -> [];
|
undefined -> [];
|
||||||
ErrorFilename -> [{lager_file_backend, [{file, ErrorFilename},
|
ErrorFilename -> [{lager_file_backend, [{file, ErrorFilename},
|
||||||
{level, error},
|
{level, error},
|
||||||
|
@ -442,7 +447,6 @@ end}.
|
||||||
cuttlefish:conf_get("log.syslog.facility", Conf),
|
cuttlefish:conf_get("log.syslog.facility", Conf),
|
||||||
cuttlefish:conf_get("log.syslog.level", Conf)]}]
|
cuttlefish:conf_get("log.syslog.level", Conf)]}]
|
||||||
end,
|
end,
|
||||||
|
|
||||||
ConsoleHandlers ++ ErrorHandler ++ InfoHandler ++ SyslogHandler
|
ConsoleHandlers ++ ErrorHandler ++ InfoHandler ++ SyslogHandler
|
||||||
end
|
end
|
||||||
}.
|
}.
|
||||||
|
@ -702,8 +706,8 @@ end}.
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
{mapping, "mqtt.broker.sys_interval", "emqttd.broker_sys_interval", [
|
{mapping, "mqtt.broker.sys_interval", "emqttd.broker_sys_interval", [
|
||||||
{default, 60},
|
{datatype, {duration, ms}},
|
||||||
{datatype, integer}
|
{default, "1m"}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
@ -735,8 +739,8 @@ end}.
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{mapping, "mqtt.bridge.ping_down_interval", "emqttd.bridge", [
|
{mapping, "mqtt.bridge.ping_down_interval", "emqttd.bridge", [
|
||||||
{default, 1},
|
{datatype, {duration, ms}},
|
||||||
{datatype, integer}
|
{default, "1s"}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{translation, "emqttd.bridge", fun(Conf) ->
|
{translation, "emqttd.bridge", fun(Conf) ->
|
||||||
|
@ -795,18 +799,30 @@ end}.
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{mapping, "listener.tcp.$name.proxy_protocol", "emqttd.listeners", [
|
{mapping, "listener.tcp.$name.proxy_protocol", "emqttd.listeners", [
|
||||||
%%{default, off},
|
|
||||||
{datatype, flag}
|
{datatype, flag}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{mapping, "listener.tcp.$name.proxy_protocol_timeout", "emqttd.listeners", [
|
{mapping, "listener.tcp.$name.proxy_protocol_timeout", "emqttd.listeners", [
|
||||||
%%{default, "5s"},
|
|
||||||
{datatype, {duration, ms}}
|
{datatype, {duration, ms}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.tcp.$name.peer_cert_as_username", "emqttd.listeners", [
|
||||||
|
{datatype, {enum, [cn, dn]}}
|
||||||
|
]}.
|
||||||
|
|
||||||
{mapping, "listener.tcp.$name.backlog", "emqttd.listeners", [
|
{mapping, "listener.tcp.$name.backlog", "emqttd.listeners", [
|
||||||
{default, 1024},
|
{datatype, integer},
|
||||||
{datatype, integer}
|
{default, 1024}
|
||||||
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.tcp.$name.send_timeout", "emqttd.listeners", [
|
||||||
|
{datatype, {duration, ms}},
|
||||||
|
{default, "15s"}
|
||||||
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.tcp.$name.send_timeout_close", "emqttd.listeners", [
|
||||||
|
{datatype, flag},
|
||||||
|
{default, on}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{mapping, "listener.tcp.$name.recbuf", "emqttd.listeners", [
|
{mapping, "listener.tcp.$name.recbuf", "emqttd.listeners", [
|
||||||
|
@ -834,6 +850,11 @@ end}.
|
||||||
hidden
|
hidden
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.tcp.$name.reuseaddr", "emqttd.listeners", [
|
||||||
|
{datatype, {enum, [true, false]}},
|
||||||
|
hidden
|
||||||
|
]}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% SSL Listeners
|
%% SSL Listeners
|
||||||
|
|
||||||
|
@ -869,12 +890,10 @@ end}.
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{mapping, "listener.ssl.$name.proxy_protocol", "emqttd.listeners", [
|
{mapping, "listener.ssl.$name.proxy_protocol", "emqttd.listeners", [
|
||||||
%%{default, off},
|
|
||||||
{datatype, flag}
|
{datatype, flag}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{mapping, "listener.ssl.$name.proxy_protocol_timeout", "emqttd.listeners", [
|
{mapping, "listener.ssl.$name.proxy_protocol_timeout", "emqttd.listeners", [
|
||||||
%%{default, "5s"},
|
|
||||||
{datatype, {duration, ms}}
|
{datatype, {duration, ms}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
@ -883,6 +902,16 @@ end}.
|
||||||
{datatype, integer}
|
{datatype, integer}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.ssl.$name.send_timeout", "emqttd.listeners", [
|
||||||
|
{datatype, {duration, ms}},
|
||||||
|
{default, "15s"}
|
||||||
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.ssl.$name.send_timeout_close", "emqttd.listeners", [
|
||||||
|
{datatype, flag},
|
||||||
|
{default, on}
|
||||||
|
]}.
|
||||||
|
|
||||||
{mapping, "listener.ssl.$name.recbuf", "emqttd.listeners", [
|
{mapping, "listener.ssl.$name.recbuf", "emqttd.listeners", [
|
||||||
{datatype, bytesize},
|
{datatype, bytesize},
|
||||||
hidden
|
hidden
|
||||||
|
@ -908,6 +937,11 @@ end}.
|
||||||
hidden
|
hidden
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.ssl.$name.reuseaddr", "emqttd.listeners", [
|
||||||
|
{datatype, {enum, [true, false]}},
|
||||||
|
hidden
|
||||||
|
]}.
|
||||||
|
|
||||||
{mapping, "listener.ssl.$name.tls_versions", "emqttd.listeners", [
|
{mapping, "listener.ssl.$name.tls_versions", "emqttd.listeners", [
|
||||||
{datatype, string}
|
{datatype, string}
|
||||||
]}.
|
]}.
|
||||||
|
@ -987,6 +1021,14 @@ end}.
|
||||||
{datatype, string}
|
{datatype, string}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.ws.$name.mountpoint", "emqttd.listeners", [
|
||||||
|
{datatype, string}
|
||||||
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.ws.$name.access.$id", "emqttd.listeners", [
|
||||||
|
{datatype, string}
|
||||||
|
]}.
|
||||||
|
|
||||||
{mapping, "listener.ws.$name.proxy_port_header", "emqttd.listeners", [
|
{mapping, "listener.ws.$name.proxy_port_header", "emqttd.listeners", [
|
||||||
{datatype, string},
|
{datatype, string},
|
||||||
hidden
|
hidden
|
||||||
|
@ -997,8 +1039,12 @@ end}.
|
||||||
hidden
|
hidden
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{mapping, "listener.ws.$name.access.$id", "emqttd.listeners", [
|
{mapping, "listener.ws.$name.proxy_protocol", "emqttd.listeners", [
|
||||||
{datatype, string}
|
{datatype, flag}
|
||||||
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.ws.$name.proxy_protocol_timeout", "emqttd.listeners", [
|
||||||
|
{datatype, {duration, ms}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{mapping, "listener.ws.$name.backlog", "emqttd.listeners", [
|
{mapping, "listener.ws.$name.backlog", "emqttd.listeners", [
|
||||||
|
@ -1006,6 +1052,16 @@ end}.
|
||||||
{datatype, integer}
|
{datatype, integer}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.ws.$name.send_timeout", "emqttd.listeners", [
|
||||||
|
{datatype, {duration, ms}},
|
||||||
|
{default, "15s"}
|
||||||
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.ws.$name.send_timeout_close", "emqttd.listeners", [
|
||||||
|
{datatype, flag},
|
||||||
|
{default, on}
|
||||||
|
]}.
|
||||||
|
|
||||||
{mapping, "listener.ws.$name.recbuf", "emqttd.listeners", [
|
{mapping, "listener.ws.$name.recbuf", "emqttd.listeners", [
|
||||||
{datatype, bytesize},
|
{datatype, bytesize},
|
||||||
hidden
|
hidden
|
||||||
|
@ -1031,6 +1087,11 @@ end}.
|
||||||
hidden
|
hidden
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.ws.$name.reuseaddr", "emqttd.listeners", [
|
||||||
|
{datatype, {enum, [true, false]}},
|
||||||
|
hidden
|
||||||
|
]}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% MQTT/WebSocket/SSL Listeners
|
%% MQTT/WebSocket/SSL Listeners
|
||||||
|
|
||||||
|
@ -1060,6 +1121,10 @@ end}.
|
||||||
{datatype, string}
|
{datatype, string}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.wss.$name.access.$id", "emqttd.listeners", [
|
||||||
|
{datatype, string}
|
||||||
|
]}.
|
||||||
|
|
||||||
{mapping, "listener.wss.$name.proxy_port_header", "emqttd.listeners", [
|
{mapping, "listener.wss.$name.proxy_port_header", "emqttd.listeners", [
|
||||||
{datatype, string},
|
{datatype, string},
|
||||||
hidden
|
hidden
|
||||||
|
@ -1070,8 +1135,12 @@ end}.
|
||||||
hidden
|
hidden
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{mapping, "listener.wss.$name.access.$id", "emqttd.listeners", [
|
{mapping, "listener.wss.$name.proxy_protocol", "emqttd.listeners", [
|
||||||
{datatype, string}
|
{datatype, flag}
|
||||||
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.wss.$name.proxy_protocol_timeout", "emqttd.listeners", [
|
||||||
|
{datatype, {duration, ms}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{mapping, "listener.wss.$name.backlog", "emqttd.listeners", [
|
{mapping, "listener.wss.$name.backlog", "emqttd.listeners", [
|
||||||
|
@ -1079,6 +1148,16 @@ end}.
|
||||||
{datatype, integer}
|
{datatype, integer}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.wss.$name.send_timeout", "emqttd.listeners", [
|
||||||
|
{datatype, {duration, ms}},
|
||||||
|
{default, "15s"}
|
||||||
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.wss.$name.send_timeout_close", "emqttd.listeners", [
|
||||||
|
{datatype, flag},
|
||||||
|
{default, on}
|
||||||
|
]}.
|
||||||
|
|
||||||
{mapping, "listener.wss.$name.recbuf", "emqttd.listeners", [
|
{mapping, "listener.wss.$name.recbuf", "emqttd.listeners", [
|
||||||
{datatype, bytesize},
|
{datatype, bytesize},
|
||||||
hidden
|
hidden
|
||||||
|
@ -1104,6 +1183,19 @@ end}.
|
||||||
hidden
|
hidden
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.wss.$name.reuseaddr", "emqttd.listeners", [
|
||||||
|
{datatype, {enum, [true, false]}},
|
||||||
|
hidden
|
||||||
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.wss.$name.tls_versions", "emqttd.listeners", [
|
||||||
|
{datatype, string}
|
||||||
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.wss.$name.ciphers", "emqttd.listeners", [
|
||||||
|
{datatype, string}
|
||||||
|
]}.
|
||||||
|
|
||||||
{mapping, "listener.wss.$name.handshake_timeout", "emqttd.listeners", [
|
{mapping, "listener.wss.$name.handshake_timeout", "emqttd.listeners", [
|
||||||
{default, "15s"},
|
{default, "15s"},
|
||||||
{datatype, {duration, ms}}
|
{datatype, {duration, ms}}
|
||||||
|
@ -1129,6 +1221,23 @@ end}.
|
||||||
{datatype, {enum, [true, false]}}
|
{datatype, {enum, [true, false]}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.wss.$name.secure_renegotiate", "emqttd.listeners", [
|
||||||
|
{datatype, flag}
|
||||||
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.wss.$name.reuse_sessions", "emqttd.listeners", [
|
||||||
|
{default, on},
|
||||||
|
{datatype, flag}
|
||||||
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.wss.$name.honor_cipher_order", "emqttd.listeners", [
|
||||||
|
{datatype, flag}
|
||||||
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.wss.$name.peer_cert_as_username", "emqttd.listeners", [
|
||||||
|
{datatype, {enum, [cn, dn]}}
|
||||||
|
]}.
|
||||||
|
|
||||||
{translation, "emqttd.listeners", fun(Conf) ->
|
{translation, "emqttd.listeners", fun(Conf) ->
|
||||||
|
|
||||||
Filter = fun(Opts) -> [{K, V} || {K, V} <- Opts, V =/= undefined] end,
|
Filter = fun(Opts) -> [{K, V} || {K, V} <- Opts, V =/= undefined] end,
|
||||||
|
@ -1167,10 +1276,13 @@ end}.
|
||||||
end,
|
end,
|
||||||
TcpOpts = fun(Prefix) ->
|
TcpOpts = fun(Prefix) ->
|
||||||
Filter([{backlog, cuttlefish:conf_get(Prefix ++ ".backlog", Conf, undefined)},
|
Filter([{backlog, cuttlefish:conf_get(Prefix ++ ".backlog", Conf, undefined)},
|
||||||
|
{send_timeout, cuttlefish:conf_get(Prefix ++ ".send_timeout", Conf, undefined)},
|
||||||
|
{send_timeout_close, cuttlefish:conf_get(Prefix ++ ".send_timeout_close", Conf, undefined)},
|
||||||
{recbuf, cuttlefish:conf_get(Prefix ++ ".recbuf", Conf, undefined)},
|
{recbuf, cuttlefish:conf_get(Prefix ++ ".recbuf", Conf, undefined)},
|
||||||
{sndbuf, cuttlefish:conf_get(Prefix ++ ".sndbuf", Conf, undefined)},
|
{sndbuf, cuttlefish:conf_get(Prefix ++ ".sndbuf", Conf, undefined)},
|
||||||
{buffer, cuttlefish:conf_get(Prefix ++ ".buffer", Conf, undefined)},
|
{buffer, cuttlefish:conf_get(Prefix ++ ".buffer", Conf, undefined)},
|
||||||
{nodelay, cuttlefish:conf_get(Prefix ++ ".nodelay", Conf, true)}])
|
{nodelay, cuttlefish:conf_get(Prefix ++ ".nodelay", Conf, true)},
|
||||||
|
{reuseaddr, cuttlefish:conf_get(Prefix ++ ".reuseaddr", Conf, true)}])
|
||||||
end,
|
end,
|
||||||
|
|
||||||
SplitFun = fun(undefined) -> undefined; (S) -> string:tokens(S, ",") end,
|
SplitFun = fun(undefined) -> undefined; (S) -> string:tokens(S, ",") end,
|
||||||
|
@ -1275,6 +1387,16 @@ end}.
|
||||||
{datatype, integer}
|
{datatype, integer}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.api.$name.send_timeout", "emqttd.listeners", [
|
||||||
|
{datatype, {duration, ms}},
|
||||||
|
{default, "15s"}
|
||||||
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.api.$name.send_timeout_close", "emqttd.listeners", [
|
||||||
|
{datatype, flag},
|
||||||
|
{default, on}
|
||||||
|
]}.
|
||||||
|
|
||||||
{mapping, "listener.api.$name.recbuf", "emqttd.listeners", [
|
{mapping, "listener.api.$name.recbuf", "emqttd.listeners", [
|
||||||
{datatype, bytesize},
|
{datatype, bytesize},
|
||||||
hidden
|
hidden
|
||||||
|
@ -1300,6 +1422,11 @@ end}.
|
||||||
hidden
|
hidden
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
{mapping, "listener.api.$name.reuseaddr", "emqttd.listeners", [
|
||||||
|
{datatype, {enum, [true, false]}},
|
||||||
|
hidden
|
||||||
|
]}.
|
||||||
|
|
||||||
{mapping, "listener.api.$name.handshake_timeout", "emqttd.listeners", [
|
{mapping, "listener.api.$name.handshake_timeout", "emqttd.listeners", [
|
||||||
{datatype, {duration, ms}}
|
{datatype, {duration, ms}}
|
||||||
]}.
|
]}.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{application,emqttd,
|
{application,emqttd,
|
||||||
[{description,"Erlang MQTT Broker"},
|
[{description,"Erlang MQTT Broker"},
|
||||||
{vsn,"2.3.1"},
|
{vsn,"2.3.4"},
|
||||||
{modules,[]},
|
{modules,[]},
|
||||||
{registered,[emqttd_sup]},
|
{registered,[emqttd_sup]},
|
||||||
{applications,[kernel,stdlib,gproc,lager,esockd,mochiweb,
|
{applications,[kernel,stdlib,gproc,lager,esockd,mochiweb,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -92,7 +92,7 @@ parse_opts([{topic_prefix, Prefix} | Opts], State) ->
|
||||||
parse_opts([{max_queue_len, Len} | Opts], State) ->
|
parse_opts([{max_queue_len, Len} | Opts], State) ->
|
||||||
parse_opts(Opts, State#state{max_queue_len = Len});
|
parse_opts(Opts, State#state{max_queue_len = Len});
|
||||||
parse_opts([{ping_down_interval, Interval} | Opts], State) ->
|
parse_opts([{ping_down_interval, Interval} | Opts], State) ->
|
||||||
parse_opts(Opts, State#state{ping_down_interval = Interval*1000});
|
parse_opts(Opts, State#state{ping_down_interval = Interval});
|
||||||
parse_opts([_Opt | Opts], State) ->
|
parse_opts([_Opt | Opts], State) ->
|
||||||
parse_opts(Opts, State).
|
parse_opts(Opts, State).
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -105,9 +105,9 @@ datetime() ->
|
||||||
io_lib:format(
|
io_lib:format(
|
||||||
"~4..0w-~2..0w-~2..0w ~2..0w:~2..0w:~2..0w", [Y, M, D, H, MM, S])).
|
"~4..0w-~2..0w-~2..0w ~2..0w:~2..0w:~2..0w", [Y, M, D, H, MM, S])).
|
||||||
|
|
||||||
%% @doc Start a tick timer
|
%% @doc Start a tick timer.
|
||||||
start_tick(Msg) ->
|
start_tick(Msg) ->
|
||||||
start_tick(timer:seconds(emqttd:env(broker_sys_interval, 60)), Msg).
|
start_tick(emqttd:env(broker_sys_interval, 60000), Msg).
|
||||||
|
|
||||||
start_tick(0, _Msg) ->
|
start_tick(0, _Msg) ->
|
||||||
undefined;
|
undefined;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -140,7 +140,9 @@ send_fun(Conn, Peername) ->
|
||||||
?LOG(debug, "SEND ~p", [Data], #client_state{peername = Peername}),
|
?LOG(debug, "SEND ~p", [Data], #client_state{peername = Peername}),
|
||||||
emqttd_metrics:inc('bytes/sent', iolist_size(Data)),
|
emqttd_metrics:inc('bytes/sent', iolist_size(Data)),
|
||||||
try Conn:async_send(Data) of
|
try Conn:async_send(Data) of
|
||||||
true -> ok
|
ok -> ok;
|
||||||
|
true -> ok; %% Compatible with esockd 4.x
|
||||||
|
{error, Reason} -> Self ! {shutdown, Reason}
|
||||||
catch
|
catch
|
||||||
error:Error -> Self ! {shutdown, Error}
|
error:Error -> Self ! {shutdown, Error}
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
|
|
||||||
-export([publish/1, subscribe/1, unsubscribe/1]).
|
-export([publish/1, subscribe/1, unsubscribe/1]).
|
||||||
|
|
||||||
-export([kick_client/1, clean_acl_cache/2]).
|
-export([kick_client/1, kick_client/2, clean_acl_cache/2, clean_acl_cache/3]).
|
||||||
|
|
||||||
-export([modify_config/2, modify_config/3, modify_config/4, get_configs/0, get_config/1,
|
-export([modify_config/2, modify_config/3, modify_config/4, get_configs/0, get_config/1,
|
||||||
get_plugin_config/1, get_plugin_config/2, modify_plugin_config/2, modify_plugin_config/3]).
|
get_plugin_config/1, get_plugin_config/2, modify_plugin_config/2, modify_plugin_config/3]).
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc.
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -44,12 +44,13 @@
|
||||||
clean_sess, proto_ver, proto_name, username, is_superuser,
|
clean_sess, proto_ver, proto_name, username, is_superuser,
|
||||||
will_msg, keepalive, keepalive_backoff, max_clientid_len,
|
will_msg, keepalive, keepalive_backoff, max_clientid_len,
|
||||||
session, stats_data, mountpoint, ws_initial_headers,
|
session, stats_data, mountpoint, ws_initial_headers,
|
||||||
is_bridge, connected_at}).
|
peercert_username, is_bridge, connected_at}).
|
||||||
|
|
||||||
-type(proto_state() :: #proto_state{}).
|
-type(proto_state() :: #proto_state{}).
|
||||||
|
|
||||||
-define(INFO_KEYS, [client_id, username, clean_sess, proto_ver, proto_name,
|
-define(INFO_KEYS, [client_id, username, clean_sess, proto_ver, proto_name,
|
||||||
keepalive, will_msg, ws_initial_headers, mountpoint, connected_at]).
|
keepalive, will_msg, ws_initial_headers, mountpoint,
|
||||||
|
peercert_username, connected_at]).
|
||||||
|
|
||||||
-define(STATS_KEYS, [recv_pkt, recv_msg, send_pkt, send_msg]).
|
-define(STATS_KEYS, [recv_pkt, recv_msg, send_pkt, send_msg]).
|
||||||
|
|
||||||
|
@ -68,6 +69,7 @@ init(Peername, SendFun, Opts) ->
|
||||||
max_clientid_len = MaxLen,
|
max_clientid_len = MaxLen,
|
||||||
is_superuser = false,
|
is_superuser = false,
|
||||||
client_pid = self(),
|
client_pid = self(),
|
||||||
|
peercert_username = undefined,
|
||||||
ws_initial_headers = WsInitialHeaders,
|
ws_initial_headers = WsInitialHeaders,
|
||||||
keepalive_backoff = Backoff,
|
keepalive_backoff = Backoff,
|
||||||
stats_data = #proto_stats{enable_stats = EnableStats}}.
|
stats_data = #proto_stats{enable_stats = EnableStats}}.
|
||||||
|
@ -79,9 +81,21 @@ enrich_opt([], _Conn, State) ->
|
||||||
State;
|
State;
|
||||||
enrich_opt([{mountpoint, MountPoint} | ConnOpts], Conn, State) ->
|
enrich_opt([{mountpoint, MountPoint} | ConnOpts], Conn, State) ->
|
||||||
enrich_opt(ConnOpts, Conn, State#proto_state{mountpoint = MountPoint});
|
enrich_opt(ConnOpts, Conn, State#proto_state{mountpoint = MountPoint});
|
||||||
|
enrich_opt([{peer_cert_as_username, N} | ConnOpts], Conn, State) ->
|
||||||
|
enrich_opt(ConnOpts, Conn, State#proto_state{peercert_username = peercert_username(N, Conn)});
|
||||||
enrich_opt([_ | ConnOpts], Conn, State) ->
|
enrich_opt([_ | ConnOpts], Conn, State) ->
|
||||||
enrich_opt(ConnOpts, Conn, State).
|
enrich_opt(ConnOpts, Conn, State).
|
||||||
|
|
||||||
|
peercert_username(cn, Conn) ->
|
||||||
|
Conn:peer_cert_common_name();
|
||||||
|
peercert_username(dn, Conn) ->
|
||||||
|
Conn:peer_cert_subject().
|
||||||
|
|
||||||
|
repl_username_with_peercert(State = #proto_state{peercert_username = undefined}) ->
|
||||||
|
State;
|
||||||
|
repl_username_with_peercert(State = #proto_state{peercert_username = PeerCert}) ->
|
||||||
|
State#proto_state{username = PeerCert}.
|
||||||
|
|
||||||
info(ProtoState) ->
|
info(ProtoState) ->
|
||||||
?record_to_proplist(proto_state, ProtoState, ?INFO_KEYS).
|
?record_to_proplist(proto_state, ProtoState, ?INFO_KEYS).
|
||||||
|
|
||||||
|
@ -183,7 +197,8 @@ process(?CONNECT_PACKET(Var), State0) ->
|
||||||
client_id = ClientId,
|
client_id = ClientId,
|
||||||
is_bridge = IsBridge} = Var,
|
is_bridge = IsBridge} = Var,
|
||||||
|
|
||||||
State1 = State0#proto_state{proto_ver = ProtoVer,
|
State1 = repl_username_with_peercert(
|
||||||
|
State0#proto_state{proto_ver = ProtoVer,
|
||||||
proto_name = ProtoName,
|
proto_name = ProtoName,
|
||||||
username = Username,
|
username = Username,
|
||||||
client_id = ClientId,
|
client_id = ClientId,
|
||||||
|
@ -191,7 +206,7 @@ process(?CONNECT_PACKET(Var), State0) ->
|
||||||
keepalive = KeepAlive,
|
keepalive = KeepAlive,
|
||||||
will_msg = willmsg(Var, State0),
|
will_msg = willmsg(Var, State0),
|
||||||
is_bridge = IsBridge,
|
is_bridge = IsBridge,
|
||||||
connected_at = os:timestamp()},
|
connected_at = os:timestamp()}),
|
||||||
|
|
||||||
{ReturnCode1, SessPresent, State3} =
|
{ReturnCode1, SessPresent, State3} =
|
||||||
case validate_connect(Var, State1) of
|
case validate_connect(Var, State1) of
|
||||||
|
@ -341,13 +356,11 @@ send(Msg, State = #proto_state{client_id = ClientId,
|
||||||
emqttd_hooks:run('message.delivered', [ClientId, Username], Msg),
|
emqttd_hooks:run('message.delivered', [ClientId, Username], Msg),
|
||||||
send(emqttd_message:to_packet(unmount(MountPoint, clean_retain(IsBridge, Msg))), State);
|
send(emqttd_message:to_packet(unmount(MountPoint, clean_retain(IsBridge, Msg))), State);
|
||||||
|
|
||||||
send(Packet = ?PACKET(Type),
|
send(Packet = ?PACKET(Type), State = #proto_state{sendfun = SendFun, stats_data = Stats}) ->
|
||||||
State = #proto_state{sendfun = SendFun, stats_data = Stats}) ->
|
|
||||||
trace(send, Packet, State),
|
trace(send, Packet, State),
|
||||||
emqttd_metrics:sent(Packet),
|
emqttd_metrics:sent(Packet),
|
||||||
SendFun(Packet),
|
SendFun(Packet),
|
||||||
Stats1 = inc_stats(send, Type, Stats),
|
{ok, State#proto_state{stats_data = inc_stats(send, Type, Stats)}}.
|
||||||
{ok, State#proto_state{stats_data = Stats1}}.
|
|
||||||
|
|
||||||
trace(recv, Packet, ProtoState) ->
|
trace(recv, Packet, ProtoState) ->
|
||||||
?LOG(debug, "RECV ~s", [emqttd_packet:format(Packet)], ProtoState);
|
?LOG(debug, "RECV ~s", [emqttd_packet:format(Packet)], ProtoState);
|
||||||
|
@ -550,8 +563,11 @@ sp(false) -> 0.
|
||||||
%% The retained flag should be propagated for bridge.
|
%% The retained flag should be propagated for bridge.
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
clean_retain(false, Msg = #mqtt_message{retain = true}) ->
|
clean_retain(false, Msg = #mqtt_message{retain = true, headers = Headers}) ->
|
||||||
Msg#mqtt_message{retain = false};
|
case lists:member(retained, Headers) of
|
||||||
|
true -> Msg;
|
||||||
|
false -> Msg#mqtt_message{retain = false}
|
||||||
|
end;
|
||||||
clean_retain(_IsBridge, Msg) ->
|
clean_retain(_IsBridge, Msg) ->
|
||||||
Msg.
|
Msg.
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -286,8 +286,8 @@ init([CleanSess, {ClientId, Username}, ClientPid]) ->
|
||||||
{ok, QEnv} = emqttd:env(mqueue),
|
{ok, QEnv} = emqttd:env(mqueue),
|
||||||
MaxInflight = get_value(max_inflight, Env, 0),
|
MaxInflight = get_value(max_inflight, Env, 0),
|
||||||
EnableStats = get_value(enable_stats, Env, false),
|
EnableStats = get_value(enable_stats, Env, false),
|
||||||
IgnoreLoopDeliver = get_value(ignore_loop_deliver, Env, false),
|
|
||||||
ForceGcCount = emqttd_gc:conn_max_gc_count(),
|
ForceGcCount = emqttd_gc:conn_max_gc_count(),
|
||||||
|
IgnoreLoopDeliver = get_value(ignore_loop_deliver, Env, false),
|
||||||
MQueue = ?MQueue:new(ClientId, QEnv, emqttd_alarm:alarm_fun()),
|
MQueue = ?MQueue:new(ClientId, QEnv, emqttd_alarm:alarm_fun()),
|
||||||
State = #state{clean_sess = CleanSess,
|
State = #state{clean_sess = CleanSess,
|
||||||
binding = binding(ClientPid),
|
binding = binding(ClientPid),
|
||||||
|
@ -453,6 +453,8 @@ handle_cast({pubrel, PacketId}, State = #state{awaiting_rel = AwaitingRel}) ->
|
||||||
{noreply,
|
{noreply,
|
||||||
case maps:take(PacketId, AwaitingRel) of
|
case maps:take(PacketId, AwaitingRel) of
|
||||||
{Msg, AwaitingRel1} ->
|
{Msg, AwaitingRel1} ->
|
||||||
|
%% Implement Qos2 by method A [MQTT 4.33]
|
||||||
|
%% Dispatch to subscriber when received PUBREL
|
||||||
spawn(emqttd_server, publish, [Msg]), %%:)
|
spawn(emqttd_server, publish, [Msg]), %%:)
|
||||||
gc(State#state{awaiting_rel = AwaitingRel1});
|
gc(State#state{awaiting_rel = AwaitingRel1});
|
||||||
error ->
|
error ->
|
||||||
|
@ -628,8 +630,10 @@ retry_delivery(Force, [{Type, Msg, Ts} | Msgs], Now,
|
||||||
redeliver(Msg, State),
|
redeliver(Msg, State),
|
||||||
Inflight1 = Inflight:update(PacketId, {publish, Msg, Now}),
|
Inflight1 = Inflight:update(PacketId, {publish, Msg, Now}),
|
||||||
retry_delivery(Force, Msgs, Now, State#state{inflight = Inflight1});
|
retry_delivery(Force, Msgs, Now, State#state{inflight = Inflight1});
|
||||||
{pubrel, PacketId} -> %% remove 'pubrel' directly?
|
{pubrel, PacketId} ->
|
||||||
retry_delivery(Force, Msgs, Now, State#state{inflight = Inflight:delete(PacketId)})
|
redeliver({pubrel, PacketId}, State),
|
||||||
|
Inflight1 = Inflight:update(PacketId, {pubrel, PacketId, Now}),
|
||||||
|
retry_delivery(Force, Msgs, Now, State#state{inflight = Inflight1})
|
||||||
end;
|
end;
|
||||||
true ->
|
true ->
|
||||||
State#state{retry_timer = start_timer(Interval - Diff, retry_delivery)}
|
State#state{retry_timer = start_timer(Interval - Diff, retry_delivery)}
|
||||||
|
@ -649,11 +653,13 @@ expire_awaiting_rel(State = #state{awaiting_rel = AwaitingRel}) ->
|
||||||
expire_awaiting_rel([], _Now, State) ->
|
expire_awaiting_rel([], _Now, State) ->
|
||||||
State#state{await_rel_timer = undefined};
|
State#state{await_rel_timer = undefined};
|
||||||
|
|
||||||
expire_awaiting_rel([{PacketId, #mqtt_message{timestamp = TS}} | Msgs],
|
expire_awaiting_rel([{PacketId, Msg = #mqtt_message{timestamp = TS}} | Msgs],
|
||||||
Now, State = #state{awaiting_rel = AwaitingRel,
|
Now, State = #state{awaiting_rel = AwaitingRel,
|
||||||
await_rel_timeout = Timeout}) ->
|
await_rel_timeout = Timeout}) ->
|
||||||
case (timer:now_diff(Now, TS) div 1000) of
|
case (timer:now_diff(Now, TS) div 1000) of
|
||||||
Diff when Diff >= Timeout ->
|
Diff when Diff >= Timeout ->
|
||||||
|
?LOG(warning, "Dropped Qos2 Message for await_rel_timeout: ~p", [Msg], State),
|
||||||
|
emqttd_metrics:inc('messages/qos2/dropped'),
|
||||||
expire_awaiting_rel(Msgs, Now, State#state{awaiting_rel = maps:remove(PacketId, AwaitingRel)});
|
expire_awaiting_rel(Msgs, Now, State#state{awaiting_rel = maps:remove(PacketId, AwaitingRel)});
|
||||||
Diff ->
|
Diff ->
|
||||||
State#state{await_rel_timer = start_timer(Timeout - Diff, check_awaiting_rel)}
|
State#state{await_rel_timer = start_timer(Timeout - Diff, check_awaiting_rel)}
|
||||||
|
@ -714,7 +720,10 @@ enqueue_msg(Msg, State = #state{mqueue = Q}) ->
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
redeliver(Msg = #mqtt_message{qos = QoS}, State) ->
|
redeliver(Msg = #mqtt_message{qos = QoS}, State) ->
|
||||||
deliver(Msg#mqtt_message{dup = if QoS =:= ?QOS2 -> false; true -> true end}, State).
|
deliver(Msg#mqtt_message{dup = if QoS =:= ?QOS2 -> false; true -> true end}, State);
|
||||||
|
|
||||||
|
redeliver({pubrel, PacketId}, #state{client_pid = Pid}) ->
|
||||||
|
Pid ! {redeliver, {?PUBREL, PacketId}}.
|
||||||
|
|
||||||
deliver(Msg, #state{client_pid = Pid}) ->
|
deliver(Msg, #state{client_pid = Pid}) ->
|
||||||
inc_stats(deliver_msg),
|
inc_stats(deliver_msg),
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -61,18 +61,18 @@ wildcard([_H|T]) ->
|
||||||
-spec(match(Name, Filter) -> boolean() when
|
-spec(match(Name, Filter) -> boolean() when
|
||||||
Name :: topic() | words(),
|
Name :: topic() | words(),
|
||||||
Filter :: topic() | words()).
|
Filter :: topic() | words()).
|
||||||
|
match(<<$$, _/binary>>, <<$+, _/binary>>) ->
|
||||||
|
false;
|
||||||
|
match(<<$$, _/binary>>, <<$#, _/binary>>) ->
|
||||||
|
false;
|
||||||
match(Name, Filter) when is_binary(Name) and is_binary(Filter) ->
|
match(Name, Filter) when is_binary(Name) and is_binary(Filter) ->
|
||||||
match(words(Name), words(Filter));
|
match(words(Name), words(Filter));
|
||||||
match([], []) ->
|
match([], []) ->
|
||||||
true;
|
true;
|
||||||
match([H|T1], [H|T2]) ->
|
match([H|T1], [H|T2]) ->
|
||||||
match(T1, T2);
|
match(T1, T2);
|
||||||
match([<<$$, _/binary>>|_], ['+'|_]) ->
|
|
||||||
false;
|
|
||||||
match([_H|T1], ['+'|T2]) ->
|
match([_H|T1], ['+'|T2]) ->
|
||||||
match(T1, T2);
|
match(T1, T2);
|
||||||
match([<<$$, _/binary>>|_], ['#']) ->
|
|
||||||
false;
|
|
||||||
match(_, ['#']) ->
|
match(_, ['#']) ->
|
||||||
true;
|
true;
|
||||||
match([_H1|_], [_H2|_]) ->
|
match([_H1|_], [_H2|_]) ->
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -38,20 +38,29 @@ handle_request(Req) ->
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% MQTT Over WebSocket
|
%% MQTT Over WebSocket
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
handle_request('GET', "/mqtt", Req) ->
|
handle_request('GET', "/mqtt", Req) ->
|
||||||
lager:debug("WebSocket Connection from: ~s", [Req:get(peer)]),
|
lager:debug("WebSocket Connection from: ~s", [Req:get(peer)]),
|
||||||
Upgrade = Req:get_header_value("Upgrade"),
|
Upgrade = Req:get_header_value("Upgrade"),
|
||||||
Proto = check_protocol_header(Req),
|
Proto = check_protocol_header(Req),
|
||||||
case {is_websocket(Upgrade), Proto} of
|
case {is_websocket(Upgrade), Proto} of
|
||||||
{true, "mqtt" ++ _Vsn} ->
|
{true, "mqtt" ++ _Vsn} ->
|
||||||
|
case Req:get(peername) of
|
||||||
|
{ok, Peername} ->
|
||||||
{ok, ProtoEnv} = emqttd:env(protocol),
|
{ok, ProtoEnv} = emqttd:env(protocol),
|
||||||
PacketSize = get_value(max_packet_size, ProtoEnv, ?MAX_PACKET_SIZE),
|
PacketSize = get_value(max_packet_size, ProtoEnv, ?MAX_PACKET_SIZE),
|
||||||
Parser = emqttd_parser:initial_state(PacketSize),
|
Parser = emqttd_parser:initial_state(PacketSize),
|
||||||
%% Upgrade WebSocket.
|
%% Upgrade WebSocket.
|
||||||
{ReentryWs, ReplyChannel} = mochiweb_websocket:upgrade_connection(Req, fun ?MODULE:ws_loop/3),
|
{ReentryWs, ReplyChannel} = mochiweb_websocket:upgrade_connection(Req, fun ?MODULE:ws_loop/3),
|
||||||
{ok, ClientPid} = emqttd_ws_client_sup:start_client(self(), Req, ReplyChannel),
|
{ok, ClientPid} = emqttd_ws_client_sup:start_client(self(), Req, ReplyChannel),
|
||||||
ReentryWs(#wsocket_state{peername = Req:get(peername), parser = Parser,
|
ReentryWs(#wsocket_state{peername = Peername,
|
||||||
max_packet_size = PacketSize, client_pid = ClientPid});
|
parser = Parser,
|
||||||
|
max_packet_size = PacketSize,
|
||||||
|
client_pid = ClientPid});
|
||||||
|
{error, Reason} ->
|
||||||
|
lager:error("Get peername with error ~s", [Reason]),
|
||||||
|
Req:respond({400, [], <<"Bad Request">>})
|
||||||
|
end;
|
||||||
{false, _} ->
|
{false, _} ->
|
||||||
lager:error("Not WebSocket: Upgrade = ~s", [Upgrade]),
|
lager:error("Not WebSocket: Upgrade = ~s", [Upgrade]),
|
||||||
Req:respond({400, [], <<"Bad Request">>});
|
Req:respond({400, [], <<"Bad Request">>});
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -272,10 +272,14 @@ code_change(_OldVsn, State, _Extra) ->
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
send_fun(ReplyChannel) ->
|
send_fun(ReplyChannel) ->
|
||||||
|
Self = self(),
|
||||||
fun(Packet) ->
|
fun(Packet) ->
|
||||||
Data = emqttd_serializer:serialize(Packet),
|
Data = emqttd_serializer:serialize(Packet),
|
||||||
emqttd_metrics:inc('bytes/sent', iolist_size(Data)),
|
emqttd_metrics:inc('bytes/sent', iolist_size(Data)),
|
||||||
ReplyChannel({binary, Data})
|
case ReplyChannel({binary, Data}) of
|
||||||
|
ok -> ok;
|
||||||
|
{error, Reason} -> Self ! {shutdown, Reason}
|
||||||
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
stat_fun(Conn) ->
|
stat_fun(Conn) ->
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -58,7 +58,6 @@
|
||||||
all() ->
|
all() ->
|
||||||
[{group, protocol},
|
[{group, protocol},
|
||||||
{group, pubsub},
|
{group, pubsub},
|
||||||
{group, router},
|
|
||||||
{group, session},
|
{group, session},
|
||||||
{group, broker},
|
{group, broker},
|
||||||
{group, metrics},
|
{group, metrics},
|
||||||
|
@ -81,10 +80,6 @@ groups() ->
|
||||||
t_local_subscribe,
|
t_local_subscribe,
|
||||||
t_shared_subscribe,
|
t_shared_subscribe,
|
||||||
'pubsub#', 'pubsub+']},
|
'pubsub#', 'pubsub+']},
|
||||||
{router, [sequence],
|
|
||||||
[router_add_del,
|
|
||||||
router_print,
|
|
||||||
router_unused]},
|
|
||||||
{session, [sequence],
|
{session, [sequence],
|
||||||
[start_session]},
|
[start_session]},
|
||||||
{broker, [sequence],
|
{broker, [sequence],
|
||||||
|
@ -291,50 +286,6 @@ loop_recv(Topic, Timeout, Acc) ->
|
||||||
Timeout -> {ok, Acc}
|
Timeout -> {ok, Acc}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Router Test
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
|
|
||||||
router_add_del(_) ->
|
|
||||||
%% Add
|
|
||||||
emqttd_router:add_route(<<"#">>),
|
|
||||||
emqttd_router:add_route(<<"a/b/c">>),
|
|
||||||
emqttd_router:add_route(<<"+/#">>),
|
|
||||||
Routes = [R1, R2 | _] = [
|
|
||||||
#mqtt_route{topic = <<"#">>, node = node()},
|
|
||||||
#mqtt_route{topic = <<"+/#">>, node = node()},
|
|
||||||
#mqtt_route{topic = <<"a/b/c">>, node = node()}],
|
|
||||||
Routes = lists:sort(emqttd_router:match(<<"a/b/c">>)),
|
|
||||||
|
|
||||||
%% Batch Add
|
|
||||||
lists:foreach(fun(R) -> emqttd_router:add_route(R) end, Routes),
|
|
||||||
Routes = lists:sort(emqttd_router:match(<<"a/b/c">>)),
|
|
||||||
|
|
||||||
%% Del
|
|
||||||
emqttd_router:del_route(<<"a/b/c">>),
|
|
||||||
[R1, R2] = lists:sort(emqttd_router:match(<<"a/b/c">>)),
|
|
||||||
{atomic, []} = mnesia:transaction(fun emqttd_trie:lookup/1, [<<"a/b/c">>]),
|
|
||||||
|
|
||||||
%% Batch Del
|
|
||||||
R3 = #mqtt_route{topic = <<"#">>, node = 'a@127.0.0.1'},
|
|
||||||
emqttd_router:add_route(R3),
|
|
||||||
emqttd_router:del_route(R1),
|
|
||||||
emqttd_router:del_route(R2),
|
|
||||||
emqttd_router:del_route(R3),
|
|
||||||
[] = lists:sort(emqttd_router:match(<<"a/b/c">>)).
|
|
||||||
|
|
||||||
router_print(_) ->
|
|
||||||
Routes = [#mqtt_route{topic = <<"a/b/c">>, node = node()},
|
|
||||||
#mqtt_route{topic = <<"#">>, node = node()},
|
|
||||||
#mqtt_route{topic = <<"+/#">>, node = node()}],
|
|
||||||
lists:foreach(fun(R) -> emqttd_router:add_route(R) end, Routes),
|
|
||||||
emqttd_router:print(<<"a/b/c">>).
|
|
||||||
|
|
||||||
router_unused(_) ->
|
|
||||||
gen_server:call(emqttd_router, bad_call),
|
|
||||||
gen_server:cast(emqttd_router, bad_msg),
|
|
||||||
emqttd_router ! bad_info.
|
|
||||||
|
|
||||||
recv_loop(Msgs) ->
|
recv_loop(Msgs) ->
|
||||||
receive
|
receive
|
||||||
{dispatch, _Topic, Msg} ->
|
{dispatch, _Topic, Msg} ->
|
||||||
|
@ -598,6 +549,7 @@ conflict_listeners(_) ->
|
||||||
L = proplists:get_value("mqtt:tcp:0.0.0.0:1883", Listeners),
|
L = proplists:get_value("mqtt:tcp:0.0.0.0:1883", Listeners),
|
||||||
?assertEqual(1, proplists:get_value(current_clients, L)),
|
?assertEqual(1, proplists:get_value(current_clients, L)),
|
||||||
?assertEqual(1, proplists:get_value(conflict, proplists:get_value(shutdown_count, L))),
|
?assertEqual(1, proplists:get_value(conflict, proplists:get_value(shutdown_count, L))),
|
||||||
|
timer:sleep(100),
|
||||||
emqttc:disconnect(C2).
|
emqttc:disconnect(C2).
|
||||||
|
|
||||||
cli_vm(_) ->
|
cli_vm(_) ->
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -115,9 +115,9 @@ run_connection_cmd(_Config) ->
|
||||||
?assertEqual(1000, E).
|
?assertEqual(1000, E).
|
||||||
|
|
||||||
run_broker_config(_Config) ->
|
run_broker_config(_Config) ->
|
||||||
emqttd_cli_config:run(["config", "set", "mqtt.broker.sys_interval=10", "--app=emqttd"]),
|
emqttd_cli_config:run(["config", "set", "mqtt.broker.sys_interval=6000ms", "--app=emqttd"]),
|
||||||
{ok, E} = application:get_env(emqttd, broker_sys_interval),
|
{ok, E} = application:get_env(emqttd, broker_sys_interval),
|
||||||
?assertEqual(10, E).
|
?assertEqual(6000, E).
|
||||||
|
|
||||||
env_value("client", {Key, Type}) ->
|
env_value("client", {Key, Type}) ->
|
||||||
case string:split(Key, "=") of
|
case string:split(Key, "=") of
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%
|
%%
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
|
|
||||||
-module(emqttd_inflight_SUITE).
|
-module(emqttd_inflight_SUITE).
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -34,7 +34,8 @@ groups() ->
|
||||||
t_add_del_route,
|
t_add_del_route,
|
||||||
t_match_route,
|
t_match_route,
|
||||||
t_print,
|
t_print,
|
||||||
t_has_route]},
|
t_has_route,
|
||||||
|
router_unused]},
|
||||||
{local_route, [sequence],
|
{local_route, [sequence],
|
||||||
[t_get_local_topics,
|
[t_get_local_topics,
|
||||||
t_add_del_local_route,
|
t_add_del_local_route,
|
||||||
|
@ -86,11 +87,6 @@ t_match_route(_) ->
|
||||||
#mqtt_route{topic = <<"a/b/c">>, node = Node}],
|
#mqtt_route{topic = <<"a/b/c">>, node = Node}],
|
||||||
lists:sort(?R:match(<<"a/b/c">>))).
|
lists:sort(?R:match(<<"a/b/c">>))).
|
||||||
|
|
||||||
t_print(_) ->
|
|
||||||
?R:add_route(<<"topic">>),
|
|
||||||
?R:add_route(<<"topic/#">>),
|
|
||||||
?R:print(<<"topic">>).
|
|
||||||
|
|
||||||
t_has_route(_) ->
|
t_has_route(_) ->
|
||||||
?R:add_route(<<"devices/+/messages">>),
|
?R:add_route(<<"devices/+/messages">>),
|
||||||
?assert(?R:has_route(<<"devices/+/messages">>)).
|
?assert(?R:has_route(<<"devices/+/messages">>)).
|
||||||
|
@ -130,3 +126,49 @@ clear_tables() ->
|
||||||
?R:clean_local_routes(),
|
?R:clean_local_routes(),
|
||||||
lists:foreach(fun mnesia:clear_table/1, [mqtt_route, mqtt_trie, mqtt_trie_node]).
|
lists:foreach(fun mnesia:clear_table/1, [mqtt_route, mqtt_trie, mqtt_trie_node]).
|
||||||
|
|
||||||
|
%%--------------------------------------------------------------------
|
||||||
|
%% Router Test
|
||||||
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
|
router_add_del(_) ->
|
||||||
|
%% Add
|
||||||
|
?R:add_route(<<"#">>),
|
||||||
|
?R:add_route(<<"a/b/c">>),
|
||||||
|
?R:add_route(<<"+/#">>),
|
||||||
|
Routes = [R1, R2 | _] = [
|
||||||
|
#mqtt_route{topic = <<"#">>, node = node()},
|
||||||
|
#mqtt_route{topic = <<"+/#">>, node = node()},
|
||||||
|
#mqtt_route{topic = <<"a/b/c">>, node = node()}],
|
||||||
|
Routes = lists:sort(?R:match(<<"a/b/c">>)),
|
||||||
|
|
||||||
|
%% Batch Add
|
||||||
|
lists:foreach(fun(R) -> ?R:add_route(R) end, Routes),
|
||||||
|
Routes = lists:sort(?R:match(<<"a/b/c">>)),
|
||||||
|
|
||||||
|
%% Del
|
||||||
|
?R:del_route(<<"a/b/c">>),
|
||||||
|
[R1, R2] = lists:sort(?R:match(<<"a/b/c">>)),
|
||||||
|
{atomic, []} = mnesia:transaction(fun emqttd_trie:lookup/1, [<<"a/b/c">>]),
|
||||||
|
|
||||||
|
%% Batch Del
|
||||||
|
R3 = #mqtt_route{topic = <<"#">>, node = 'a@127.0.0.1'},
|
||||||
|
?R:add_route(R3),
|
||||||
|
?R:del_route(R1),
|
||||||
|
?R:del_route(R2),
|
||||||
|
?R:del_route(R3),
|
||||||
|
[] = lists:sort(?R:match(<<"a/b/c">>)).
|
||||||
|
|
||||||
|
t_print(_) ->
|
||||||
|
Routes = [#mqtt_route{topic = <<"a/b/c">>, node = node()},
|
||||||
|
#mqtt_route{topic = <<"#">>, node = node()},
|
||||||
|
#mqtt_route{topic = <<"+/#">>, node = node()}],
|
||||||
|
lists:foreach(fun(R) -> ?R:add_route(R) end, Routes),
|
||||||
|
?R:print(<<"a/b/c">>),
|
||||||
|
?R:del_route(<<"+/#">>),
|
||||||
|
?R:del_route(<<"a/b/c">>),
|
||||||
|
?R:del_route(<<"#">>).
|
||||||
|
|
||||||
|
router_unused(_) ->
|
||||||
|
gen_server:call(emqttd_router, bad_call),
|
||||||
|
gen_server:cast(emqttd_router, bad_msg),
|
||||||
|
emqttd_router ! bad_info.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -73,10 +73,10 @@ t_match2(_) ->
|
||||||
|
|
||||||
t_match3(_) ->
|
t_match3(_) ->
|
||||||
true = match(<<"device/60019423a83c/fw">>, <<"device/60019423a83c/#">>),
|
true = match(<<"device/60019423a83c/fw">>, <<"device/60019423a83c/#">>),
|
||||||
false = match(<<"device/60019423a83c/$fw">>, <<"device/60019423a83c/#">>),
|
true = match(<<"device/60019423a83c/$fw">>, <<"device/60019423a83c/#">>),
|
||||||
true = match(<<"device/60019423a83c/$fw/fw">>, <<"device/60019423a83c/$fw/#">>),
|
true = match(<<"device/60019423a83c/$fw/fw">>, <<"device/60019423a83c/$fw/#">>),
|
||||||
true = match(<<"device/60019423a83c/fw/checksum">>, <<"device/60019423a83c/#">>),
|
true = match(<<"device/60019423a83c/fw/checksum">>, <<"device/60019423a83c/#">>),
|
||||||
false = match(<<"device/60019423a83c/$fw/checksum">>, <<"device/60019423a83c/#">>),
|
true = match(<<"device/60019423a83c/$fw/checksum">>, <<"device/60019423a83c/#">>),
|
||||||
true = match(<<"device/60019423a83c/dust/type">>, <<"device/60019423a83c/#">>).
|
true = match(<<"device/60019423a83c/dust/type">>, <<"device/60019423a83c/#">>).
|
||||||
|
|
||||||
t_sigle_level_match(_) ->
|
t_sigle_level_match(_) ->
|
||||||
|
@ -86,7 +86,9 @@ t_sigle_level_match(_) ->
|
||||||
true = match(<<"sport/">>, <<"sport/+">>),
|
true = match(<<"sport/">>, <<"sport/+">>),
|
||||||
true = match(<<"/finance">>, <<"+/+">>),
|
true = match(<<"/finance">>, <<"+/+">>),
|
||||||
true = match(<<"/finance">>, <<"/+">>),
|
true = match(<<"/finance">>, <<"/+">>),
|
||||||
false = match(<<"/finance">>, <<"+">>).
|
false = match(<<"/finance">>, <<"+">>),
|
||||||
|
true = match(<<"/devices/$dev1">>, <<"/devices/+">>),
|
||||||
|
true = match(<<"/devices/$dev1/online">>, <<"/devices/+/online">>).
|
||||||
|
|
||||||
t_sys_match(_) ->
|
t_sys_match(_) ->
|
||||||
true = match(<<"$SYS/broker/clients/testclient">>, <<"$SYS/#">>),
|
true = match(<<"$SYS/broker/clients/testclient">>, <<"$SYS/#">>),
|
||||||
|
@ -97,7 +99,9 @@ t_sys_match(_) ->
|
||||||
't_#_match'(_) ->
|
't_#_match'(_) ->
|
||||||
true = match(<<"a/b/c">>, <<"#">>),
|
true = match(<<"a/b/c">>, <<"#">>),
|
||||||
true = match(<<"a/b/c">>, <<"+/#">>),
|
true = match(<<"a/b/c">>, <<"+/#">>),
|
||||||
false = match(<<"$SYS/brokers">>, <<"#">>).
|
false = match(<<"$SYS/brokers">>, <<"#">>),
|
||||||
|
true = match(<<"a/b/$c">>, <<"a/b/#">>),
|
||||||
|
true = match(<<"a/b/$c">>, <<"a/#">>).
|
||||||
|
|
||||||
t_match_perf(_) ->
|
t_match_perf(_) ->
|
||||||
true = match(<<"a/b/ccc">>, <<"a/#">>),
|
true = match(<<"a/b/ccc">>, <<"a/#">>),
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
%% Copyright (c) 2013-2018 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
Loading…
Reference in New Issue