Skip to content

Commit

Permalink
sync 4.3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
lsxredrain committed Jan 2, 2022
1 parent c9f2f78 commit 533bade
Show file tree
Hide file tree
Showing 151 changed files with 6,674 additions and 1,469 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@ $(REL_PROFILES:%=%): $(REBAR) get-dashboard
clean: $(PROFILES:%=clean-%)
$(PROFILES:%=clean-%):
@if [ -d _build/$(@:clean-%=%) ]; then \
rm rebar.lock \
rm -rf _build/$(@:clean-%=%)/rel; \
find _build/$(@:clean-%=%) -name '*.beam' -o -name '*.so' -o -name '*.app' -o -name '*.appup' -o -name '*.o' -o -name '*.d' -type f | xargs rm -f; \
find _build/$(@:clean-%=%) -type l -delete; \
fi

.PHONY: clean-all
Expand All @@ -103,13 +105,15 @@ clean-all:

.PHONY: deps-all
deps-all: $(REBAR) $(PROFILES:%=deps-%)
@make clean # ensure clean at the end

## deps-<profile> is used in CI scripts to download deps and the
## share downloads between CI steps and/or copied into containers
## which may not have the right credentials
.PHONY: $(PROFILES:%=deps-%)
$(PROFILES:%=deps-%): $(REBAR) get-dashboard
@$(REBAR) as $(@:deps-%=%) get-deps
@rm -f rebar.lock

.PHONY: xref
xref: $(REBAR)
Expand Down
43 changes: 7 additions & 36 deletions apps/dgiot/conf/rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -36,42 +36,13 @@
{erl_first_files, ["src/emqx_logger.erl", "src/emqx_rule_actions_trans.erl"]}.

