Skip to content

Commit

Permalink
Merge pull request #21 from emqtt/emq20
Browse files Browse the repository at this point in the history
  • Loading branch information
Feng Lee committed Oct 31, 2016
2 parents 1b4622f + bdaee27 commit bd57351
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion etc/emq_auth_mysql.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## MySQL Auth/ACL Plugin
##--------------------------------------------------------------------

## Mysql Server
## Mysql Server 3306, 127.0.0.1:3306, localhost:3306
auth.mysql.server = 127.0.0.1:3306

## Mysql Pool Size
Expand Down
15 changes: 11 additions & 4 deletions priv/emq_auth_mysql.schema
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%% emq_auth_mysql config mapping
{mapping, "auth.mysql.server", "emq_auth_mysql.server", [
{default, {"127.0.0.1", 3306}},
{datatype, [integer, ip]}
{datatype, [integer, ip, string]}
]}.

{mapping, "auth.mysql.pool", "emq_auth_mysql.server", [
Expand All @@ -26,15 +26,22 @@
]}.

{translation, "emq_auth_mysql.server", fun(Conf) ->
{Host, Port} = cuttlefish:conf_get("auth.mysql.server", Conf),
{MyHost, MyPort} =
case cuttlefish:conf_get("auth.mysql.server", Conf) of
{Ip, Port} -> {Ip, Port};
S -> case string:tokens(S, ":") of
[Domain] -> {Domain, 3306};
[Domain, Port] -> {Domain, list_to_integer(Port)}
end
end,
Pool = cuttlefish:conf_get("auth.mysql.pool", Conf),
Username = cuttlefish:conf_get("auth.mysql.username", Conf),
Passwd = cuttlefish:conf_get("auth.mysql.password", Conf),
DB = cuttlefish:conf_get("auth.mysql.database", Conf),
[{pool_size, Pool},
{auto_reconnect, 1},
{host, Host},
{port, Port},
{host, MyHost},
{port, MyPort},
{user, Username},
{password, Passwd},
{database, DB},
Expand Down

0 comments on commit bd57351

Please sign in to comment.