Просмотр исходного кода

Merge pull request #3900 from zmstone/chore-build-resync-apps

chore(build): resync apps
Zaiming Shi 5 лет назад
Родитель
Сommit
3e1787d6bb
85 измененных файлов с 544 добавлено и 378 удалено
  1. 1 0
      .tool-versions
  2. 9 9
      Makefile
  3. 15 2
      apps/emqx_auth_http/src/emqx_auth_http_app.erl
  4. 0 10
      apps/emqx_auth_jwt/src/emqx_auth_jwt.appup.src
  5. 26 0
      apps/emqx_auth_ldap/.ci/docker-compose.yml
  6. 26 0
      apps/emqx_auth_ldap/.ci/emqx-ldap/Dockerfile
  7. 16 0
      apps/emqx_auth_ldap/.ci/emqx-ldap/slapd.conf
  8. 29 4
      apps/emqx_auth_mnesia/src/emqx_auth_mnesia.erl
  9. 0 9
      apps/emqx_auth_mysql/src/emqx_auth_mysql.appup.src
  10. 30 0
      apps/emqx_auth_pgsql/.ci/docker-compose.yml
  11. 8 0
      apps/emqx_auth_pgsql/.ci/pgsql/Dockerfile
  12. 0 9
      apps/emqx_auth_pgsql/src/emqx_auth_pgsql.appup.src
  13. 39 0
      apps/emqx_auth_redis/.ci/docker-compose-cluster-tls.yml
  14. 38 0
      apps/emqx_auth_redis/.ci/docker-compose-cluster.yml
  15. 31 0
      apps/emqx_auth_redis/.ci/docker-compose-tls.yml
  16. 25 0
      apps/emqx_auth_redis/.ci/docker-compose.yml
  17. 3 0
      apps/emqx_auth_redis/.ci/redis/redis.conf
  18. 71 0
      apps/emqx_auth_redis/.ci/redis/redis.sh
  19. 2 0
      apps/emqx_auth_redis/.gitignore
  20. 0 10
      apps/emqx_auth_redis/src/emqx_auth_redis.appup.src
  21. 26 10
      apps/emqx_auth_redis/test/emqx_auth_redis_SUITE.erl
  22. 0 10
      apps/emqx_bridge_mqtt/src/emqx_bridge_mqtt.appup.src
  23. 0 8
      apps/emqx_dashboard/priv/www/static/js/0.7a09d1383e1319441399.js
  24. 0 8
      apps/emqx_dashboard/priv/www/static/js/2.71ffb214c95162432f13.js
  25. 0 1
      apps/emqx_dashboard/priv/www/static/js/20.308aa0fdf6653ef3299f.js
  26. 0 1
      apps/emqx_dashboard/priv/www/static/js/22.d968dc6f54a690adde18.js
  27. 0 1
      apps/emqx_dashboard/priv/www/static/js/3.25b49772270df4b9915d.js
  28. 0 1
      apps/emqx_dashboard/priv/www/static/js/5.8935139a413f40d70253.js
  29. 0 1
      apps/emqx_dashboard/priv/www/static/js/8.e86f6131cc8a9138368d.js
  30. 0 1
      apps/emqx_dashboard/priv/www/static/js/manifest.b28890b7e119092c6f70.js
  31. 0 24
      apps/emqx_exhook/src/emqx_exhook.app.src.script
  32. 0 9
      apps/emqx_exhook/src/emqx_exhook.appup.src
  33. 0 24
      apps/emqx_exproto/src/emqx_exproto.app.src.script
  34. 0 9
      apps/emqx_exproto/src/emqx_exproto.appup.src
  35. 1 0
      apps/emqx_lwm2m/rebar.config
  36. 16 1
      apps/emqx_management/src/emqx_mgmt.erl
  37. 9 6
      apps/emqx_management/src/emqx_mgmt_api_data.erl
  38. 4 2
      apps/emqx_management/src/emqx_mgmt_cli.erl
  39. 0 8
      apps/emqx_rule_engine/src/emqx_rule_engine.appup.src
  40. 45 75
      apps/emqx_rule_engine/src/emqx_rule_funcs.erl
  41. 4 57
      apps/emqx_rule_engine/test/emqx_rule_funcs_SUITE.erl
  42. 1 1
      apps/emqx_sasl/test/emqx_sasl_scram_SUITE.erl
  43. 0 9
      apps/emqx_web_hook/src/emqx_web_hook.appup.src
  44. 0 4
      packages.mk
  45. 16 2
      rebar.config
  46. 5 4
      sync-apps.sh
  47. 1 1
      test/emqx_SUITE.erl
  48. 1 1
      test/emqx_access_control_SUITE.erl
  49. 2 2
      test/emqx_alarm_SUITE.erl
  50. 1 1
      test/emqx_banned_SUITE.erl
  51. 2 2
      test/emqx_broker_SUITE.erl
  52. 2 2
      test/emqx_channel_SUITE.erl
  53. 1 1
      test/emqx_client_SUITE.erl
  54. 1 1
      test/emqx_cm_SUITE.erl
  55. 1 1
      test/emqx_connection_SUITE.erl
  56. 1 1
      test/emqx_frame_SUITE.erl
  57. 2 2
      test/emqx_listeners_SUITE.erl
  58. 2 2
      test/emqx_message_SUITE.erl
  59. 1 1
      test/emqx_metrics_SUITE.erl
  60. 1 1
      test/emqx_mod_acl_internal_SUITE.erl
  61. 1 1
      test/emqx_mod_delayed_SUITE.erl
  62. 1 1
      test/emqx_mod_presence_SUITE.erl
  63. 1 1
      test/emqx_mod_rewrite_SUITE.erl
  64. 1 1
      test/emqx_mod_subscription_SUITE.erl
  65. 1 1
      test/emqx_mountpoint_SUITE.erl
  66. 1 1
      test/emqx_mqtt_SUITE.erl
  67. 1 1
      test/emqx_mqtt_caps_SUITE.erl
  68. 1 1
      test/emqx_mqtt_props_SUITE.erl
  69. 2 2
      test/emqx_mqueue_SUITE.erl
  70. 2 2
      test/emqx_packet_SUITE.erl
  71. 1 1
      test/emqx_plugins_SUITE.erl
  72. 1 1
      test/emqx_reason_codes_SUITE.erl
  73. 1 1
      test/emqx_request_handler.erl
  74. 1 1
      test/emqx_request_responser_SUITE.erl
  75. 1 1
      test/emqx_request_sender.erl
  76. 1 1
      test/emqx_router_SUITE.erl
  77. 1 1
      test/emqx_session_SUITE.erl
  78. 1 1
      test/emqx_shared_sub_SUITE.erl
  79. 1 1
      test/emqx_sys_mon_SUITE.erl
  80. 1 1
      test/emqx_takeover_SUITE.erl
  81. 1 1
      test/emqx_trie_SUITE.erl
  82. 2 2
      test/emqx_ws_connection_SUITE.erl
  83. 2 2
      test/mqtt_protocol_v5_SUITE.erl
  84. 1 1
      test/props/prop_emqx_frame.erl
  85. 1 1
      test/props/prop_emqx_reason_codes.erl

+ 1 - 0
.tool-versions

@@ -0,0 +1 @@
+erlang 22.3.4.13

+ 9 - 9
Makefile

@@ -1,4 +1,4 @@
-REBAR_VERSION = 3.14.3-emqx-1
+REBAR_VERSION = 3.14.3-emqx-2
 REBAR = ./rebar3
 
 PROFILE ?= emqx
@@ -19,14 +19,6 @@ ensure-rebar3:
 
 $(REBAR): ensure-rebar3
 
-.PHONY: xref
-xref: $(REBAR)
-	$(REBAR) xref
-
-.PHONY: dialyzer
-dialyzer: $(REBAR)
-	$(REBAR) dialyzer
-
 .PHONY: distclean
 distclean:
 	@rm -rf _build
@@ -66,5 +58,13 @@ else
 endif
 	$(REBAR) as $(@:deps-%=%) get-deps
 
+.PHONY: xref
+xref: $(REBAR)
+	$(REBAR) as check xref
+
+.PHONY: dialyzer
+dialyzer: $(REBAR)
+	$(REBAR) as check dialyzer
+
 include packages.mk
 include docker.mk

+ 15 - 2
apps/emqx_auth_http/src/emqx_auth_http_app.erl

@@ -119,7 +119,7 @@ translate_env() ->
                             #{host := Host0,
                               port := Port,
                               path := Path} = uri_string:parse(list_to_binary(URL)),
-                            {ok, Host} = inet:parse_address(binary_to_list(Host0)),
+                            Host = get_addr(binary_to_list(Host0)),
                             [{Name, {Host, Port, binary_to_list(Path)}} | Acc]
                     end
                 end, [], [acl_req, auth_req, super_req]),