{deps,
[
{getopt, {git, "https://gitee.com/fastdgiot/getopt.git", {tag, "v1.0.2"}}}
, {grpc, {git, "https://gitee.com/fastdgiot/grpc-erl", {tag, "0.6.4"}}}
, {grpc_plugin, {git, "https://gitee.com/fastdgiot/grpc_plugin.git", {tag, "v0.10.4"}}}
, {recon, {git, "https://gitee.com/fastdgiot/recon.git", {tag, "2.5.1"}}}
, {rebar3_proper, {git, "https://gitee.com/fastdgiot/rebar3_proper.git", {tag, "0.12.1"}}}
, {gpb, {git, "https://gitee.com/fastdgiot/gpb", {tag, "4.17.6"}}}
, {cuttlefish, {git, "https://gitee.com/fastdgiot/cuttlefish", {tag, "v4.3.4"}}}
, {cowboy, {git, "https://gitee.com/fastdgiot/cowboy", {tag, "2.8.3"}}}
, {minirest, {git, "https://gitee.com/fastdgiot/minirest", {tag, "0.3.5"}}}
, {ecpool, {git, "https://gitee.com/fastdgiot/ecpool", {tag, "0.5.1"}}}
, {replayq, {git, "https://gitee.com/fastdgiot/replayq", {tag, "0.3.2"}}}
, {pbkdf2, {git, "https://gitee.com/fastdgiot/erlang-pbkdf2.git", {branch, "2.0.4"}}}
, {emqtt, {git, "https://gitee.com/fastdgiot/emqtt", {tag, "1.2.3"}}}
, {rulesql, {git, "https://gitee.com/fastdgiot/rulesql", {tag, "0.1.2"}}}
, {recon, {git, "https://gitee.com/fastdgiot/recon", {tag, "2.5.1"}}}
, {ranch, {git, "https://gitee.com/fastdgiot/ranch", {tag, "1.7.1"}}}
, {gproc, {git, "https://gitee.com/fastdgiot/gproc", {tag, "0.8.0"}}}
, {gen_rpc, {git, "https://gitee.com/fastdgiot/gen_rpc", {tag, "2.5.1"}}}
, {gun, {git, "https://gitee.com/fastdgiot/gun", {tag, "1.3.5"}}}
, {ssl_verify_fun, {git, "https://gitee.com/fastdgiot/ssl_verify_fun.erl.git", {tag, "1.1.4"}}}
, {jiffy, {git, "https://gitee.com/fastdgiot/jiffy", {tag, "1.0.5"}}}
, {esockd, {git, "https://gitee.com/fastdgiot/esockd", {tag, "5.8.0"}}}
, {ekka, {git, "https://gitee.com/fastdgiot/ekka", {tag, "0.8.1"}}}
, {ehttpc, {git, "https://gitee.com/fastdgiot/ehttpc", {tag, "0.1.5"}}}
, {erlydtl, {git, "https://gitee.com/fastdgiot/erlydtl.git", {tag, "0.12.1"}}}
, {erlport, {git, "https://gitee.com/fastdgiot/erlport", {tag, "v1.2.2"}}}
, {poolboy, {git, "https://gitee.com/fastdgiot/poolboy.git", {tag, "1.5.3"}}}
, {websocket_client, {git, "https://gitee.com/fastdgiot/websocket_client", {tag, "v0.7"}}}
, {observer_cli, "1.6.1"} % NOTE: depends on recon 2.5.1
, {ejdbc, {git, "https://gitee.com/fastdgiot/ejdbc", {tag, "1.0.1"}}}
, {snabbkaffe, {git, "https://gitee.com/fastdgiot/snabbkaffe.git", {tag, "0.12.2"}}}
, {cowlib, {git, "https://gitee.com/fastdgiot/cowlib",{tag,"2.8.0"}}}
, {ibrowse, {git, "https://gitee.com/fastdgiot/ibrowse.git", {tag, "v4.4.2"}}}
, {jesse, {git, "https://gitee.com/fastdgiot/jesse.git", {tag, "1.6.1"}}}
, {jwerl, {git, "https://gitee.com/fastdgiot/jwerl.git", {tag, "1.1.1"}}}
[{gun, {git, "https://gitee.com/fastdgiot/gun", {tag, "1.3.5"}}}
, {ssl_verify_fun, {git, "https://gitee.com/fastdgiot/ssl_verify_fun.erl.git", {tag, "1.1.4"}}}
, {erlydtl, {git, "https://gitee.com/fastdgiot/erlydtl.git", {tag, "0.12.1"}}}
, {erlport, {git, "https://gitee.com/fastdgiot/erlport", {tag, "v1.2.2"}}}
, {poolboy, {git, "https://gitee.com/fastdgiot/poolboy.git", {tag, "1.5.3"}}}
, {ibrowse, {git, "https://gitee.com/fastdgiot/ibrowse.git", {tag, "v4.4.2"}}}
, {jwerl, {git, "https://gitee.com/fastdgiot/jwerl.git", {tag, "1.1.1"}}}
]}.

{xref_ignores,
Expand Down
4 changes: 3 additions & 1 deletion apps/dgiot_api/rebar.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{deps, []}.
{deps, [
{jesse, {git, "https://gitee.com/fastdgiot/jesse.git", {tag, "1.6.1"}}}
]}.

{shell, [
% {config, "config/sys.config"},
Expand Down
2 changes: 1 addition & 1 deletion apps/dgiot_api/src/dgiot_api.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{vsn, "4.3.0"},
{registered, []},
{mod, {dgiot_api_app, []}},
{applications,[kernel, stdlib, dgiot, dgiot_parse]},
{applications,[kernel, stdlib, jesse, dgiot, dgiot_parse]},
{env, []},
{modules, []},
{licenses, ["Apache-2.0"]},
Expand Down
1 change: 1 addition & 0 deletions apps/dgiot_device/rebar.config
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
{deps, [
{ibrowse, {git, "https://gitee.com/fastdgiot/ibrowse.git", {tag, "v4.4.2"}}}
]}.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This is a demo server written in python for exhook

## Prerequisites

- [Python](https://www.python.org) 3.5 or higher
- [Python]() 3.5 or higher
- pip version 9.0.1 or higher

## Run
Expand Down
4 changes: 2 additions & 2 deletions apps/dgiot_grpc/rebar.config
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{plugins,
[{grpc_plugin, {git, "https://github.com/HJianBo/grpc_plugin", {tag, "v0.10.1"}}}
[{grpc_plugin, {git, "https://gitee.com/fastdgiot/grpc_plugin", {tag, "v0.10.1"}}}
]}.

{deps,
[{grpc, {git, "https://gitee.com/fastdgiot/grpc-erl", {branch, "master"}}}
[{grpc, {git, "https://gitee.com/fastdgiot/grpc-erl", {tag, "0.6.4"}}}
]}.

{grpc,
Expand Down
14 changes: 7 additions & 7 deletions apps/dgiot_grpc/src/dgiot_grpc_channel.erl
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,17 @@ init(?TYPE, ChannelId, Env) ->
env = Env
},
Port = maps:get(<<"port">>, Env),
Scheme = maps:get(<<"scheme">>, Env),
Host = dgiot_utils:to_list(maps:get(<<"host">>, Env)),
Opts0 = [{scheme, dgiot_utils:to_atom(Scheme)}, {host, Host}, {port, Port}],
%% Scheme = maps:get(<<"scheme">>, Env),
%% Host = dgiot_utils:to_list(maps:get(<<"host">>, Env)),
%%Opts0 = [{scheme, dgiot_utils:to_atom(Scheme)}, {host, Host}, {port, Port}],
case maps:get(<<"model">>, Env) of
<<"both">> ->
dgiot_grpc_server:start(ChannelId, Port, []),
application:ensure_all_started(emqx_hooks),
emqx_exhook:enable(ChannelId, Opts0);
application:ensure_all_started(emqx_hooks);
%%emqx_exhook:enable(ChannelId, Opts0);
<<"client">> ->
application:ensure_all_started(emqx_hooks),
emqx_exhook:enable(ChannelId, Opts0);
application:ensure_all_started(emqx_hooks);
%%emqx_exhook:enable(ChannelId, Opts0);
<<"server">> ->
dgiot_grpc_server:start(ChannelId, Port, [])
end,
Expand Down
4 changes: 3 additions & 1 deletion apps/dgiot_http/rebar.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{deps, []}.
{deps, [
{jwerl, {git, "https://gitee.com/fastdgiot/jwerl.git", {tag, "1.1.1"}}}
]}.

{shell, [
% {config, "config/sys.config"},
Expand Down
2 changes: 1 addition & 1 deletion apps/dgiot_location/rebar.config
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{deps, [

{locus, {git, "https://gitee.com/fastdgiot/locus.git", {tag, "2.2.2"}}}
]}.
5 changes: 3 additions & 2 deletions apps/dgiot_tdengine/src/dgiot_tdengine_channel.erl
Original file line number Diff line number Diff line change
Expand Up @@ -678,9 +678,10 @@ run_sql(#{<<"driver">> := <<"HTTP">>, <<"url">> := Url, <<"username">> := UserNa
?LOG(info, "Execute Fail ~p (~ts) ~p", [Url, unicode:characters_to_list(Sql), Reason]),
{error, Reason}
end;
run_sql(#{<<"driver">> := <<"JDBC">>, <<"url">> := _Url}, Action, Sql) when Action == execute_update; Action == execute_query ->
run_sql(#{<<"driver">> := <<"JDBC">>, <<"url">> := _Url}, Action, _Sql) when Action == execute_update; Action == execute_query ->
%% ?LOG(info,"Execute ~p (~p) ~p", [Url, byte_size(Sql), Sql]),
apply(ejdbc, Action, [<<"com.taosdata.jdbc.TSDBDriver">>, Sql]).
%% apply(ejdbc, Action, [<<"com.taosdata.jdbc.TSDBDriver">>, Sql]).
ok.


%% 先缓存定时存库
Expand Down
26 changes: 26 additions & 0 deletions apps/emqx_auth_mnesia/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.eunit
deps
*.o
*.beam
*.plt
erl_crash.dump
ebin
rel/example_project
.concrete/DEV_MODE
.rebar
.erlang.mk/
emqx_auth_mnesia.d
data/
_build/
.DS_Store
cover/
ct.coverdata
eunit.coverdata
logs/
test/ct.cover.spec
rebar.lock
rebar3.crashdump
erlang.mk
.*.swp
.rebar3/
etc/emqx_auth_mnesia.conf.rendered
2 changes: 2 additions & 0 deletions apps/emqx_auth_mnesia/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
emqx_auth_mnesia
===============
30 changes: 30 additions & 0 deletions apps/emqx_auth_mnesia/etc/emqx_auth_mnesia.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## Password hash.
##
## Value: plain | md5 | sha | sha256 | sha512
auth.mnesia.password_hash = sha256

##--------------------------------------------------------------------
## ClientId Authentication
##--------------------------------------------------------------------

## Examples
##auth.client.1.clientid = id
##auth.client.1.password = passwd
##auth.client.2.clientid = dev:devid
##auth.client.2.password = passwd2
##auth.client.3.clientid = app:appid
##auth.client.3.password = passwd3
##auth.client.4.clientid = client~!@#$%^&*()_+
##auth.client.4.password = passwd~!@#$%^&*()_+

##--------------------------------------------------------------------
## Username Authentication
##--------------------------------------------------------------------

## Examples:
##auth.user.1.username = admin
##auth.user.1.password = public
##auth.user.2.username = [email protected]
##auth.user.2.password = public
##auth.user.3.username = name~!@#$%^&*()_+
##auth.user.3.password = pwsswd~!@#$%^&*()_+
64 changes: 64 additions & 0 deletions apps/emqx_auth_mnesia/include/emqx_auth_mnesia.hrl
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
-define(APP, emqx_auth_mnesia).

-type(login() :: {clientid, binary()}
| {username, binary()}).

-type(acl_target() :: login() | all).

-type(acl_target_type() :: clientid | username | all).

-type(access():: allow | deny).
-type(action():: pub | sub).
-type(legacy_action():: action() | pubsub).
-type(created_at():: integer()).

-record(emqx_user, {
login :: login(),
password :: binary(),
created_at :: created_at()
}).

-define(ACL_TABLE, emqx_acl).

-define(MIGRATION_MARK_KEY, emqx_acl2_migration_started).

-record(?ACL_TABLE, {
filter :: {acl_target(), emqx_topic:topic()} | ?MIGRATION_MARK_KEY,
action :: legacy_action(),
access :: access(),
created_at :: created_at()
}).

-define(MIGRATION_MARK_RECORD, #?ACL_TABLE{filter = ?MIGRATION_MARK_KEY, action = pub, access = deny, created_at = 0}).

-type(rule() :: {access(), action(), emqx_topic:topic(), created_at()}).

-define(ACL_TABLE2, emqx_acl2).

-record(?ACL_TABLE2, {
who :: acl_target(),
rules :: [ rule() ]
}).

-type(acl_record() :: {acl_target(), emqx_topic:topic(), action(), access(), created_at()}).

-record(auth_metrics, {
success = 'client.auth.success',
failure = 'client.auth.failure',
ignore = 'client.auth.ignore'
}).

-record(acl_metrics, {
allow = 'client.acl.allow',
deny = 'client.acl.deny',
ignore = 'client.acl.ignore'
}).

-define(METRICS(Type), tl(tuple_to_list(#Type{}))).
-define(METRICS(Type, K), #Type{}#Type.K).

-define(AUTH_METRICS, ?METRICS(auth_metrics)).
-define(AUTH_METRICS(K), ?METRICS(auth_metrics, K)).

-define(ACL_METRICS, ?METRICS(acl_metrics)).
-define(ACL_METRICS(K), ?METRICS(acl_metrics, K)).
43 changes: 43 additions & 0 deletions apps/emqx_auth_mnesia/priv/emqx_auth_mnesia.schema
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
%%-*- mode: erlang -*-
%% emqx_auth_mnesia config mapping

{mapping, "auth.mnesia.password_hash", "emqx_auth_mnesia.password_hash", [
{default, sha256},
{datatype, {enum, [plain, md5, sha, sha256, sha512]}}
]}.

{mapping, "auth.client.$id.clientid", "emqx_auth_mnesia.clientid_list", [
{datatype, string}
]}.

{mapping, "auth.client.$id.password", "emqx_auth_mnesia.clientid_list", [
{datatype, string}
]}.

{translation, "emqx_auth_mnesia.clientid_list", fun(Conf) ->
ClientList = cuttlefish_variable:filter_by_prefix("auth.client", Conf),
lists:foldl(
fun({["auth", "client", Id, "clientid"], ClientId}, AccIn) ->
[{ClientId, cuttlefish:conf_get("auth.client." ++ Id ++ ".password", Conf)} | AccIn];
(_, AccIn) ->
AccIn
end, [], ClientList)
end}.

{mapping, "auth.user.$id.username", "emqx_auth_mnesia.username_list", [
{datatype, string}
]}.

{mapping, "auth.user.$id.password", "emqx_auth_mnesia.username_list", [
{datatype, string}
]}.

{translation, "emqx_auth_mnesia.username_list", fun(Conf) ->
Userlist = cuttlefish_variable:filter_by_prefix("auth.user", Conf),
lists:foldl(
fun({["auth", "user", Id, "username"], Username}, AccIn) ->
[{Username, cuttlefish:conf_get("auth.user." ++ Id ++ ".password", Conf)} | AccIn];
(_, AccIn) ->
AccIn
end, [], Userlist)
end}.
17 changes: 17 additions & 0 deletions apps/emqx_auth_mnesia/rebar.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{deps,
[ ]}.

{erl_opts, [warn_unused_vars,
warn_shadow_vars,
warn_unused_import,
warn_obsolete_guard,
debug_info,
{parse_transform}]}.

{xref_checks, [undefined_function_calls, undefined_functions,
locals_not_used, deprecated_function_calls,
warnings_as_errors, deprecated_functions]}.
{cover_enabled, true}.
{cover_opts, [verbose]}.
{cover_export_enabled, true}.

Loading

0 comments on commit 533bade

Please sign in to comment.