summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaweł Chmielowski <pchmielowski@process-one.net>2017-03-10 14:39:47 +0100
committerPaweł Chmielowski <pchmielowski@process-one.net>2017-03-10 14:39:47 +0100
commit0822108fc8bf52e6224287962ba3479afd195cdf (patch)
treec2300666ba62a09ac54672434a9d39fea8c1ae6a /src
parentImprove formatting of erlang terms shown in web admin (diff)
Teach web admin about ip acl rules
Diffstat (limited to 'src')
-rw-r--r--src/ejabberd_web_admin.erl8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/ejabberd_web_admin.erl b/src/ejabberd_web_admin.erl
index ea695863..390900d0 100644
--- a/src/ejabberd_web_admin.erl
+++ b/src/ejabberd_web_admin.erl
@@ -1114,6 +1114,8 @@ acl_spec_to_text({server_glob, RS}) ->
acl_spec_to_text({node_glob, {RU, RS}}) ->
{node_glob, <<RU/binary, "@", RS/binary>>};
acl_spec_to_text(all) -> {all, <<"">>};
+acl_spec_to_text({ip, {IP, L}}) -> {ip, <<(jlib:ip_to_list(IP))/binary, "/",
+ (integer_to_binary(L))/binary>>};
acl_spec_to_text(Spec) -> {raw, term_to_string(Spec)}.
acl_spec_to_xhtml(ID, Spec) ->
@@ -1137,7 +1139,7 @@ acl_spec_select(ID, Opt) ->
(iolist_to_binary(atom_to_list(O))))
end,
[user, server, user_regexp, server_regexp, node_regexp,
- user_glob, server_glob, node_glob, all, raw])))]).
+ user_glob, server_glob, node_glob, all, ip, raw])))]).
%% @spec (T::any()) -> StringLine::string()
term_to_string(T) ->
@@ -1222,6 +1224,10 @@ string_to_spec(<<"node_glob">>, Val) ->
#jid{luser = U, lserver = S, resource = <<"">>} =
jid:decode(Val),
{node_glob, U, S};
+string_to_spec(<<"ip">>, Val) ->
+ [IPs, Ms] = str:tokens(Val, <<"/">>),
+ {ok, IP} = inet_parse:address(binary_to_list(IPs)),
+ {ip, {IP, binary_to_integer(Ms)}};
string_to_spec(<<"all">>, _) -> all;
string_to_spec(<<"raw">>, Val) ->
{ok, Tokens, _} = erl_scan:string(binary_to_list(<<Val/binary, ".">>)),