@@ -144,4 +144,17 @@ same_host_and_port([{_, {Host, Port, _}}, {_, {Host, Port, _}}]) ->
 same_host_and_port([{_, {Host, Port, _}}, URL = {_, {Host, Port, _}} | Rest]) ->
     same_host_and_port([URL | Rest]);
 same_host_and_port(_) ->
-    false.
+    false.
+
+get_addr(Hostname) ->
+    case inet:parse_address(Hostname) of
+        {ok, {_,_,_,_} = Addr} -> Addr;
+        {ok, {_,_,_,_,_,_,_,_} = Addr} -> Addr;
+        {error, einval} ->
+            case inet:getaddr(Hostname, inet) of
+                 {error, _} ->
+                     {ok, Addr} = inet:getaddr(Hostname, inet6),
+                     Addr;
+                 {ok, Addr} -> Addr
+            end
+    end.

+ 0 - 10
apps/emqx_auth_jwt/src/emqx_auth_jwt.appup.src

@@ -1,10 +0,0 @@
-%% -*-: erlang -*-
-
-{VSN,
-  [
-    {<<".*">>, []}
-  ],
-  [
-    {<<".*">>, []}
-  ]
-}.

+ 26 - 0
apps/emqx_auth_ldap/.ci/docker-compose.yml

@@ -0,0 +1,26 @@
+version: '3'
+
+services:
+  erlang:
+    image: erlang:22.1
+    volumes:
+      - ../:/emqx_auth_ldap
+    networks:
+      - emqx_bridge
+    depends_on:
+      - ldap_server
+    tty: true
+
+  ldap_server:
+    build: ./emqx-ldap
+    image: emqx-ldap:1.0
+    restart: always
+    ports:
+      - 389:389
+      - 636:636
+    networks:
+      - emqx_bridge
+
+networks:
+  emqx_bridge:
+    driver: bridge

+ 26 - 0
apps/emqx_auth_ldap/.ci/emqx-ldap/Dockerfile

@@ -0,0 +1,26 @@
+FROM buildpack-deps:stretch
+
+ENV VERSION=2.4.50
+
+RUN apt-get update && apt-get install -y groff groff-base
+RUN wget ftp://ftp.openldap.org/pub/OpenLDAP/openldap-release/openldap-${VERSION}.tgz \
+    && gunzip -c openldap-${VERSION}.tgz | tar xvfB - \
+    && cd openldap-${VERSION} \
+    && ./configure && make depend && make && make install \
+    && cd .. && rm -rf  openldap-${VERSION}
+
+COPY ./slapd.conf /usr/local/etc/openldap/slapd.conf
+COPY ./emqx.io.ldif /usr/local/etc/openldap/schema/emqx.io.ldif
+COPY ./emqx.schema /usr/local/etc/openldap/schema/emqx.schema
+COPY ./*.pem /usr/local/etc/openldap/
+
+RUN mkdir -p /usr/local/etc/openldap/data \
+    && slapadd -l /usr/local/etc/openldap/schema/emqx.io.ldif -f /usr/local/etc/openldap/slapd.conf
+
+WORKDIR /usr/local/etc/openldap
+
+EXPOSE 389 636
+
+ENTRYPOINT ["/usr/local/libexec/slapd", "-h", "ldap:/// ldaps:///", "-d", "3", "-f", "/usr/local/etc/openldap/slapd.conf"]
+
+CMD []

+ 16 - 0
apps/emqx_auth_ldap/.ci/emqx-ldap/slapd.conf

@@ -0,0 +1,16 @@
+include         /usr/local/etc/openldap/schema/core.schema
+include         /usr/local/etc/openldap/schema/cosine.schema
+include         /usr/local/etc/openldap/schema/inetorgperson.schema
+include         /usr/local/etc/openldap/schema/ppolicy.schema
+include         /usr/local/etc/openldap/schema/emqx.schema
+
+TLSCACertificateFile  /usr/local/etc/openldap/cacert.pem
+TLSCertificateFile    /usr/local/etc/openldap/cert.pem
+TLSCertificateKeyFile /usr/local/etc/openldap/key.pem
+
+database bdb
+suffix "dc=emqx,dc=io"
+rootdn "cn=root,dc=emqx,dc=io"
+rootpw {SSHA}eoF7NhNrejVYYyGHqnt+MdKNBh4r1w3W
+
+directory       /usr/local/etc/openldap/data

+ 29 - 4
apps/emqx_auth_mnesia/src/emqx_auth_mnesia.erl

@@ -63,10 +63,8 @@ check(ClientInfo = #{ clientid := Clientid
             emqx_metrics:inc(?AUTH_METRICS(ignore)),
             ok;
         List ->
-            case [ Hash  || <<Salt:4/binary, Hash/binary>> <- lists:sort(fun emqx_auth_mnesia_cli:comparing/2, List),
-                            Hash =:= hash(NPassword, Salt, HashType)
-                 ] of
-                [] ->
+            case match_password(NPassword, HashType, List)  of
+                false ->
                     ?LOG(error, "[Mnesia] Auth from mnesia failed: ~p", [ClientInfo]),
                     emqx_metrics:inc(?AUTH_METRICS(failure)),
                     {stop, AuthResult#{anonymous => false, auth_result => password_error}};
@@ -78,7 +76,34 @@ check(ClientInfo = #{ clientid := Clientid
 
 description() -> "Authentication with Mnesia".
 
+match_password(Password, HashType, HashList) ->
+    lists:any(
+      fun(Secret) ->
+        case is_salt_hash(Secret, HashType) of
+            true ->
+                <<Salt:4/binary, Hash/binary>> = Secret,
+                Hash =:= hash(Password, Salt, HashType);
+            _ ->
+                Secret =:= hash(Password, HashType)
+        end
+      end, HashList).
+
+hash(undefined, HashType) ->
+    hash(<<>>, HashType);
+hash(Password, HashType) ->
+    emqx_passwd:hash(HashType, Password).
+
 hash(undefined, SaltBin, HashType) ->
     hash(<<>>, SaltBin, HashType);
 hash(Password, SaltBin, HashType) ->
     emqx_passwd:hash(HashType, <<SaltBin/binary, Password/binary>>).
+
+is_salt_hash(_, plain) ->
+    true;
+is_salt_hash(Secret, HashType) ->
+    not (byte_size(Secret) == len(HashType)).
+
+len(md5) -> 32;
+len(sha) -> 40;
+len(sha256) -> 64;
+len(sha512) -> 128.

+ 0 - 9
apps/emqx_auth_mysql/src/emqx_auth_mysql.appup.src

@@ -1,9 +0,0 @@
-%% -*-: erlang -*-
-{VSN,
-   [
-     {<<".*">>, []}
-   ],
-   [
-     {<<".*">>, []}
-   ]
-}.

+ 30 - 0
apps/emqx_auth_pgsql/.ci/docker-compose.yml

@@ -0,0 +1,30 @@
+version: '3'
+
+services:
+  erlang:
+    image: erlang:22.3
+    volumes:
+      - ../:/emqx_auth_pgsql
+    networks:
+      - emqx_bridge
+    depends_on:
+      - pgsql_server
+    tty: true
+
+  pgsql_server:
+    build:
+        context: ./pgsql
+        args:
+            BUILD_FROM: postgres:${PGSQL_TAG}
+    image: emqx-pgsql
+    restart: always
+    environment:
+      POSTGRES_PASSWORD: public
+      POSTGRES_USER: root
+      POSTGRES_DB: mqtt
+    networks:
+      - emqx_bridge
+
+networks:
+  emqx_bridge:
+    driver: bridge

+ 8 - 0
apps/emqx_auth_pgsql/.ci/pgsql/Dockerfile

@@ -0,0 +1,8 @@
+ARG BUILD_FROM=postgres:11
+FROM ${BUILD_FROM}
+COPY pg.conf /etc/postgresql/postgresql.conf
+COPY server-cert.pem /etc/postgresql/server-cert.pem
+COPY server-key.pem /etc/postgresql/server-key.pem
+RUN chown -R postgres:postgres /etc/postgresql \
+    && chmod 600 /etc/postgresql/*.pem 
+CMD ["-c", "config_file=/etc/postgresql/postgresql.conf"]

+ 0 - 9
apps/emqx_auth_pgsql/src/emqx_auth_pgsql.appup.src

@@ -1,9 +0,0 @@
-%% -*-: erlang -*-
-{VSN,
-   [
-     {<<".*">>, []}
-   ],
-   [
-     {<<".*">>, []}
-   ]
-}.

+ 39 - 0
apps/emqx_auth_redis/.ci/docker-compose-cluster-tls.yml

@@ -0,0 +1,39 @@
+version: '2.4'
+# network configuration is limited in version 3
+# https://github.com/docker/compose/issues/4958
+
+services:
+  erlang:
+    image: erlang:22.3
+    volumes:
+      - ../:/emqx_auth_redis
+    networks:
+      - app_net
+    depends_on:
+      - redis_cluster
+    tty: true
+
+  redis_cluster:
+    image: redis:6.0.9
+    container_name: redis-cluster
+    volumes:
+      - ../test/emqx_auth_redis_SUITE_data/certs:/tls
+      - ./redis/:/data/conf
+    command: bash -c "/bin/bash /data/conf/redis.sh -t && while true; do echo 1; sleep 1; done"
+    networks:
+      app_net:
+        # Assign a public address. Erlang container cannot find cluster nodes by network-scoped alias (redis_cluster).
+        ipv4_address: 172.16.239.10
+        ipv6_address: 2001:3200:3200::20
+
+networks:
+  app_net:
+    driver: bridge
+    enable_ipv6: true
+    ipam:
+      driver: default
+      config:
+        - subnet: 172.16.239.0/24
+          gateway: 172.16.239.1
+        - subnet: 2001:3200:3200::/64
+          gateway: 2001:3200:3200::1

+ 38 - 0
apps/emqx_auth_redis/.ci/docker-compose-cluster.yml

@@ -0,0 +1,38 @@
+version: '2.4'
+# network configuration is limited in version 3
+# https://github.com/docker/compose/issues/4958
+
+services:
+  erlang:
+    image: erlang:22.3
+    volumes:
+      - ../:/emqx_auth_redis
+    networks:
+      - app_net
+    depends_on:
+      - redis_cluster
+    tty: true
+
+  redis_cluster:
+    image: redis:${REDIS_TAG}
+    container_name: redis-cluster
+    volumes:
+      - ./redis/:/data/conf
+    command: bash -c "/bin/bash /data/conf/redis.sh && while true; do echo 1; sleep 1; done"
+    networks:
+      app_net:
+        # Assign a public address. Erlang container cannot find cluster nodes by network-scoped alias (redis_cluster).
+        ipv4_address: 172.16.239.10
+        ipv6_address: 2001:3200:3200::20
+
+networks:
+  app_net:
+    driver: bridge
+    enable_ipv6: true
+    ipam:
+      driver: default
+      config:
+        - subnet: 172.16.239.0/24
+          gateway: 172.16.239.1
+        - subnet: 2001:3200:3200::/64
+          gateway: 2001:3200:3200::1

+ 31 - 0
apps/emqx_auth_redis/.ci/docker-compose-tls.yml

@@ -0,0 +1,31 @@
+version: '3'
+
+services:
+  erlang:
+    image: erlang:22.3
+    volumes:
+      - ../:/emqx_auth_redis
+    networks:
+      - emqx_bridge
+    depends_on:
+      - redis_server
+    tty: true
+
+  redis_server:
+    image: redis:6.0.9
+    volumes:
+      - ../test/emqx_auth_redis_SUITE_data/certs:/tls
+    command:
+      - redis-server
+      - "--bind 0.0.0.0 ::"
+      - --tls-port 6380
+      - --tls-cert-file /tls/redis.crt
+      - --tls-key-file /tls/redis.key
+      - --tls-ca-cert-file /tls/ca.crt
+    restart: always
+    networks:
+      - emqx_bridge
+
+networks:
+  emqx_bridge:
+    driver: bridge

+ 25 - 0
apps/emqx_auth_redis/.ci/docker-compose.yml

@@ -0,0 +1,25 @@
+version: '3'
+
+services:
+  erlang:
+    image: erlang:22.3
+    volumes:
+      - ../:/emqx_auth_redis    
+    networks:
+      - emqx_bridge
+    depends_on:
+      - redis_server
+    tty: true
+
+  redis_server:
+    image: redis:${REDIS_TAG}
+    command:
+        - redis-server
+        - "--bind 0.0.0.0 ::"
+    restart: always
+    networks:
+      - emqx_bridge
+
+networks:
+  emqx_bridge:
+    driver: bridge

+ 3 - 0
apps/emqx_auth_redis/.ci/redis/redis.conf

@@ -0,0 +1,3 @@
+cluster-enabled      yes
+cluster-node-timeout 10000
+bind 0.0.0.0 :: 

+ 71 - 0
apps/emqx_auth_redis/.ci/redis/redis.sh

@@ -0,0 +1,71 @@
+#!/bin/bash
+
+tls=false;
+while getopts t OPT
+do
+    case $OPT in
+        t)  tls=true
+            ;;
+        \?) exit
+            ;;
+    esac
+done
+
+rm -f \
+    /data/conf/r7000i.log \
+    /data/conf/r7001i.log \
+    /data/conf/r7002i.log \
+    /data/conf/nodes.7000.conf \
+    /data/conf/nodes.7001.conf \
+    /data/conf/nodes.7002.conf ;
+
+if  $tls ; then
+  redis-server /data/conf/redis.conf --port 7000 --cluster-config-file /data/conf/nodes.7000.conf --daemonize yes \
+                                     --tls-port 8000 \
+                                     --tls-cert-file /tls/redis.crt \
+                                     --tls-key-file /tls/redis.key \
+                                     --tls-ca-cert-file /tls/ca.crt
+  redis-server /data/conf/redis.conf --port 7001 --cluster-config-file /data/conf/nodes.7001.conf --daemonize yes \
+                                     --tls-port 8001 \
+                                     --tls-cert-file /tls/redis.crt \
+                                     --tls-key-file /tls/redis.key \
+                                     --tls-ca-cert-file /tls/ca.crt
+  redis-server /data/conf/redis.conf --port 7002 --cluster-config-file /data/conf/nodes.7002.conf --daemonize yes \
+                                     --tls-port 8002 \
+                                     --tls-cert-file /tls/redis.crt \
+                                     --tls-key-file /tls/redis.key \
+                                     --tls-ca-cert-file /tls/ca.crt
+else
+  redis-server /data/conf/redis.conf --port 7000 --cluster-config-file /data/conf/nodes.7000.conf --daemonize yes ;
+  redis-server /data/conf/redis.conf --port 7001 --cluster-config-file /data/conf/nodes.7001.conf --daemonize yes ;
+  redis-server /data/conf/redis.conf --port 7002 --cluster-config-file /data/conf/nodes.7002.conf --daemonize yes ;
+fi
+
+REDIS_LOAD_FLG=true;
+
+while $REDIS_LOAD_FLG;
+do
+    sleep 1;
+    redis-cli -p 7000 info 1> /data/conf/r7000i.log 2> /dev/null;
+    if [ -s /data/conf/r7000i.log ]; then
+        :
+    else
+        continue;
+    fi
+    redis-cli -p 7001 info 1> /data/conf/r7001i.log 2> /dev/null;
+    if [ -s /data/conf/r7001i.log ]; then
+        :
+    else
+        continue;
+    fi
+    redis-cli -p 7002 info 1> /data/conf/r7002i.log 2> /dev/null;
+    if [ -s /data/conf/r7002i.log ]; then
+        :
+    else
+        continue;
+    fi
+    yes "yes" | redis-cli --cluster create 172.16.239.10:7000 172.16.239.10:7001 172.16.239.10:7002;
+    REDIS_LOAD_FLG=false;
+done
+
+exit 0;

+ 2 - 0
apps/emqx_auth_redis/.gitignore

@@ -24,3 +24,5 @@ erlang.mk
 rebar.lock
 /.idea/
 .DS_Store
+/.ci/redis/nodes.*.conf
+/.ci/redis/*.log

+ 0 - 10
apps/emqx_auth_redis/src/emqx_auth_redis.appup.src

@@ -1,10 +0,0 @@
-%% -*-: erlang -*-
-
-{VSN,
-   [
-     {<<".*">>, []}
-   ],
-   [
-     {<<".*">>, []}
-   ]
-}.

+ 26 - 10
apps/emqx_auth_redis/test/emqx_auth_redis_SUITE.erl

@@ -69,21 +69,18 @@ set_special_configs(_App) ->
     ok.
 
 init_redis_rows() ->
-    {ok, Connection} = ?POOL(?APP),
     %% Users
-    [eredis:q(Connection, ["HMSET", Key|FiledValue]) || {Key, FiledValue} <- ?INIT_AUTH],
-
+    [q(["HMSET", Key|FiledValue]) || {Key, FiledValue} <- ?INIT_AUTH],
     %% ACLs
     emqx_modules:load_module(emqx_mod_acl_internal, false),
-    Result = [eredis:q(Connection, ["HSET", Key, Filed, Value]) || {Key, Filed, Value} <- ?INIT_ACL],
+    Result = [q(["HSET", Key, Filed, Value]) || {Key, Filed, Value} <- ?INIT_ACL],
     ct:pal("redis init result: ~p~n", [Result]).
 
 deinit_redis_rows() ->
-    {ok, Connection} = ?POOL(?APP),
     AuthKeys = [Key || {Key, _Filed, _Value} <- ?INIT_AUTH],
     AclKeys = [Key || {Key, _Value} <- ?INIT_ACL],
-    eredis:q(Connection, ["DEL" | AuthKeys]),
-    eredis:q(Connection, ["DEL" | AclKeys]).
+    q(["DEL" | AuthKeys]),
+    q(["DEL" | AclKeys]).
 
 %%--------------------------------------------------------------------
 %% Cases
@@ -121,9 +118,8 @@ t_check_auth(_) ->
     {error, _} = emqx_access_control:authenticate(Bcrypt#{password => <<"password">>}).
 
 t_check_auth_hget(_) ->
-    {ok, Connection} = ?POOL(?APP),
-    eredis:q(Connection, ["HSET", "mqtt_user:hset", "password", "hset"]),
-    eredis:q(Connection, ["HSET", "mqtt_user:hset", "is_superuser", "1"]),
+    q(["HSET", "mqtt_user:hset", "password", "hset"]),
+    q(["HSET", "mqtt_user:hset", "is_superuser", "1"]),
     reload([{password_hash, plain}, {auth_cmd, "HGET mqtt_user:%u password"}]),
     Hset = #{clientid => <<"hset">>, username => <<"hset">>, zone => external},
     {ok, #{is_superuser := true}} = emqx_access_control:authenticate(Hset#{password => <<"hset">>}).
@@ -164,6 +160,16 @@ t_acl_super(_) ->
     end,
     emqtt:disconnect(C).
 
+t_check_cluster_connection(_) ->
+    ?assertMatch({error, _Reason}, reload([{server, [{type,cluster},
+                                           {pool_size,8},
+                                           {auto_reconnect,1},
+                                           {database,0},
+                                           {password,[]},
+                                           {sentinel,[]},
+                                           {servers,[{"wrong",6379},{"wrong",6380},{"wrong",6381}]}]}])).
+
+
 %%--------------------------------------------------------------------
 %% Internal funcs
 %%--------------------------------------------------------------------
@@ -172,3 +178,13 @@ reload(Config) when is_list(Config) ->
     application:stop(?APP),
     [application:set_env(?APP, K, V) || {K, V} <- Config],
     application:start(?APP).
+
+q(Cmd) ->
+    {ok, Server} = application:get_env(?APP, server),
+    case proplists:get_value(type, Server) of
+        single ->
+            {ok, Connection} = ?POOL(?APP),
+            eredis:q(Connection, Cmd);
+        cluster ->
+            eredis_cluster:q(emqx_auth_redis, Cmd)
+    end.

+ 0 - 10
apps/emqx_bridge_mqtt/src/emqx_bridge_mqtt.appup.src

@@ -1,10 +0,0 @@
-%% -*-: erlang -*-
-
-{VSN,
-  [
-    {<<".*">>, []}
-  ],
-  [
-    {<<"*.">>, []}
-  ]
-}.

Разница между файлами не показана из-за своего большого размера
+ 0 - 8
apps/emqx_dashboard/priv/www/static/js/0.7a09d1383e1319441399.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 8
apps/emqx_dashboard/priv/www/static/js/2.71ffb214c95162432f13.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 1
apps/emqx_dashboard/priv/www/static/js/20.308aa0fdf6653ef3299f.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 1
apps/emqx_dashboard/priv/www/static/js/22.d968dc6f54a690adde18.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 1
apps/emqx_dashboard/priv/www/static/js/3.25b49772270df4b9915d.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 1
apps/emqx_dashboard/priv/www/static/js/5.8935139a413f40d70253.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 1
apps/emqx_dashboard/priv/www/static/js/8.e86f6131cc8a9138368d.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 1
apps/emqx_dashboard/priv/www/static/js/manifest.b28890b7e119092c6f70.js


+ 0 - 24
apps/emqx_exhook/src/emqx_exhook.app.src.script

@@ -1,24 +0,0 @@
-%%-*- mode: erlang -*-
-%% .app.src.script
-
-RemoveLeadingV =
-    fun(Tag) ->
-        case re:run(Tag, "^[v]?[0-9]\.[0-9]\.([0-9]|(rc|beta|alpha)\.[0-9])", [{capture, none}]) of
-            nomatch ->
-                re:replace(Tag, "/", "-", [{return ,list}]);
-            _ ->
-                %% if it is a version number prefixed by 'v' or 'e', then remove it
-                re:replace(Tag, "[v]", "", [{return ,list}])
-        end
-    end,
-
-case os:getenv("EMQX_DEPS_DEFAULT_VSN") of
-    false -> CONFIG; % env var not defined
-    []    -> CONFIG; % env var set to empty string
-    Tag ->
-       [begin
-           AppConf0 = lists:keystore(vsn, 1, AppConf, {vsn, RemoveLeadingV(Tag)}),
-           {application, App, AppConf0}
-        end || Conf = {application, App, AppConf} <- CONFIG]
-end.
-

+ 0 - 9
apps/emqx_exhook/src/emqx_exhook.appup.src

@@ -1,9 +0,0 @@
-%% -*-: erlang -*-
-{VSN,
-  [
-    {<<".*">>, []}
-  ],
-  [
-    {<<".*">>, []}
-  ]
-}.

+ 0 - 24
apps/emqx_exproto/src/emqx_exproto.app.src.script

@@ -1,24 +0,0 @@
-%%-*- mode: erlang -*-
-%% .app.src.script
-
-RemoveLeadingV =
-    fun(Tag) ->
-        case re:run(Tag, "^[v]?[0-9]\.[0-9]\.([0-9]|(rc|beta|alpha)\.[0-9])", [{capture, none}]) of
-            nomatch ->
-                re:replace(Tag, "/", "-", [{return ,list}]);
-            _ ->
-                %% if it is a version number prefixed by 'v' or 'e', then remove it
-                re:replace(Tag, "[v]", "", [{return ,list}])
-        end
-    end,
-
-case os:getenv("EMQX_DEPS_DEFAULT_VSN") of
-    false -> CONFIG; % env var not defined
-    []    -> CONFIG; % env var set to empty string
-    Tag ->
-       [begin
-           AppConf0 = lists:keystore(vsn, 1, AppConf, {vsn, RemoveLeadingV(Tag)}),
-           {application, App, AppConf0}
-        end || Conf = {application, App, AppConf} <- CONFIG]
-end.
-

+ 0 - 9
apps/emqx_exproto/src/emqx_exproto.appup.src

@@ -1,9 +0,0 @@
-%% -*-: erlang -*-
-{VSN,
-  [
-    {<<".*">>, []}
-  ],
-  [
-    {<<".*">>, []}
-  ]
-}.

+ 1 - 0
apps/emqx_lwm2m/rebar.config

@@ -25,3 +25,4 @@
 {cover_enabled, true}.
 {cover_opts, [verbose]}.
 {cover_export_enabled, true}.
+{extra_src_dirs, [{"lwm2m_xml", [{recursive,true}]}]}.

+ 16 - 1
apps/emqx_management/src/emqx_mgmt.erl

@@ -128,6 +128,7 @@
         , export_auth_username/0
         , export_auth_mnesia/0
         , export_acl_mnesia/0
+        , export_schemas/0
         , import_rules/1
         , import_resources/1
         , import_blacklist/1
@@ -137,6 +138,7 @@
         , import_auth_username/1
         , import_auth_mnesia/1
         , import_acl_mnesia/1
+        , import_schemas/1
         , to_version/1
         ]).
 
@@ -677,6 +679,13 @@ export_acl_mnesia() ->
                         end, [], ets:tab2list(emqx_acl))
     end.
 
+export_schemas() ->
+    case ets:info(emqx_schema) of
+        undefined -> [];
+        _ ->
+            [emqx_schema_api:format_schema(Schema) || Schema <- emqx_schema_registry:get_all_schemas()]
+    end.
+
 import_rules(Rules) ->
     lists:foreach(fun(#{<<"id">> := RuleId,
                         <<"rawsql">> := RawSQL,
@@ -779,13 +788,19 @@ import_auth_mnesia(Auths) ->
 import_acl_mnesia(Acls) ->
     case ets:info(emqx_acl) of
         undefined -> ok;
-        _ ->
+        _ -> 
             [ mnesia:dirty_write({emqx_acl ,Login, Topic, Action, Allow}) || #{<<"login">> := Login, 
                                                                                <<"topic">> := Topic,
                                                                                <<"action">> := Action,
                                                                                <<"allow">> := Allow} <- Acls ]
     end.
 
+import_schemas(Schemas) -> 
+    case ets:info(emqx_schema) of
+        undefined -> ok;
+        _ -> [emqx_schema_registry:add_schema(emqx_schema_api:make_schema_params(Schema)) || Schema <- Schemas]
+    end.
+
 any_to_atom(L) when is_list(L) -> list_to_atom(L);
 any_to_atom(B) when is_binary(B) -> binary_to_atom(B, utf8);
 any_to_atom(A) when is_atom(A) -> A.

+ 9 - 6
apps/emqx_management/src/emqx_mgmt_api_data.erl

@@ -84,6 +84,7 @@ export(_Bindings, _Params) ->
     AuthUsername = emqx_mgmt:export_auth_username(),
     AuthMnesia = emqx_mgmt:export_auth_mnesia(),
     AclMnesia = emqx_mgmt:export_acl_mnesia(),
+    Schemas = emqx_mgmt:export_schemas(),
     Seconds = erlang:system_time(second),
     {{Y, M, D}, {H, MM, S}} = emqx_mgmt_util:datetime(Seconds),
     Filename = io_lib:format("emqx-export-~p-~p-~p-~p-~p-~p.json", [Y, M, D, H, MM, S]),
@@ -99,7 +100,8 @@ export(_Bindings, _Params) ->
             {auth_clientid, AuthClientid},
             {auth_username, AuthUsername},
             {auth_mnesia, AuthMnesia},
-            {acl_mnesia, AclMnesia}
+            {acl_mnesia, AclMnesia},
+            {schemas, Schemas}
            ],
 
     Bin = emqx_json:encode(Data),
@@ -178,19 +180,20 @@ do_import(Filename) ->
             case lists:member(Version, ?VERSIONS) of
                 true  ->
                     try
-                        %emqx_mgmt:import_confs(maps:get(<<"configs">>, Data, []), maps:get(<<"listeners_state">>, Data, [])),
+                        emqx_mgmt:import_confs(maps:get(<<"configs">>, Data, []), maps:get(<<"listeners_state">>, Data, [])),
                         emqx_mgmt:import_resources(maps:get(<<"resources">>, Data, [])),
                         emqx_mgmt:import_rules(maps:get(<<"rules">>, Data, [])),
                         emqx_mgmt:import_blacklist(maps:get(<<"blacklist">>, Data, [])),
                         emqx_mgmt:import_applications(maps:get(<<"apps">>, Data, [])),
                         emqx_mgmt:import_users(maps:get(<<"users">>, Data, [])),
-                        %emqx_mgmt:import_modules(maps:get(<<"modules">>, Data, [])),
+                        emqx_mgmt:import_modules(maps:get(<<"modules">>, Data, [])),
                         emqx_mgmt:import_auth_clientid(maps:get(<<"auth_clientid">>, Data, [])),
                         emqx_mgmt:import_auth_username(maps:get(<<"auth_username">>, Data, [])),
-                        %emqx_mgmt:import_auth_mnesia(maps:get(<<"auth_mnesia">>, Data, []), Version),
-                        %emqx_mgmt:import_acl_mnesia(maps:get(<<"acl_mnesia">>, Data, []), Version),
+                        emqx_mgmt:import_auth_mnesia(maps:get(<<"auth_mnesia">>, Data, []), Version),
+                        emqx_mgmt:import_acl_mnesia(maps:get(<<"acl_mnesia">>, Data, []), Version),
+                        emqx_mgmt:import_schemas(maps:get(<<"schemas">>, Data, [])),
                         logger:debug("The emqx data has been imported successfully"),
-                        error({not_implemented, [import_confs,import_modules,import_auth_mnesia,import_acl_mnesia]})
+                        ok
                     catch Class:Reason:Stack ->
                         logger:error("The emqx data import failed: ~0p", [{Class,Reason,Stack}]),
                         {error, import_failed}

+ 4 - 2
apps/emqx_management/src/emqx_mgmt_cli.erl

@@ -567,6 +567,7 @@ data(["export"]) ->
     AuthUsername = emqx_mgmt:export_auth_username(),
     AuthMnesia = emqx_mgmt:export_auth_mnesia(),
     AclMnesia = emqx_mgmt:export_acl_mnesia(),
+    Schemas = emqx_mgmt:export_schemas(),
     Seconds = erlang:system_time(second),
     {{Y, M, D}, {H, MM, S}} = emqx_mgmt_util:datetime(Seconds),
     Filename = io_lib:format("emqx-export-~p-~p-~p-~p-~p-~p.json", [Y, M, D, H, MM, S]),
@@ -582,8 +583,8 @@ data(["export"]) ->
             {auth_clientid, AuthClientID},
             {auth_username, AuthUsername},
             {auth_mnesia, AuthMnesia},
-            {acl_mnesia, AclMnesia}
-            ],
+            {acl_mnesia, AclMnesia},
+            {schemas, Schemas}],
     ok = filelib:ensure_dir(NFilename),
     case file:write_file(NFilename, emqx_json:encode(Data)) of
         ok ->
@@ -609,6 +610,7 @@ data(["import", Filename]) ->
                         emqx_mgmt:import_auth_username(maps:get(<<"auth_username">>, Data, [])),
                         emqx_mgmt:import_auth_mnesia(maps:get(<<"auth_mnesia">>, Data, [])),
                         emqx_mgmt:import_acl_mnesia(maps:get(<<"acl_mnesia">>, Data, [])),
+                        emqx_mgmt:import_schemas(maps:get(<<"schemas">>, Data, [])),
                         emqx_ctl:print("The emqx data has been imported successfully.~n")
                     catch Class:Reason:Stack ->
                         emqx_ctl:print("The emqx data import failed due: ~0p~n", [{Class,Reason,Stack}])

+ 0 - 8
apps/emqx_rule_engine/src/emqx_rule_engine.appup.src

@@ -1,8 +0,0 @@
-{VSN,
-  [
-    {<<".*">>, []}
-  ],
-  [
-    {<<".*">>, []}
-  ]
-}.

+ 45 - 75
apps/emqx_rule_engine/src/emqx_rule_funcs.erl

@@ -78,10 +78,6 @@
         , bitxor/2
         , bitsl/2
         , bitsr/2
-        , bitsize/1
-        , subbits/2
-        , subbits/3
-        , subbits/6
         ]).
 
 %% Data Type Convertion
@@ -237,7 +233,7 @@ payload() ->
 
 payload(Path) ->
     fun(#{payload := Payload}) when erlang:is_map(Payload) ->
-            map_get(Path, Payload);
+            emqx_rule_maps:nested_get(map_path(Path), Payload);
        (_) -> undefined
     end.
 
@@ -405,74 +401,6 @@ bitsl(X, I) when is_integer(X), is_integer(I) ->
 bitsr(X, I) when is_integer(X), is_integer(I) ->
     X bsr I.
 
-bitsize(Bits) when is_bitstring(Bits) ->
-    bit_size(Bits).
-
-subbits(Bits, Len) when is_integer(Len), is_bitstring(Bits) ->
-    subbits(Bits, 1, Len).
-
-subbits(Bits, Start, Len) when is_integer(Start), is_integer(Len), is_bitstring(Bits) ->
-    get_subbits(Bits, Start, Len, <<"integer">>, <<"unsigned">>, <<"big">>).
-
-subbits(Bits, Start, Len, Type, Signedness, Endianness) when is_integer(Start), is_integer(Len), is_bitstring(Bits) ->
-    get_subbits(Bits, Start, Len, Type, Signedness, Endianness).
-
-get_subbits(Bits, Start, Len, Type, Signedness, Endianness) ->
-    Begin = Start - 1,
-    case Bits of
-        <<_:Begin, Rem/bits>> when Rem =/= <<>> ->
-            Sz = bit_size(Rem),
-            do_get_subbits(Rem, Sz, Len, Type, Signedness, Endianness);
-        _ -> undefined
-    end.
-
--define(match_bits(Bits0, Pattern, ElesePattern),
-    case Bits0 of
-        Pattern ->
-            SubBits;
-        ElesePattern ->
-            SubBits
-    end).
-do_get_subbits(Bits, Sz, Len, <<"integer">>, <<"unsigned">>, <<"big">>) ->
-    ?match_bits(Bits, <<SubBits:Len/integer-unsigned-big-unit:1, _/bits>>,
-                      <<SubBits:Sz/integer-unsigned-big-unit:1>>);
-do_get_subbits(Bits, Sz, Len, <<"float">>, <<"unsigned">>, <<"big">>) ->
-    ?match_bits(Bits, <<SubBits:Len/float-unsigned-big-unit:1, _/bits>>,
-                      <<SubBits:Sz/float-unsigned-big-unit:1>>);
-do_get_subbits(Bits, Sz, Len, <<"bits">>, <<"unsigned">>, <<"big">>) ->
-    ?match_bits(Bits, <<SubBits:Len/bits-unsigned-big-unit:1, _/bits>>,
-                      <<SubBits:Sz/bits-unsigned-big-unit:1>>);
-
-do_get_subbits(Bits, Sz, Len, <<"integer">>, <<"signed">>, <<"big">>) ->
-    ?match_bits(Bits, <<SubBits:Len/integer-signed-big-unit:1, _/bits>>,
-                      <<SubBits:Sz/integer-signed-big-unit:1>>);
-do_get_subbits(Bits, Sz, Len, <<"float">>, <<"signed">>, <<"big">>) ->
-    ?match_bits(Bits, <<SubBits:Len/float-signed-big-unit:1, _/bits>>,
-                      <<SubBits:Sz/float-signed-big-unit:1>>);
-do_get_subbits(Bits, Sz, Len, <<"bits">>, <<"signed">>, <<"big">>) ->
-    ?match_bits(Bits, <<SubBits:Len/bits-signed-big-unit:1, _/bits>>,
-                      <<SubBits:Sz/bits-signed-big-unit:1>>);
-
-do_get_subbits(Bits, Sz, Len, <<"integer">>, <<"unsigned">>, <<"little">>) ->
-    ?match_bits(Bits, <<SubBits:Len/integer-unsigned-little-unit:1, _/bits>>,
-                      <<SubBits:Sz/integer-unsigned-little-unit:1>>);
-do_get_subbits(Bits, Sz, Len, <<"float">>, <<"unsigned">>, <<"little">>) ->
-    ?match_bits(Bits, <<SubBits:Len/float-unsigned-little-unit:1, _/bits>>,
-                      <<SubBits:Sz/float-unsigned-little-unit:1>>);
-do_get_subbits(Bits, Sz, Len, <<"bits">>, <<"unsigned">>, <<"little">>) ->
-    ?match_bits(Bits, <<SubBits:Len/bits-unsigned-little-unit:1, _/bits>>,
-                      <<SubBits:Sz/bits-unsigned-little-unit:1>>);
-
-do_get_subbits(Bits, Sz, Len, <<"integer">>, <<"signed">>, <<"little">>) ->
-    ?match_bits(Bits, <<SubBits:Len/integer-signed-little-unit:1, _/bits>>,
-                      <<SubBits:Sz/integer-signed-little-unit:1>>);
-do_get_subbits(Bits, Sz, Len, <<"float">>, <<"signed">>, <<"little">>) ->
-    ?match_bits(Bits, <<SubBits:Len/float-signed-little-unit:1, _/bits>>,
-                      <<SubBits:Sz/float-signed-little-unit:1>>);
-do_get_subbits(Bits, Sz, Len, <<"bits">>, <<"signed">>, <<"little">>) ->
-    ?match_bits(Bits, <<SubBits:Len/bits-signed-little-unit:1, _/bits>>,
-                      <<SubBits:Sz/bits-signed-little-unit:1>>).
-
 %%------------------------------------------------------------------------------
 %% Data Type Convertion Funcs
 %%------------------------------------------------------------------------------
@@ -679,10 +607,52 @@ map_get(Key, Map) ->
     map_get(Key, Map, undefined).
 
 map_get(Key, Map, Default) ->
-    emqx_rule_maps:nested_get(map_path(Key), Map, Default).
+    case maps:find(Key, Map) of
+        {ok, Val} -> Val;
+        error when is_atom(Key) ->
+            %% the map may have an equivalent binary-form key
+            BinKey = emqx_rule_utils:bin(Key),
+            case maps:find(BinKey, Map) of
+                {ok, Val} -> Val;
+                error -> Default
+            end;
+        error when is_binary(Key) ->
+            try %% the map may have an equivalent atom-form key
+                AtomKey = list_to_existing_atom(binary_to_list(Key)),
+                case maps:find(AtomKey, Map) of
+                    {ok, Val} -> Val;
+                    error -> Default
+                end
+            catch error:badarg ->
+                Default
+            end;
+        error ->
+            Default
+    end.
 
 map_put(Key, Val, Map) ->
-    emqx_rule_maps:nested_put(map_path(Key), Val, Map).
+    case maps:find(Key, Map) of
+        {ok, _} -> maps:put(Key, Val, Map);
+        error when is_atom(Key) ->
+            %% the map may have an equivalent binary-form key
+            BinKey = emqx_rule_utils:bin(Key),
+            case maps:find(BinKey, Map) of
+                {ok, _} -> maps:put(BinKey, Val, Map);
+                error -> maps:put(Key, Val, Map)
+            end;
+        error when is_binary(Key) ->
+            try %% the map may have an equivalent atom-form key
+                AtomKey = list_to_existing_atom(binary_to_list(Key)),
+                case maps:find(AtomKey, Map) of
+                    {ok, _} -> maps:put(AtomKey, Val, Map);
+                    error -> maps:put(Key, Val, Map)
+                end
+            catch error:badarg ->
+                maps:put(Key, Val, Map)
+            end;
+        error ->
+            maps:put(Key, Val, Map)
+    end.
 
 mget(Key, Map) ->
     mget(Key, Map, undefined).

+ 4 - 57
apps/emqx_rule_engine/test/emqx_rule_funcs_SUITE.erl

@@ -489,75 +489,22 @@ t_contains(_) ->
 
 t_map_get(_) ->
     ?assertEqual(1, apply_func(map_get, [<<"a">>, #{a => 1}])),
-    ?assertEqual(undefined, apply_func(map_get, [<<"a">>, #{}])),
-    ?assertEqual(1, apply_func(map_get, [<<"a.b">>, #{a => #{b => 1}}])),
-    ?assertEqual(undefined, apply_func(map_get, [<<"a.c">>, #{a => #{b => 1}}])).
+    ?assertEqual(undefined, apply_func(map_get, [<<"a">>, #{}])).
 
 t_map_put(_) ->
     ?assertEqual(#{<<"a">> => 1}, apply_func(map_put, [<<"a">>, 1, #{}])),
-    ?assertEqual(#{a => 2}, apply_func(map_put, [<<"a">>, 2, #{a => 1}])),
-    ?assertEqual(#{<<"a">> => #{<<"b">> => 1}}, apply_func(map_put, [<<"a.b">>, 1, #{}])),
-    ?assertEqual(#{a => #{b => 1, <<"c">> => 1}}, apply_func(map_put, [<<"a.c">>, 1, #{a => #{b => 1}}])).
+    ?assertEqual(#{a => 2}, apply_func(map_put, [<<"a">>, 2, #{a => 1}])).
 
-t_mget(_) ->
+ t_mget(_) ->
     ?assertEqual(1, apply_func(map_get, [<<"a">>, #{a => 1}])),
     ?assertEqual(1, apply_func(map_get, [<<"a">>, #{<<"a">> => 1}])),
     ?assertEqual(undefined, apply_func(map_get, [<<"a">>, #{}])).
 
-t_mput(_) ->
+ t_mput(_) ->
     ?assertEqual(#{<<"a">> => 1}, apply_func(map_put, [<<"a">>, 1, #{}])),
     ?assertEqual(#{<<"a">> => 2}, apply_func(map_put, [<<"a">>, 2, #{<<"a">> => 1}])),
     ?assertEqual(#{a => 2}, apply_func(map_put, [<<"a">>, 2, #{a => 1}])).
 
-t_bitsize(_) ->
-    ?assertEqual(8, apply_func(bitsize, [<<"a">>])),
-    ?assertEqual(4, apply_func(bitsize, [<<15:4>>])).
-
-t_subbits(_) ->
-    ?assertEqual(1, apply_func(subbits, [<<255:8>>, 1])),
-    ?assertEqual(3, apply_func(subbits, [<<255:8>>, 2])),
-    ?assertEqual(7, apply_func(subbits, [<<255:8>>, 3])),
-    ?assertEqual(15, apply_func(subbits, [<<255:8>>, 4])),
-    ?assertEqual(31, apply_func(subbits, [<<255:8>>, 5])),
-    ?assertEqual(63, apply_func(subbits, [<<255:8>>, 6])),
-    ?assertEqual(127, apply_func(subbits, [<<255:8>>, 7])),
-    ?assertEqual(255, apply_func(subbits, [<<255:8>>, 8])).
-
-t_subbits2(_) ->
-    ?assertEqual(1, apply_func(subbits, [<<255:8>>, 1, 1])),
-    ?assertEqual(3, apply_func(subbits, [<<255:8>>, 1, 2])),
-    ?assertEqual(7, apply_func(subbits, [<<255:8>>, 1, 3])),
-    ?assertEqual(15, apply_func(subbits, [<<255:8>>, 1, 4])),
-    ?assertEqual(31, apply_func(subbits, [<<255:8>>, 1, 5])),
-    ?assertEqual(63, apply_func(subbits, [<<255:8>>, 1, 6])),
-    ?assertEqual(127, apply_func(subbits, [<<255:8>>, 1, 7])),
-    ?assertEqual(255, apply_func(subbits, [<<255:8>>, 1, 8])).
-
-t_subbits2_1(_) ->
-    ?assertEqual(1, apply_func(subbits, [<<255:8>>, 2, 1])),
-    ?assertEqual(3, apply_func(subbits, [<<255:8>>, 2, 2])),
-    ?assertEqual(7, apply_func(subbits, [<<255:8>>, 2, 3])),
-    ?assertEqual(15, apply_func(subbits, [<<255:8>>, 2, 4])),
-    ?assertEqual(31, apply_func(subbits, [<<255:8>>, 2, 5])),
-    ?assertEqual(63, apply_func(subbits, [<<255:8>>, 2, 6])),
-    ?assertEqual(127, apply_func(subbits, [<<255:8>>, 2, 7])),
-    ?assertEqual(127, apply_func(subbits, [<<255:8>>, 2, 8])).
-
-t_subbits2_integer(_) ->
-    ?assertEqual(456, apply_func(subbits, [<<456:32/integer>>, 1, 32, <<"integer">>, <<"signed">>, <<"big">>])),
-    ?assertEqual(-456, apply_func(subbits, [<<-456:32/integer>>, 1, 32, <<"integer">>, <<"signed">>, <<"big">>])).
-
-t_subbits2_float(_) ->
-    R = apply_func(subbits, [<<5.3:64/float>>, 1, 64, <<"float">>, <<"unsigned">>, <<"big">>]),
-    RL = (5.3 - R),
-    ct:pal(";;;;~p", [R]),
-    ?assert( (RL >= 0 andalso RL < 0.0001) orelse (RL =< 0 andalso RL > -0.0001)),
-
-    R2 = apply_func(subbits, [<<-5.3:64/float>>, 1, 64, <<"float">>, <<"signed">>, <<"big">>]),
-
-    RL2 = (5.3 + R2),
-    ct:pal(";;;;~p", [R2]),
-    ?assert( (RL2 >= 0 andalso RL2 < 0.0001) orelse (RL2 =< 0 andalso RL2 > -0.0001)).
 
 %%------------------------------------------------------------------------------
 %% Test cases for Hash funcs

+ 1 - 1
apps/emqx_sasl/test/emqx_sasl_scram_SUITE.erl

@@ -137,4 +137,4 @@ receive_msg() ->
             ct:print("==========+~p~n", [Msg]), 
             receive_msg()
     after 200 -> ok
-    end.
+    end.

+ 0 - 9
apps/emqx_web_hook/src/emqx_web_hook.appup.src

@@ -1,9 +0,0 @@
-%% -*-: erlang -*-
-{VSN,
-  [
-    {<<".*">>, []}
-  ],
-  [
-    {<<".*">>, []}
-  ]
-}.

+ 0 - 4
packages.mk

@@ -32,7 +32,6 @@ endif
 .PHONY: $(PROFILES:%=relup-%)
 $(PROFILES:%=relup-%): $(REBAR)
 ifneq ($(OS),Windows_NT)
-	@ln -snf _build/$(@:relup-%=%)/lib
 	@if [ ! -z $$(ls | grep -E "$(@:relup-%=%)-$(SYSTEM)-(.*)-$$(uname -m).zip" | head -1 ) ]; then \
 		mkdir -p tmp/relup_packages/$(@:relup-%=%); \
 		cp $(@:relup-%=%)-$(SYSTEM)-*-$$(uname -m).zip tmp/relup_packages/$(@:relup-%=%); \
@@ -42,9 +41,6 @@ endif
 
 .PHONY: $(PROFILES:%=%-tar) $(PKG_PROFILES:%=%-tar)
 $(PROFILES:%=%-tar) $(PKG_PROFILES:%=%-tar): $(REBAR)
-ifneq ($(OS),Windows_NT)
-	@ln -snf _build/$(subst -tar,,$(@))/lib
-endif
 ifneq ($(shell echo $(@) |grep edge),)
 	export EMQX_DESC="EMQ X Edge"
 else

+ 16 - 2
rebar.config

@@ -12,8 +12,10 @@
             warn_obsolete_guard,no_debug_info,compressed]}.
 
 {overrides,[{add,[{erl_opts,[no_debug_info,compressed,deterministic,
-                             {parse_transform,mod_vsn}]}]}]}.
-
+                             {parse_transform,mod_vsn}]}]}
+           ,{add,[{extra_src_dirs, [{"etc", [{recursive,true}]}]}]}
+           ]}.
+{extra_src_dirs, [{"etc", [{recursive,true}]}]}.
 
 {xref_checks,[undefined_function_calls,undefined_functions,locals_not_used,
               deprecated_function_calls,warnings_as_errors, deprecated_functions]}.
@@ -49,3 +51,15 @@
     , {rulesql, {git, "https://github.com/emqx/rulesql", {tag, "0.1.2"}}}
     , {getopt, "1.0.1"}
     ]}.
+
+{xref_ignores,
+ [ %% schema registry is for enterprise
+  {emqx_schema_registry,get_all_schemas,0},
+  {emqx_schema_api,format_schema,1},
+  {emqx_schema_api,make_schema_params,1},
+  {emqx_schema_parser,decode,3},
+  {emqx_schema_parser,encode,3},
+  {emqx_schema_registry,add_schema,1},
+  emqx_exhook_pb, % generated code for protobuf
+  emqx_exproto_pb % generated code for protobuf
+]}.

+ 5 - 4
sync-apps.sh

@@ -85,10 +85,11 @@ done
 cleanup_app(){
     local app="$1"
     pushd "apps/$app"
-    rm -f Makefile rebar.config.script
-    rm -rf ".github" ".ci"
-    rm -rf src/*.app.src.script
-    rm -rf src/*.appup.src
+    rm -f Makefile rebar.config.script LICENSE src/*.app.src.script src/*.appup.src
+    rm -rf ".github"
+    # restore rebar.config and app.src
+    git checkout rebar.config
+    git checkout src/*.app.src
     popd
 }
 

+ 1 - 1
test/emqx_SUITE.erl

@@ -19,7 +19,7 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx.hrl").
+-include_lib("emqx/include/emqx.hrl").
 -include_lib("eunit/include/eunit.hrl").
 -include_lib("common_test/include/ct.hrl").
 

+ 1 - 1
test/emqx_access_control_SUITE.erl

@@ -19,7 +19,7 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx_mqtt.hrl").
+-include_lib("emqx/include/emqx_mqtt.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
 all() -> emqx_ct:all(?MODULE).

+ 2 - 2
test/emqx_alarm_SUITE.erl

@@ -19,8 +19,8 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx.hrl").
--include("emqx_mqtt.hrl").
+-include_lib("emqx/include/emqx.hrl").
+-include_lib("emqx/include/emqx_mqtt.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
 all() -> emqx_ct:all(?MODULE).

+ 1 - 1
test/emqx_banned_SUITE.erl

@@ -19,7 +19,7 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx.hrl").
+-include_lib("emqx/include/emqx.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
 all() -> emqx_ct:all(?MODULE).

+ 2 - 2
test/emqx_broker_SUITE.erl

@@ -24,8 +24,8 @@
 -include_lib("eunit/include/eunit.hrl").
 -include_lib("common_test/include/ct.hrl").
 
--include("emqx.hrl").
--include("emqx_mqtt.hrl").
+-include_lib("emqx/include/emqx.hrl").
+-include_lib("emqx/include/emqx_mqtt.hrl").
 
 all() -> emqx_ct:all(?MODULE).
 

+ 2 - 2
test/emqx_channel_SUITE.erl

@@ -19,8 +19,8 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx.hrl").
--include("emqx_mqtt.hrl").
+-include_lib("emqx/include/emqx.hrl").
+-include_lib("emqx/include/emqx_mqtt.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
 

+ 1 - 1
test/emqx_client_SUITE.erl

@@ -21,7 +21,7 @@
 
 -import(lists, [nth/2]).
 
--include("emqx_mqtt.hrl").
+-include_lib("emqx/include/emqx_mqtt.hrl").
 -include_lib("eunit/include/eunit.hrl").
 -include_lib("common_test/include/ct.hrl").
 

+ 1 - 1
test/emqx_cm_SUITE.erl

@@ -19,7 +19,7 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx.hrl").
+-include_lib("emqx/include/emqx.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
 -define(CM, emqx_cm).

+ 1 - 1
test/emqx_connection_SUITE.erl

@@ -19,7 +19,7 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx_mqtt.hrl").
+-include_lib("emqx/include/emqx_mqtt.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
 all() -> emqx_ct:all(?MODULE).

+ 1 - 1
test/emqx_frame_SUITE.erl

@@ -19,7 +19,7 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx_mqtt.hrl").
+-include_lib("emqx/include/emqx_mqtt.hrl").
 -include_lib("eunit/include/eunit.hrl").
 -include_lib("common_test/include/ct.hrl").
 -include_lib("emqx_ct_helpers/include/emqx_ct.hrl").

+ 2 - 2
test/emqx_listeners_SUITE.erl

@@ -19,8 +19,8 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx.hrl").
--include("emqx_mqtt.hrl").
+-include_lib("emqx/include/emqx.hrl").
+-include_lib("emqx/include/emqx_mqtt.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
 all() -> emqx_ct:all(?MODULE).

+ 2 - 2
test/emqx_message_SUITE.erl

@@ -19,8 +19,8 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx.hrl").
--include("emqx_mqtt.hrl").
+-include_lib("emqx/include/emqx.hrl").
+-include_lib("emqx/include/emqx_mqtt.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
 all() -> emqx_ct:all(?MODULE).

+ 1 - 1
test/emqx_metrics_SUITE.erl

@@ -19,7 +19,7 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx_mqtt.hrl").
+-include_lib("emqx/include/emqx_mqtt.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
 all() -> emqx_ct:all(?MODULE).

+ 1 - 1
test/emqx_mod_acl_internal_SUITE.erl

@@ -19,7 +19,7 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx_mqtt.hrl").
+-include_lib("emqx/include/emqx_mqtt.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
 all() -> emqx_ct:all(?MODULE).

+ 1 - 1
test/emqx_mod_delayed_SUITE.erl

@@ -25,7 +25,7 @@
 
 -include_lib("common_test/include/ct.hrl").
 -include_lib("eunit/include/eunit.hrl").
--include("emqx.hrl").
+-include_lib("emqx/include/emqx.hrl").
 
 %%--------------------------------------------------------------------
 %% Setups

+ 1 - 1
test/emqx_mod_presence_SUITE.erl

@@ -19,7 +19,7 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx_mqtt.hrl").
+-include_lib("emqx/include/emqx_mqtt.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
 all() -> emqx_ct:all(?MODULE).

+ 1 - 1
test/emqx_mod_rewrite_SUITE.erl

@@ -19,7 +19,7 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx_mqtt.hrl").
+-include_lib("emqx/include/emqx_mqtt.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
 -define(RULES, [{rewrite, pub, <<"x/#">>,<<"^x/y/(.+)$">>,<<"z/y/$1">>},

+ 1 - 1
test/emqx_mod_subscription_SUITE.erl

@@ -19,7 +19,7 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx_mqtt.hrl").
+-include_lib("emqx/include/emqx_mqtt.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
 all() -> emqx_ct:all(?MODULE).

+ 1 - 1
test/emqx_mountpoint_SUITE.erl

@@ -25,7 +25,7 @@
         , replvar/2
         ]).
 
--include("emqx.hrl").
+-include_lib("emqx/include/emqx.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
 all() -> emqx_ct:all(?MODULE).

+ 1 - 1
test/emqx_mqtt_SUITE.erl

@@ -19,7 +19,7 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx.hrl").
+-include_lib("emqx/include/emqx.hrl").
 -include_lib("eunit/include/eunit.hrl").
 -include_lib("common_test/include/ct.hrl").
 

+ 1 - 1
test/emqx_mqtt_caps_SUITE.erl

@@ -19,7 +19,7 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx_mqtt.hrl").
+-include_lib("emqx/include/emqx_mqtt.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
 all() -> emqx_ct:all(?MODULE).

+ 1 - 1
test/emqx_mqtt_props_SUITE.erl

@@ -19,7 +19,7 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx_mqtt.hrl").
+-include_lib("emqx/include/emqx_mqtt.hrl").
 -include_lib("eunit/include/eunit.hrl").
 -include_lib("emqx_ct_helpers/include/emqx_ct.hrl").
 

+ 2 - 2
test/emqx_mqueue_SUITE.erl

@@ -19,8 +19,8 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx.hrl").
--include("emqx_mqtt.hrl").
+-include_lib("emqx/include/emqx.hrl").
+-include_lib("emqx/include/emqx_mqtt.hrl").
 
 -include_lib("eunit/include/eunit.hrl").
 

+ 2 - 2
test/emqx_packet_SUITE.erl

@@ -19,8 +19,8 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx.hrl").
--include("emqx_mqtt.hrl").
+-include_lib("emqx/include/emqx.hrl").
+-include_lib("emqx/include/emqx_mqtt.hrl").
 
 -include_lib("eunit/include/eunit.hrl").
 

+ 1 - 1
test/emqx_plugins_SUITE.erl

@@ -19,7 +19,7 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx.hrl").
+-include_lib("emqx/include/emqx.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
 all() -> emqx_ct:all(?MODULE).

+ 1 - 1
test/emqx_reason_codes_SUITE.erl

@@ -19,7 +19,7 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx_mqtt.hrl").
+-include_lib("emqx/include/emqx_mqtt.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
 all() -> emqx_ct:all(?MODULE).

+ 1 - 1
test/emqx_request_handler.erl

@@ -18,7 +18,7 @@
 
 -export([start_link/4, stop/1]).
 
--include("emqx_mqtt.hrl").
+-include_lib("emqx/include/emqx_mqtt.hrl").
 
 -type qos() :: emqx_mqtt_types:qos_name() | emqx_mqtt_types:qos().
 -type topic() :: emqx_topic:topic().

+ 1 - 1
test/emqx_request_responser_SUITE.erl

@@ -17,7 +17,7 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx_mqtt.hrl").
+-include_lib("emqx/include/emqx_mqtt.hrl").
 -include_lib("eunit/include/eunit.hrl").
 -include_lib("common_test/include/ct.hrl").
 

+ 1 - 1
test/emqx_request_sender.erl

@@ -18,7 +18,7 @@
 
 -export([start_link/3, stop/1, send/6]).
 
--include("emqx_mqtt.hrl").
+-include_lib("emqx/include/emqx_mqtt.hrl").
 
 start_link(ResponseTopic, QoS, Options0) ->
     Parent = self(),

+ 1 - 1
test/emqx_router_SUITE.erl

@@ -19,7 +19,7 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx.hrl").
+-include_lib("emqx/include/emqx.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
 -define(R, emqx_router).

+ 1 - 1
test/emqx_session_SUITE.erl

@@ -19,7 +19,7 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx_mqtt.hrl").
+-include_lib("emqx/include/emqx_mqtt.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
 all() -> emqx_ct:all(?MODULE).

+ 1 - 1
test/emqx_shared_sub_SUITE.erl

@@ -19,7 +19,7 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx.hrl").
+-include_lib("emqx/include/emqx.hrl").
 -include_lib("eunit/include/eunit.hrl").
 -include_lib("common_test/include/ct.hrl").
 

+ 1 - 1
test/emqx_sys_mon_SUITE.erl

@@ -19,7 +19,7 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx_mqtt.hrl").
+-include_lib("emqx/include/emqx_mqtt.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
 -define(SYSMON, emqx_sys_mon).

+ 1 - 1
test/emqx_takeover_SUITE.erl

@@ -19,7 +19,7 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx.hrl").
+-include_lib("emqx/include/emqx.hrl").
 -include_lib("eunit/include/eunit.hrl").
 -include_lib("common_test/include/ct.hrl").
 

+ 1 - 1
test/emqx_trie_SUITE.erl

@@ -19,7 +19,7 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx.hrl").
+-include_lib("emqx/include/emqx.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
 -define(TRIE, emqx_trie).

+ 2 - 2
test/emqx_ws_connection_SUITE.erl

@@ -16,8 +16,8 @@
 
 -module(emqx_ws_connection_SUITE).
 
--include("emqx.hrl").
--include("emqx_mqtt.hrl").
+-include_lib("emqx/include/emqx.hrl").
+-include_lib("emqx/include/emqx_mqtt.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
 -compile(export_all).

+ 2 - 2
test/mqtt_protocol_v5_SUITE.erl

@@ -19,8 +19,8 @@
 -compile(export_all).
 -compile(nowarn_export_all).
 
--include("emqx.hrl").
--include("emqx_mqtt.hrl").
+-include_lib("emqx/include/emqx.hrl").
+-include_lib("emqx/include/emqx_mqtt.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
 -import(lists, [nth/2]).

+ 1 - 1
test/props/prop_emqx_frame.erl

@@ -16,7 +16,7 @@
 
 -module(prop_emqx_frame).
 
--include("emqx_mqtt.hrl").
+-include_lib("emqx/include/emqx_mqtt.hrl").
 -include_lib("proper/include/proper.hrl").
 
 %%--------------------------------------------------------------------

+ 1 - 1
test/props/prop_emqx_reason_codes.erl

@@ -16,7 +16,7 @@
 
 -module(prop_emqx_reason_codes).
 
--include("emqx_mqtt.hrl").
+-include_lib("emqx/include/emqx_mqtt.hrl").
 -include_lib("proper/include/proper.hrl").
 
 %%--------------------------------------------------------------------