mirror of
https://github.com/processone/ejabberd.git
synced 2024-06-14 22:00:16 +02:00
Rename aux.erl as misc.erl
Thanks Microsoft Windows to not support some filenames
This commit is contained in:
parent
265aa54bc2
commit
b1acd1183f
|
@ -128,14 +128,14 @@ mech_step(#state{step = 2} = State, ClientIn) ->
|
||||||
str:substr(ClientIn,
|
str:substr(ClientIn,
|
||||||
str:str(ClientIn, <<"n=">>)),
|
str:str(ClientIn, <<"n=">>)),
|
||||||
ServerNonce =
|
ServerNonce =
|
||||||
aux:encode_base64(randoms:bytes(?NONCE_LENGTH)),
|
misc:encode_base64(randoms:bytes(?NONCE_LENGTH)),
|
||||||
ServerFirstMessage =
|
ServerFirstMessage =
|
||||||
iolist_to_binary(
|
iolist_to_binary(
|
||||||
["r=",
|
["r=",
|
||||||
ClientNonce,
|
ClientNonce,
|
||||||
ServerNonce,
|
ServerNonce,
|
||||||
",", "s=",
|
",", "s=",
|
||||||
aux:encode_base64(Salt),
|
misc:encode_base64(Salt),
|
||||||
",", "i=",
|
",", "i=",
|
||||||
integer_to_list(IterationCount)]),
|
integer_to_list(IterationCount)]),
|
||||||
{continue, ServerFirstMessage,
|
{continue, ServerFirstMessage,
|
||||||
|
@ -161,7 +161,7 @@ mech_step(#state{step = 4} = State, ClientIn) ->
|
||||||
ClientProofAttribute] ->
|
ClientProofAttribute] ->
|
||||||
case parse_attribute(GS2ChannelBindingAttribute) of
|
case parse_attribute(GS2ChannelBindingAttribute) of
|
||||||
{$c, CVal} ->
|
{$c, CVal} ->
|
||||||
ChannelBindingSupport = binary:at(aux:decode_base64(CVal), 0),
|
ChannelBindingSupport = binary:at(misc:decode_base64(CVal), 0),
|
||||||
if (ChannelBindingSupport == $n)
|
if (ChannelBindingSupport == $n)
|
||||||
or (ChannelBindingSupport == $y) ->
|
or (ChannelBindingSupport == $y) ->
|
||||||
Nonce = <<(State#state.client_nonce)/binary,
|
Nonce = <<(State#state.client_nonce)/binary,
|
||||||
|
@ -170,7 +170,7 @@ mech_step(#state{step = 4} = State, ClientIn) ->
|
||||||
{$r, CompareNonce} when CompareNonce == Nonce ->
|
{$r, CompareNonce} when CompareNonce == Nonce ->
|
||||||
case parse_attribute(ClientProofAttribute) of
|
case parse_attribute(ClientProofAttribute) of
|
||||||
{$p, ClientProofB64} ->
|
{$p, ClientProofB64} ->
|
||||||
ClientProof = aux:decode_base64(ClientProofB64),
|
ClientProof = misc:decode_base64(ClientProofB64),
|
||||||
AuthMessage = iolist_to_binary(
|
AuthMessage = iolist_to_binary(
|
||||||
[State#state.auth_message,
|
[State#state.auth_message,
|
||||||
",",
|
",",
|
||||||
|
@ -191,7 +191,7 @@ mech_step(#state{step = 4} = State, ClientIn) ->
|
||||||
{auth_module, State#state.auth_module},
|
{auth_module, State#state.auth_module},
|
||||||
{authzid, State#state.username}],
|
{authzid, State#state.username}],
|
||||||
<<"v=",
|
<<"v=",
|
||||||
(aux:encode_base64(ServerSignature))/binary>>};
|
(misc:encode_base64(ServerSignature))/binary>>};
|
||||||
true -> {error, not_authorized, State#state.username}
|
true -> {error, not_authorized, State#state.username}
|
||||||
end;
|
end;
|
||||||
_ -> {error, bad_attribute}
|
_ -> {error, bad_attribute}
|
||||||
|
|
|
@ -510,8 +510,8 @@ auth_modules(Server) ->
|
||||||
Default = ejabberd_config:default_db(LServer, ?MODULE),
|
Default = ejabberd_config:default_db(LServer, ?MODULE),
|
||||||
Methods = ejabberd_config:get_option(
|
Methods = ejabberd_config:get_option(
|
||||||
{auth_method, LServer}, opt_type(auth_method), [Default]),
|
{auth_method, LServer}, opt_type(auth_method), [Default]),
|
||||||
[aux:binary_to_atom(<<"ejabberd_auth_",
|
[misc:binary_to_atom(<<"ejabberd_auth_",
|
||||||
(aux:atom_to_binary(M))/binary>>)
|
(misc:atom_to_binary(M))/binary>>)
|
||||||
|| M <- Methods].
|
|| M <- Methods].
|
||||||
|
|
||||||
export(Server) ->
|
export(Server) ->
|
||||||
|
|
|
@ -361,8 +361,8 @@ result_attrs(#state{uids = UIDs,
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
parse_options(Host) ->
|
parse_options(Host) ->
|
||||||
Cfg = eldap_utils:get_config(Host, []),
|
Cfg = eldap_utils:get_config(Host, []),
|
||||||
Eldap_ID = aux:atom_to_binary(gen_mod:get_module_proc(Host, ?MODULE)),
|
Eldap_ID = misc:atom_to_binary(gen_mod:get_module_proc(Host, ?MODULE)),
|
||||||
Bind_Eldap_ID = aux:atom_to_binary(
|
Bind_Eldap_ID = misc:atom_to_binary(
|
||||||
gen_mod:get_module_proc(Host, bind_ejabberd_auth_ldap)),
|
gen_mod:get_module_proc(Host, bind_ejabberd_auth_ldap)),
|
||||||
UIDsTemp = gen_mod:get_opt(
|
UIDsTemp = gen_mod:get_opt(
|
||||||
{ldap_uids, Host}, [],
|
{ldap_uids, Host}, [],
|
||||||
|
|
|
@ -129,7 +129,7 @@ check_password(User, AuthzId, Server, Password, Digest,
|
||||||
true -> (Passwd == Password) and (Password /= <<"">>)
|
true -> (Passwd == Password) and (Password /= <<"">>)
|
||||||
end;
|
end;
|
||||||
[#passwd{password = Scram}] when is_record(Scram, scram) ->
|
[#passwd{password = Scram}] when is_record(Scram, scram) ->
|
||||||
Passwd = aux:decode_base64(Scram#scram.storedkey),
|
Passwd = misc:decode_base64(Scram#scram.storedkey),
|
||||||
DigRes = if Digest /= <<"">> ->
|
DigRes = if Digest /= <<"">> ->
|
||||||
Digest == DigestGen(Passwd);
|
Digest == DigestGen(Passwd);
|
||||||
true -> false
|
true -> false
|
||||||
|
@ -294,9 +294,9 @@ get_password(User, Server) ->
|
||||||
Password;
|
Password;
|
||||||
[#passwd{password = Scram}]
|
[#passwd{password = Scram}]
|
||||||
when is_record(Scram, scram) ->
|
when is_record(Scram, scram) ->
|
||||||
{aux:decode_base64(Scram#scram.storedkey),
|
{misc:decode_base64(Scram#scram.storedkey),
|
||||||
aux:decode_base64(Scram#scram.serverkey),
|
misc:decode_base64(Scram#scram.serverkey),
|
||||||
aux:decode_base64(Scram#scram.salt),
|
misc:decode_base64(Scram#scram.salt),
|
||||||
Scram#scram.iterationcount};
|
Scram#scram.iterationcount};
|
||||||
_ -> false
|
_ -> false
|
||||||
end.
|
end.
|
||||||
|
@ -480,9 +480,9 @@ password_to_scram(Password, IterationCount) ->
|
||||||
StoredKey =
|
StoredKey =
|
||||||
scram:stored_key(scram:client_key(SaltedPassword)),
|
scram:stored_key(scram:client_key(SaltedPassword)),
|
||||||
ServerKey = scram:server_key(SaltedPassword),
|
ServerKey = scram:server_key(SaltedPassword),
|
||||||
#scram{storedkey = aux:encode_base64(StoredKey),
|
#scram{storedkey = misc:encode_base64(StoredKey),
|
||||||
serverkey = aux:encode_base64(ServerKey),
|
serverkey = misc:encode_base64(ServerKey),
|
||||||
salt = aux:encode_base64(Salt),
|
salt = misc:encode_base64(Salt),
|
||||||
iterationcount = IterationCount}.
|
iterationcount = IterationCount}.
|
||||||
|
|
||||||
is_password_scram_valid(Password, Scram) ->
|
is_password_scram_valid(Password, Scram) ->
|
||||||
|
@ -491,12 +491,12 @@ is_password_scram_valid(Password, Scram) ->
|
||||||
false;
|
false;
|
||||||
_ ->
|
_ ->
|
||||||
IterationCount = Scram#scram.iterationcount,
|
IterationCount = Scram#scram.iterationcount,
|
||||||
Salt = aux:decode_base64(Scram#scram.salt),
|
Salt = misc:decode_base64(Scram#scram.salt),
|
||||||
SaltedPassword = scram:salted_password(Password, Salt,
|
SaltedPassword = scram:salted_password(Password, Salt,
|
||||||
IterationCount),
|
IterationCount),
|
||||||
StoredKey =
|
StoredKey =
|
||||||
scram:stored_key(scram:client_key(SaltedPassword)),
|
scram:stored_key(scram:client_key(SaltedPassword)),
|
||||||
aux:decode_base64(Scram#scram.storedkey) == StoredKey
|
misc:decode_base64(Scram#scram.storedkey) == StoredKey
|
||||||
end.
|
end.
|
||||||
|
|
||||||
export(_Server) ->
|
export(_Server) ->
|
||||||
|
|
|
@ -108,7 +108,7 @@ check_password(User, AuthzId, Server, Password, Digest,
|
||||||
end;
|
end;
|
||||||
{ok, #passwd{password = Scram}}
|
{ok, #passwd{password = Scram}}
|
||||||
when is_record(Scram, scram) ->
|
when is_record(Scram, scram) ->
|
||||||
Passwd = aux:decode_base64(Scram#scram.storedkey),
|
Passwd = misc:decode_base64(Scram#scram.storedkey),
|
||||||
DigRes = if Digest /= <<"">> ->
|
DigRes = if Digest /= <<"">> ->
|
||||||
Digest == DigestGen(Passwd);
|
Digest == DigestGen(Passwd);
|
||||||
true -> false
|
true -> false
|
||||||
|
@ -213,9 +213,9 @@ get_password(User, Server) ->
|
||||||
Password;
|
Password;
|
||||||
{ok, #passwd{password = Scram}}
|
{ok, #passwd{password = Scram}}
|
||||||
when is_record(Scram, scram) ->
|
when is_record(Scram, scram) ->
|
||||||
{aux:decode_base64(Scram#scram.storedkey),
|
{misc:decode_base64(Scram#scram.storedkey),
|
||||||
aux:decode_base64(Scram#scram.serverkey),
|
misc:decode_base64(Scram#scram.serverkey),
|
||||||
aux:decode_base64(Scram#scram.salt),
|
misc:decode_base64(Scram#scram.salt),
|
||||||
Scram#scram.iterationcount};
|
Scram#scram.iterationcount};
|
||||||
_ -> false
|
_ -> false
|
||||||
end.
|
end.
|
||||||
|
@ -287,9 +287,9 @@ password_to_scram(Password, IterationCount) ->
|
||||||
StoredKey =
|
StoredKey =
|
||||||
scram:stored_key(scram:client_key(SaltedPassword)),
|
scram:stored_key(scram:client_key(SaltedPassword)),
|
||||||
ServerKey = scram:server_key(SaltedPassword),
|
ServerKey = scram:server_key(SaltedPassword),
|
||||||
#scram{storedkey = aux:encode_base64(StoredKey),
|
#scram{storedkey = misc:encode_base64(StoredKey),
|
||||||
serverkey = aux:encode_base64(ServerKey),
|
serverkey = misc:encode_base64(ServerKey),
|
||||||
salt = aux:encode_base64(Salt),
|
salt = misc:encode_base64(Salt),
|
||||||
iterationcount = IterationCount}.
|
iterationcount = IterationCount}.
|
||||||
|
|
||||||
is_password_scram_valid(Password, Scram) ->
|
is_password_scram_valid(Password, Scram) ->
|
||||||
|
@ -298,12 +298,12 @@ is_password_scram_valid(Password, Scram) ->
|
||||||
false;
|
false;
|
||||||
_ ->
|
_ ->
|
||||||
IterationCount = Scram#scram.iterationcount,
|
IterationCount = Scram#scram.iterationcount,
|
||||||
Salt = aux:decode_base64(Scram#scram.salt),
|
Salt = misc:decode_base64(Scram#scram.salt),
|
||||||
SaltedPassword = scram:salted_password(Password, Salt,
|
SaltedPassword = scram:salted_password(Password, Salt,
|
||||||
IterationCount),
|
IterationCount),
|
||||||
StoredKey =
|
StoredKey =
|
||||||
scram:stored_key(scram:client_key(SaltedPassword)),
|
scram:stored_key(scram:client_key(SaltedPassword)),
|
||||||
aux:decode_base64(Scram#scram.storedkey) == StoredKey
|
misc:decode_base64(Scram#scram.storedkey) == StoredKey
|
||||||
end.
|
end.
|
||||||
|
|
||||||
export(_Server) ->
|
export(_Server) ->
|
||||||
|
|
|
@ -301,9 +301,9 @@ get_password(User, Server) ->
|
||||||
LServer, LUser) of
|
LServer, LUser) of
|
||||||
{selected,
|
{selected,
|
||||||
[{StoredKey, ServerKey, Salt, IterationCount}]} ->
|
[{StoredKey, ServerKey, Salt, IterationCount}]} ->
|
||||||
{aux:decode_base64(StoredKey),
|
{misc:decode_base64(StoredKey),
|
||||||
aux:decode_base64(ServerKey),
|
misc:decode_base64(ServerKey),
|
||||||
aux:decode_base64(Salt),
|
misc:decode_base64(Salt),
|
||||||
IterationCount};
|
IterationCount};
|
||||||
_ -> false
|
_ -> false
|
||||||
end;
|
end;
|
||||||
|
@ -423,9 +423,9 @@ password_to_scram(Password, IterationCount) ->
|
||||||
StoredKey =
|
StoredKey =
|
||||||
scram:stored_key(scram:client_key(SaltedPassword)),
|
scram:stored_key(scram:client_key(SaltedPassword)),
|
||||||
ServerKey = scram:server_key(SaltedPassword),
|
ServerKey = scram:server_key(SaltedPassword),
|
||||||
#scram{storedkey = aux:encode_base64(StoredKey),
|
#scram{storedkey = misc:encode_base64(StoredKey),
|
||||||
serverkey = aux:encode_base64(ServerKey),
|
serverkey = misc:encode_base64(ServerKey),
|
||||||
salt = aux:encode_base64(Salt),
|
salt = misc:encode_base64(Salt),
|
||||||
iterationcount = IterationCount}.
|
iterationcount = IterationCount}.
|
||||||
|
|
||||||
is_password_scram_valid_stored(Pass, {scram,Pass,<<>>,<<>>,0}, LUser, LServer) ->
|
is_password_scram_valid_stored(Pass, {scram,Pass,<<>>,<<>>,0}, LUser, LServer) ->
|
||||||
|
@ -443,12 +443,12 @@ is_password_scram_valid(Password, Scram) ->
|
||||||
false;
|
false;
|
||||||
_ ->
|
_ ->
|
||||||
IterationCount = Scram#scram.iterationcount,
|
IterationCount = Scram#scram.iterationcount,
|
||||||
Salt = aux:decode_base64(Scram#scram.salt),
|
Salt = misc:decode_base64(Scram#scram.salt),
|
||||||
SaltedPassword = scram:salted_password(Password, Salt,
|
SaltedPassword = scram:salted_password(Password, Salt,
|
||||||
IterationCount),
|
IterationCount),
|
||||||
StoredKey =
|
StoredKey =
|
||||||
scram:stored_key(scram:client_key(SaltedPassword)),
|
scram:stored_key(scram:client_key(SaltedPassword)),
|
||||||
aux:decode_base64(Scram#scram.storedkey) == StoredKey
|
misc:decode_base64(Scram#scram.storedkey) == StoredKey
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-define(BATCH_SIZE, 1000).
|
-define(BATCH_SIZE, 1000).
|
||||||
|
|
|
@ -438,7 +438,7 @@ handle_auth_success(User, Mech, AuthModule,
|
||||||
?INFO_MSG("(~s) Accepted c2s ~s authentication for ~s@~s by ~s backend from ~s",
|
?INFO_MSG("(~s) Accepted c2s ~s authentication for ~s@~s by ~s backend from ~s",
|
||||||
[SockMod:pp(Socket), Mech, User, LServer,
|
[SockMod:pp(Socket), Mech, User, LServer,
|
||||||
ejabberd_auth:backend_type(AuthModule),
|
ejabberd_auth:backend_type(AuthModule),
|
||||||
ejabberd_config:may_hide_data(aux:ip_to_list(IP))]),
|
ejabberd_config:may_hide_data(misc:ip_to_list(IP))]),
|
||||||
State1 = State#{auth_module => AuthModule},
|
State1 = State#{auth_module => AuthModule},
|
||||||
ejabberd_hooks:run_fold(c2s_auth_result, LServer, State1, [true, User]).
|
ejabberd_hooks:run_fold(c2s_auth_result, LServer, State1, [true, User]).
|
||||||
|
|
||||||
|
@ -450,7 +450,7 @@ handle_auth_failure(User, Mech, Reason,
|
||||||
if User /= <<"">> -> ["for ", User, "@", LServer, " "];
|
if User /= <<"">> -> ["for ", User, "@", LServer, " "];
|
||||||
true -> ""
|
true -> ""
|
||||||
end,
|
end,
|
||||||
ejabberd_config:may_hide_data(aux:ip_to_list(IP)), Reason]),
|
ejabberd_config:may_hide_data(misc:ip_to_list(IP)), Reason]),
|
||||||
ejabberd_hooks:run_fold(c2s_auth_result, LServer, State, [false, User]).
|
ejabberd_hooks:run_fold(c2s_auth_result, LServer, State, [false, User]).
|
||||||
|
|
||||||
handle_unbinded_packet(Pkt, #{lserver := LServer} = State) ->
|
handle_unbinded_packet(Pkt, #{lserver := LServer} = State) ->
|
||||||
|
|
|
@ -73,7 +73,7 @@ start() ->
|
||||||
nocookie ->
|
nocookie ->
|
||||||
str:sha(randoms:get_string());
|
str:sha(randoms:get_string());
|
||||||
Cookie ->
|
Cookie ->
|
||||||
str:sha(aux:atom_to_binary(Cookie))
|
str:sha(misc:atom_to_binary(Cookie))
|
||||||
end,
|
end,
|
||||||
State2 = set_option({node_start, global}, UnixTime, State1),
|
State2 = set_option({node_start, global}, UnixTime, State1),
|
||||||
State3 = set_option({shared_key, global}, SharedKey, State2),
|
State3 = set_option({shared_key, global}, SharedKey, State2),
|
||||||
|
|
|
@ -258,7 +258,7 @@ process_header(State, Data) ->
|
||||||
request_version = Version, request_path = Path,
|
request_version = Version, request_path = Path,
|
||||||
request_keepalive = KeepAlive};
|
request_keepalive = KeepAlive};
|
||||||
{ok, {http_header, _, 'Connection' = Name, _, Conn}} ->
|
{ok, {http_header, _, 'Connection' = Name, _, Conn}} ->
|
||||||
KeepAlive1 = case aux:tolower(Conn) of
|
KeepAlive1 = case misc:tolower(Conn) of
|
||||||
<<"keep-alive">> -> true;
|
<<"keep-alive">> -> true;
|
||||||
<<"close">> -> false;
|
<<"close">> -> false;
|
||||||
_ -> State#state.request_keepalive
|
_ -> State#state.request_keepalive
|
||||||
|
@ -520,7 +520,7 @@ make_bad_request(State) ->
|
||||||
analyze_ip_xff(IP, [], _Host) -> IP;
|
analyze_ip_xff(IP, [], _Host) -> IP;
|
||||||
analyze_ip_xff({IPLast, Port}, XFF, Host) ->
|
analyze_ip_xff({IPLast, Port}, XFF, Host) ->
|
||||||
[ClientIP | ProxiesIPs] = str:tokens(XFF, <<", ">>) ++
|
[ClientIP | ProxiesIPs] = str:tokens(XFF, <<", ">>) ++
|
||||||
[aux:ip_to_list(IPLast)],
|
[misc:ip_to_list(IPLast)],
|
||||||
TrustedProxies = ejabberd_config:get_option(
|
TrustedProxies = ejabberd_config:get_option(
|
||||||
{trusted_proxies, Host},
|
{trusted_proxies, Host},
|
||||||
fun(all) -> all;
|
fun(all) -> all;
|
||||||
|
@ -735,7 +735,7 @@ rest_dir(N, Path, <<_H, T/binary>>) -> rest_dir(N, Path, T).
|
||||||
|
|
||||||
expand_custom_headers(Headers) ->
|
expand_custom_headers(Headers) ->
|
||||||
lists:map(fun({K, V}) ->
|
lists:map(fun({K, V}) ->
|
||||||
{K, aux:expand_keyword(<<"@VERSION@">>, V, ?VERSION)}
|
{K, misc:expand_keyword(<<"@VERSION@">>, V, ?VERSION)}
|
||||||
end, Headers).
|
end, Headers).
|
||||||
|
|
||||||
%% hex_to_integer
|
%% hex_to_integer
|
||||||
|
@ -801,7 +801,7 @@ code_to_phrase(505) -> <<"HTTP Version Not Supported">>.
|
||||||
|
|
||||||
-spec parse_auth(binary()) -> {binary(), binary()} | {oauth, binary(), []} | undefined.
|
-spec parse_auth(binary()) -> {binary(), binary()} | {oauth, binary(), []} | undefined.
|
||||||
parse_auth(<<"Basic ", Auth64/binary>>) ->
|
parse_auth(<<"Basic ", Auth64/binary>>) ->
|
||||||
Auth = aux:decode_base64(Auth64),
|
Auth = misc:decode_base64(Auth64),
|
||||||
%% Auth should be a string with the format: user@server:password
|
%% Auth should be a string with the format: user@server:password
|
||||||
%% Note that password can contain additional characters '@' and ':'
|
%% Note that password can contain additional characters '@' and ':'
|
||||||
case str:chr(Auth, $:) of
|
case str:chr(Auth, $:) of
|
||||||
|
|
|
@ -283,7 +283,7 @@ cancel_timer(Timer) ->
|
||||||
receive {timeout, Timer, _} -> ok after 0 -> ok end.
|
receive {timeout, Timer, _} -> ok after 0 -> ok end.
|
||||||
|
|
||||||
get_human_html_xmlel() ->
|
get_human_html_xmlel() ->
|
||||||
Heading = <<"ejabberd ", (aux:atom_to_binary(?MODULE))/binary>>,
|
Heading = <<"ejabberd ", (misc:atom_to_binary(?MODULE))/binary>>,
|
||||||
#xmlel{name = <<"html">>,
|
#xmlel{name = <<"html">>,
|
||||||
attrs =
|
attrs =
|
||||||
[{<<"xmlns">>, <<"http://www.w3.org/1999/xhtml">>}],
|
[{<<"xmlns">>, <<"http://www.w3.org/1999/xhtml">>}],
|
||||||
|
|
|
@ -206,10 +206,10 @@ parse_listener_portip(PortIP, Opts) ->
|
||||||
case add_proto(PortIP, Opts) of
|
case add_proto(PortIP, Opts) of
|
||||||
{P, Prot} ->
|
{P, Prot} ->
|
||||||
T = get_ip_tuple(IPOpt, IPVOpt),
|
T = get_ip_tuple(IPOpt, IPVOpt),
|
||||||
S = aux:ip_to_list(T),
|
S = misc:ip_to_list(T),
|
||||||
{P, T, S, Prot};
|
{P, T, S, Prot};
|
||||||
{P, T, Prot} when is_integer(P) and is_tuple(T) ->
|
{P, T, Prot} when is_integer(P) and is_tuple(T) ->
|
||||||
S = aux:ip_to_list(T),
|
S = misc:ip_to_list(T),
|
||||||
{P, T, S, Prot};
|
{P, T, S, Prot};
|
||||||
{P, S, Prot} when is_integer(P) and is_binary(S) ->
|
{P, S, Prot} when is_integer(P) and is_binary(S) ->
|
||||||
[S | _] = str:tokens(S, <<"/">>),
|
[S | _] = str:tokens(S, <<"/">>),
|
||||||
|
|
|
@ -68,12 +68,12 @@ start_link(I) ->
|
||||||
?GEN_SERVER:start_link({local, get_proc(I)}, ?MODULE, [I], []).
|
?GEN_SERVER:start_link({local, get_proc(I)}, ?MODULE, [I], []).
|
||||||
|
|
||||||
get_proc(I) ->
|
get_proc(I) ->
|
||||||
aux:binary_to_atom(
|
misc:binary_to_atom(
|
||||||
iolist_to_binary(
|
iolist_to_binary(
|
||||||
[atom_to_list(?MODULE), $_, integer_to_list(I)])).
|
[atom_to_list(?MODULE), $_, integer_to_list(I)])).
|
||||||
|
|
||||||
get_connection(I) ->
|
get_connection(I) ->
|
||||||
aux:binary_to_atom(
|
misc:binary_to_atom(
|
||||||
iolist_to_binary(
|
iolist_to_binary(
|
||||||
[atom_to_list(?MODULE), "_connection_", integer_to_list(I)])).
|
[atom_to_list(?MODULE), "_connection_", integer_to_list(I)])).
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ multi(F) ->
|
||||||
|
|
||||||
-spec format_error(atom() | binary()) -> binary().
|
-spec format_error(atom() | binary()) -> binary().
|
||||||
format_error(Reason) when is_atom(Reason) ->
|
format_error(Reason) when is_atom(Reason) ->
|
||||||
format_error(aux:atom_to_binary(Reason));
|
format_error(misc:atom_to_binary(Reason));
|
||||||
format_error(Reason) ->
|
format_error(Reason) ->
|
||||||
Reason.
|
Reason.
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ is_connected() ->
|
||||||
|
|
||||||
%% @private
|
%% @private
|
||||||
get_proc(I) ->
|
get_proc(I) ->
|
||||||
aux:binary_to_atom(
|
misc:binary_to_atom(
|
||||||
iolist_to_binary(
|
iolist_to_binary(
|
||||||
[atom_to_list(?MODULE), $_, integer_to_list(I)])).
|
[atom_to_list(?MODULE), $_, integer_to_list(I)])).
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ init() ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
register_route(Domain, ServerHost, LocalHint, _, Pid) ->
|
register_route(Domain, ServerHost, LocalHint, _, Pid) ->
|
||||||
PidS = aux:encode_pid(Pid),
|
PidS = misc:encode_pid(Pid),
|
||||||
LocalHintS = enc_local_hint(LocalHint),
|
LocalHintS = enc_local_hint(LocalHint),
|
||||||
Node = erlang:atom_to_binary(node(Pid), latin1),
|
Node = erlang:atom_to_binary(node(Pid), latin1),
|
||||||
case ?SQL_UPSERT(?MYNAME, "route",
|
case ?SQL_UPSERT(?MYNAME, "route",
|
||||||
|
@ -68,7 +68,7 @@ register_route(Domain, ServerHost, LocalHint, _, Pid) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
unregister_route(Domain, _, Pid) ->
|
unregister_route(Domain, _, Pid) ->
|
||||||
PidS = aux:encode_pid(Pid),
|
PidS = misc:encode_pid(Pid),
|
||||||
Node = erlang:atom_to_binary(node(Pid), latin1),
|
Node = erlang:atom_to_binary(node(Pid), latin1),
|
||||||
ejabberd_sql:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
?MYNAME,
|
?MYNAME,
|
||||||
|
@ -146,7 +146,7 @@ find_routes() ->
|
||||||
enc_local_hint(undefined) ->
|
enc_local_hint(undefined) ->
|
||||||
<<"">>;
|
<<"">>;
|
||||||
enc_local_hint(LocalHint) ->
|
enc_local_hint(LocalHint) ->
|
||||||
aux:term_to_expr(LocalHint).
|
misc:term_to_expr(LocalHint).
|
||||||
|
|
||||||
dec_local_hint(<<"">>) ->
|
dec_local_hint(<<"">>) ->
|
||||||
undefined;
|
undefined;
|
||||||
|
@ -156,7 +156,7 @@ dec_local_hint(S) ->
|
||||||
row_to_route(Domain, {ServerHost, NodeS, PidS, LocalHintS} = Row) ->
|
row_to_route(Domain, {ServerHost, NodeS, PidS, LocalHintS} = Row) ->
|
||||||
try [#route{domain = Domain,
|
try [#route{domain = Domain,
|
||||||
server_host = ServerHost,
|
server_host = ServerHost,
|
||||||
pid = aux:decode_pid(PidS, NodeS),
|
pid = misc:decode_pid(PidS, NodeS),
|
||||||
local_hint = dec_local_hint(LocalHintS)}]
|
local_hint = dec_local_hint(LocalHintS)}]
|
||||||
catch _:{bad_node, _} ->
|
catch _:{bad_node, _} ->
|
||||||
[];
|
[];
|
||||||
|
|
|
@ -669,7 +669,7 @@ transform_options({{s2s_host, Host}, Action}, Opts) ->
|
||||||
?WARNING_MSG("Option 's2s_host' is deprecated. "
|
?WARNING_MSG("Option 's2s_host' is deprecated. "
|
||||||
"The option is still supported but it is better to "
|
"The option is still supported but it is better to "
|
||||||
"fix your config: use access rules instead.", []),
|
"fix your config: use access rules instead.", []),
|
||||||
ACLName = aux:binary_to_atom(
|
ACLName = misc:binary_to_atom(
|
||||||
iolist_to_binary(["s2s_access_", Host])),
|
iolist_to_binary(["s2s_access_", Host])),
|
||||||
[{acl, ACLName, {server, Host}},
|
[{acl, ACLName, {server, Host}},
|
||||||
{access, s2s, [{Action, ACLName}]},
|
{access, s2s, [{Action, ACLName}]},
|
||||||
|
|
|
@ -182,7 +182,7 @@ handle_auth_success(RServer, Mech, _AuthModule,
|
||||||
lserver := LServer} = State) ->
|
lserver := LServer} = State) ->
|
||||||
?INFO_MSG("(~s) Accepted inbound s2s ~s authentication ~s -> ~s (~s)",
|
?INFO_MSG("(~s) Accepted inbound s2s ~s authentication ~s -> ~s (~s)",
|
||||||
[SockMod:pp(Socket), Mech, RServer, LServer,
|
[SockMod:pp(Socket), Mech, RServer, LServer,
|
||||||
ejabberd_config:may_hide_data(aux:ip_to_list(IP))]),
|
ejabberd_config:may_hide_data(misc:ip_to_list(IP))]),
|
||||||
State1 = case ejabberd_s2s:allow_host(ServerHost, RServer) of
|
State1 = case ejabberd_s2s:allow_host(ServerHost, RServer) of
|
||||||
true ->
|
true ->
|
||||||
AuthDomains1 = sets:add_element(RServer, AuthDomains),
|
AuthDomains1 = sets:add_element(RServer, AuthDomains),
|
||||||
|
@ -200,7 +200,7 @@ handle_auth_failure(RServer, Mech, Reason,
|
||||||
lserver := LServer} = State) ->
|
lserver := LServer} = State) ->
|
||||||
?INFO_MSG("(~s) Failed inbound s2s ~s authentication ~s -> ~s (~s): ~s",
|
?INFO_MSG("(~s) Failed inbound s2s ~s authentication ~s -> ~s (~s): ~s",
|
||||||
[SockMod:pp(Socket), Mech, RServer, LServer,
|
[SockMod:pp(Socket), Mech, RServer, LServer,
|
||||||
ejabberd_config:may_hide_data(aux:ip_to_list(IP)), Reason]),
|
ejabberd_config:may_hide_data(misc:ip_to_list(IP)), Reason]),
|
||||||
ejabberd_hooks:run_fold(s2s_in_auth_result,
|
ejabberd_hooks:run_fold(s2s_in_auth_result,
|
||||||
ServerHost, State, [false, RServer]).
|
ServerHost, State, [false, RServer]).
|
||||||
|
|
||||||
|
|
|
@ -230,7 +230,7 @@ handle_auth_success(Mech, #{sockmod := SockMod,
|
||||||
server := LServer} = State) ->
|
server := LServer} = State) ->
|
||||||
?INFO_MSG("(~s) Accepted outbound s2s ~s authentication ~s -> ~s (~s)",
|
?INFO_MSG("(~s) Accepted outbound s2s ~s authentication ~s -> ~s (~s)",
|
||||||
[SockMod:pp(Socket), Mech, LServer, RServer,
|
[SockMod:pp(Socket), Mech, LServer, RServer,
|
||||||
ejabberd_config:may_hide_data(aux:ip_to_list(IP))]),
|
ejabberd_config:may_hide_data(misc:ip_to_list(IP))]),
|
||||||
ejabberd_hooks:run_fold(s2s_out_auth_result, ServerHost, State, [true]).
|
ejabberd_hooks:run_fold(s2s_out_auth_result, ServerHost, State, [true]).
|
||||||
|
|
||||||
handle_auth_failure(Mech, Reason,
|
handle_auth_failure(Mech, Reason,
|
||||||
|
@ -241,7 +241,7 @@ handle_auth_failure(Mech, Reason,
|
||||||
server := LServer} = State) ->
|
server := LServer} = State) ->
|
||||||
?INFO_MSG("(~s) Failed outbound s2s ~s authentication ~s -> ~s (~s): ~s",
|
?INFO_MSG("(~s) Failed outbound s2s ~s authentication ~s -> ~s (~s): ~s",
|
||||||
[SockMod:pp(Socket), Mech, LServer, RServer,
|
[SockMod:pp(Socket), Mech, LServer, RServer,
|
||||||
ejabberd_config:may_hide_data(aux:ip_to_list(IP)),
|
ejabberd_config:may_hide_data(misc:ip_to_list(IP)),
|
||||||
xmpp_stream_out:format_error(Reason)]),
|
xmpp_stream_out:format_error(Reason)]),
|
||||||
ejabberd_hooks:run_fold(s2s_out_auth_result, ServerHost, State, [{false, Reason}]).
|
ejabberd_hooks:run_fold(s2s_out_auth_result, ServerHost, State, [{false, Reason}]).
|
||||||
|
|
||||||
|
|
|
@ -153,7 +153,7 @@ get_password_fun(#{remote_server := RemoteServer,
|
||||||
?INFO_MSG("(~s) Domain ~s is unconfigured for "
|
?INFO_MSG("(~s) Domain ~s is unconfigured for "
|
||||||
"external component from ~s",
|
"external component from ~s",
|
||||||
[SockMod:pp(Socket), RemoteServer,
|
[SockMod:pp(Socket), RemoteServer,
|
||||||
ejabberd_config:may_hide_data(aux:ip_to_list(IP))]),
|
ejabberd_config:may_hide_data(misc:ip_to_list(IP))]),
|
||||||
{false, undefined}
|
{false, undefined}
|
||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
@ -165,7 +165,7 @@ handle_auth_success(_, Mech, _,
|
||||||
?INFO_MSG("(~s) Accepted external component ~s authentication "
|
?INFO_MSG("(~s) Accepted external component ~s authentication "
|
||||||
"for ~s from ~s",
|
"for ~s from ~s",
|
||||||
[SockMod:pp(Socket), Mech, RemoteServer,
|
[SockMod:pp(Socket), Mech, RemoteServer,
|
||||||
ejabberd_config:may_hide_data(aux:ip_to_list(IP))]),
|
ejabberd_config:may_hide_data(misc:ip_to_list(IP))]),
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun (H) ->
|
fun (H) ->
|
||||||
ejabberd_router:register_route(H, ?MYNAME),
|
ejabberd_router:register_route(H, ?MYNAME),
|
||||||
|
@ -180,7 +180,7 @@ handle_auth_failure(_, Mech, Reason,
|
||||||
?INFO_MSG("(~s) Failed external component ~s authentication "
|
?INFO_MSG("(~s) Failed external component ~s authentication "
|
||||||
"for ~s from ~s: ~s",
|
"for ~s from ~s: ~s",
|
||||||
[SockMod:pp(Socket), Mech, RemoteServer,
|
[SockMod:pp(Socket), Mech, RemoteServer,
|
||||||
ejabberd_config:may_hide_data(aux:ip_to_list(IP)),
|
ejabberd_config:may_hide_data(misc:ip_to_list(IP)),
|
||||||
Reason]),
|
Reason]),
|
||||||
State.
|
State.
|
||||||
|
|
||||||
|
|
|
@ -65,10 +65,10 @@ init() ->
|
||||||
|
|
||||||
set_session(#session{sid = {Now, Pid}, usr = {U, LServer, R},
|
set_session(#session{sid = {Now, Pid}, usr = {U, LServer, R},
|
||||||
priority = Priority, info = Info}) ->
|
priority = Priority, info = Info}) ->
|
||||||
InfoS = aux:term_to_expr(Info),
|
InfoS = misc:term_to_expr(Info),
|
||||||
PrioS = enc_priority(Priority),
|
PrioS = enc_priority(Priority),
|
||||||
TS = now_to_timestamp(Now),
|
TS = now_to_timestamp(Now),
|
||||||
PidS = aux:encode_pid(Pid),
|
PidS = misc:encode_pid(Pid),
|
||||||
Node = erlang:atom_to_binary(node(Pid), latin1),
|
Node = erlang:atom_to_binary(node(Pid), latin1),
|
||||||
case ?SQL_UPSERT(LServer, "sm",
|
case ?SQL_UPSERT(LServer, "sm",
|
||||||
["!usec=%(TS)d",
|
["!usec=%(TS)d",
|
||||||
|
@ -194,7 +194,7 @@ enc_priority(Int) when is_integer(Int) ->
|
||||||
|
|
||||||
row_to_session(LServer, {USec, PidS, NodeS, User, Resource, PrioS, InfoS}) ->
|
row_to_session(LServer, {USec, PidS, NodeS, User, Resource, PrioS, InfoS}) ->
|
||||||
Now = timestamp_to_now(USec),
|
Now = timestamp_to_now(USec),
|
||||||
Pid = aux:decode_pid(PidS, NodeS),
|
Pid = misc:decode_pid(PidS, NodeS),
|
||||||
Priority = dec_priority(PrioS),
|
Priority = dec_priority(PrioS),
|
||||||
Info = ejabberd_sql:decode_term(InfoS),
|
Info = ejabberd_sql:decode_term(InfoS),
|
||||||
#session{sid = {Now, Pid}, us = {User, LServer},
|
#session{sid = {Now, Pid}, us = {User, LServer},
|
||||||
|
|
|
@ -644,7 +644,7 @@ generic_sql_query_format(SQLQuery) ->
|
||||||
|
|
||||||
generic_escape() ->
|
generic_escape() ->
|
||||||
#sql_escape{string = fun(X) -> <<"'", (escape(X))/binary, "'">> end,
|
#sql_escape{string = fun(X) -> <<"'", (escape(X))/binary, "'">> end,
|
||||||
integer = fun(X) -> aux:i2l(X) end,
|
integer = fun(X) -> misc:i2l(X) end,
|
||||||
boolean = fun(true) -> <<"1">>;
|
boolean = fun(true) -> <<"1">>;
|
||||||
(false) -> <<"0">>
|
(false) -> <<"0">>
|
||||||
end
|
end
|
||||||
|
@ -661,7 +661,7 @@ sqlite_sql_query_format(SQLQuery) ->
|
||||||
|
|
||||||
sqlite_escape() ->
|
sqlite_escape() ->
|
||||||
#sql_escape{string = fun(X) -> <<"'", (standard_escape(X))/binary, "'">> end,
|
#sql_escape{string = fun(X) -> <<"'", (standard_escape(X))/binary, "'">> end,
|
||||||
integer = fun(X) -> aux:i2l(X) end,
|
integer = fun(X) -> misc:i2l(X) end,
|
||||||
boolean = fun(true) -> <<"1">>;
|
boolean = fun(true) -> <<"1">>;
|
||||||
(false) -> <<"0">>
|
(false) -> <<"0">>
|
||||||
end
|
end
|
||||||
|
@ -685,7 +685,7 @@ pgsql_prepare(SQLQuery, State) ->
|
||||||
|
|
||||||
pgsql_execute_escape() ->
|
pgsql_execute_escape() ->
|
||||||
#sql_escape{string = fun(X) -> X end,
|
#sql_escape{string = fun(X) -> X end,
|
||||||
integer = fun(X) -> [aux:i2l(X)] end,
|
integer = fun(X) -> [misc:i2l(X)] end,
|
||||||
boolean = fun(true) -> "1";
|
boolean = fun(true) -> "1";
|
||||||
(false) -> "0"
|
(false) -> "0"
|
||||||
end
|
end
|
||||||
|
|
|
@ -296,14 +296,14 @@ process_command1(From, To, Body) ->
|
||||||
process_command2(str:tokens(Body, <<" ">>), From, To).
|
process_command2(str:tokens(Body, <<" ">>), From, To).
|
||||||
|
|
||||||
process_command2([<<"kill">>, SNode, SPid], From, To) ->
|
process_command2([<<"kill">>, SNode, SPid], From, To) ->
|
||||||
Node = aux:binary_to_atom(SNode),
|
Node = misc:binary_to_atom(SNode),
|
||||||
remote_command(Node, [kill, SPid], From, To);
|
remote_command(Node, [kill, SPid], From, To);
|
||||||
process_command2([<<"showlh">>, SNode], From, To) ->
|
process_command2([<<"showlh">>, SNode], From, To) ->
|
||||||
Node = aux:binary_to_atom(SNode),
|
Node = misc:binary_to_atom(SNode),
|
||||||
remote_command(Node, [showlh], From, To);
|
remote_command(Node, [showlh], From, To);
|
||||||
process_command2([<<"setlh">>, SNode, NewValueString],
|
process_command2([<<"setlh">>, SNode, NewValueString],
|
||||||
From, To) ->
|
From, To) ->
|
||||||
Node = aux:binary_to_atom(SNode),
|
Node = misc:binary_to_atom(SNode),
|
||||||
NewValue = binary_to_integer(NewValueString),
|
NewValue = binary_to_integer(NewValueString),
|
||||||
remote_command(Node, [setlh, NewValue], From, To);
|
remote_command(Node, [setlh, NewValue], From, To);
|
||||||
process_command2([<<"help">>], From, To) ->
|
process_command2([<<"help">>], From, To) ->
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -152,7 +152,7 @@ handshake(#ws{headers = Headers} = State) ->
|
||||||
V ->
|
V ->
|
||||||
[<<"Sec-Websocket-Protocol:">>, V, <<"\r\n">>]
|
[<<"Sec-Websocket-Protocol:">>, V, <<"\r\n">>]
|
||||||
end,
|
end,
|
||||||
Hash = aux:encode_base64(
|
Hash = misc:encode_base64(
|
||||||
crypto:hash(sha, <<Key/binary, "258EAFA5-E914-47DA-95CA-C5AB0DC85B11">>)),
|
crypto:hash(sha, <<Key/binary, "258EAFA5-E914-47DA-95CA-C5AB0DC85B11">>)),
|
||||||
{State, [<<"HTTP/1.1 101 Switching Protocols\r\n">>,
|
{State, [<<"HTTP/1.1 101 Switching Protocols\r\n">>,
|
||||||
<<"Upgrade: websocket\r\n">>,
|
<<"Upgrade: websocket\r\n">>,
|
||||||
|
|
|
@ -145,7 +145,7 @@
|
||||||
%%% API
|
%%% API
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
start_link(Name) ->
|
start_link(Name) ->
|
||||||
Reg_name = aux:binary_to_atom(<<"eldap_",
|
Reg_name = misc:binary_to_atom(<<"eldap_",
|
||||||
Name/binary>>),
|
Name/binary>>),
|
||||||
gen_fsm:start_link({local, Reg_name}, ?MODULE, [], []).
|
gen_fsm:start_link({local, Reg_name}, ?MODULE, [], []).
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ start_link(Name) ->
|
||||||
binary(), tlsopts()) -> any().
|
binary(), tlsopts()) -> any().
|
||||||
|
|
||||||
start_link(Name, Hosts, Port, Rootdn, Passwd, Opts) ->
|
start_link(Name, Hosts, Port, Rootdn, Passwd, Opts) ->
|
||||||
Reg_name = aux:binary_to_atom(<<"eldap_",
|
Reg_name = misc:binary_to_atom(<<"eldap_",
|
||||||
Name/binary>>),
|
Name/binary>>),
|
||||||
gen_fsm:start_link({local, Reg_name}, ?MODULE,
|
gen_fsm:start_link({local, Reg_name}, ?MODULE,
|
||||||
[Hosts, Port, Rootdn, Passwd, Opts], []).
|
[Hosts, Port, Rootdn, Passwd, Opts], []).
|
||||||
|
@ -548,7 +548,7 @@ extensibleMatch_opts([], MRA) -> MRA.
|
||||||
get_handle(Pid) when is_pid(Pid) -> Pid;
|
get_handle(Pid) when is_pid(Pid) -> Pid;
|
||||||
get_handle(Atom) when is_atom(Atom) -> Atom;
|
get_handle(Atom) when is_atom(Atom) -> Atom;
|
||||||
get_handle(Name) when is_binary(Name) ->
|
get_handle(Name) when is_binary(Name) ->
|
||||||
aux:binary_to_atom(<<"eldap_",
|
misc:binary_to_atom(<<"eldap_",
|
||||||
Name/binary>>).
|
Name/binary>>).
|
||||||
|
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
|
@ -83,4 +83,4 @@ do_request(Name, {F, Args}) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
make_id(Name) ->
|
make_id(Name) ->
|
||||||
aux:binary_to_atom(<<"eldap_pool_", Name/binary>>).
|
misc:binary_to_atom(<<"eldap_pool_", Name/binary>>).
|
||||||
|
|
|
@ -160,9 +160,9 @@ available() ->
|
||||||
lists:keystore(Key, 1, Acc, {Key, Val})
|
lists:keystore(Key, 1, Acc, {Key, Val})
|
||||||
end, Jungle, Standalone)).
|
end, Jungle, Standalone)).
|
||||||
available(Module) when is_atom(Module) ->
|
available(Module) when is_atom(Module) ->
|
||||||
available(aux:atom_to_binary(Module));
|
available(misc:atom_to_binary(Module));
|
||||||
available(Package) when is_binary(Package) ->
|
available(Package) when is_binary(Package) ->
|
||||||
Available = [aux:atom_to_binary(K) || K<-proplists:get_keys(available())],
|
Available = [misc:atom_to_binary(K) || K<-proplists:get_keys(available())],
|
||||||
lists:member(Package, Available).
|
lists:member(Package, Available).
|
||||||
|
|
||||||
available_command() ->
|
available_command() ->
|
||||||
|
@ -171,18 +171,18 @@ available_command() ->
|
||||||
installed() ->
|
installed() ->
|
||||||
modules_spec(modules_dir(), "*").
|
modules_spec(modules_dir(), "*").
|
||||||
installed(Module) when is_atom(Module) ->
|
installed(Module) when is_atom(Module) ->
|
||||||
installed(aux:atom_to_binary(Module));
|
installed(misc:atom_to_binary(Module));
|
||||||
installed(Package) when is_binary(Package) ->
|
installed(Package) when is_binary(Package) ->
|
||||||
Installed = [aux:atom_to_binary(K) || K<-proplists:get_keys(installed())],
|
Installed = [misc:atom_to_binary(K) || K<-proplists:get_keys(installed())],
|
||||||
lists:member(Package, Installed).
|
lists:member(Package, Installed).
|
||||||
|
|
||||||
installed_command() ->
|
installed_command() ->
|
||||||
[short_spec(Item) || Item <- installed()].
|
[short_spec(Item) || Item <- installed()].
|
||||||
|
|
||||||
install(Module) when is_atom(Module) ->
|
install(Module) when is_atom(Module) ->
|
||||||
install(aux:atom_to_binary(Module));
|
install(misc:atom_to_binary(Module));
|
||||||
install(Package) when is_binary(Package) ->
|
install(Package) when is_binary(Package) ->
|
||||||
Spec = [S || {Mod, S} <- available(), aux:atom_to_binary(Mod)==Package],
|
Spec = [S || {Mod, S} <- available(), misc:atom_to_binary(Mod)==Package],
|
||||||
case {Spec, installed(Package), is_contrib_allowed()} of
|
case {Spec, installed(Package), is_contrib_allowed()} of
|
||||||
{_, _, false} ->
|
{_, _, false} ->
|
||||||
{error, not_allowed};
|
{error, not_allowed};
|
||||||
|
@ -191,7 +191,7 @@ install(Package) when is_binary(Package) ->
|
||||||
{_, true, _} ->
|
{_, true, _} ->
|
||||||
{error, conflict};
|
{error, conflict};
|
||||||
{[Attrs], _, _} ->
|
{[Attrs], _, _} ->
|
||||||
Module = aux:binary_to_atom(Package),
|
Module = misc:binary_to_atom(Package),
|
||||||
case compile_and_install(Module, Attrs) of
|
case compile_and_install(Module, Attrs) of
|
||||||
ok ->
|
ok ->
|
||||||
code:add_patha(module_ebin_dir(Module)),
|
code:add_patha(module_ebin_dir(Module)),
|
||||||
|
@ -207,11 +207,11 @@ install(Package) when is_binary(Package) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
uninstall(Module) when is_atom(Module) ->
|
uninstall(Module) when is_atom(Module) ->
|
||||||
uninstall(aux:atom_to_binary(Module));
|
uninstall(misc:atom_to_binary(Module));
|
||||||
uninstall(Package) when is_binary(Package) ->
|
uninstall(Package) when is_binary(Package) ->
|
||||||
case installed(Package) of
|
case installed(Package) of
|
||||||
true ->
|
true ->
|
||||||
Module = aux:binary_to_atom(Package),
|
Module = misc:binary_to_atom(Package),
|
||||||
case erlang:function_exported(Module, pre_uninstall, 0) of
|
case erlang:function_exported(Module, pre_uninstall, 0) of
|
||||||
true -> Module:pre_uninstall();
|
true -> Module:pre_uninstall();
|
||||||
_ -> ok
|
_ -> ok
|
||||||
|
@ -230,7 +230,7 @@ uninstall(Package) when is_binary(Package) ->
|
||||||
upgrade() ->
|
upgrade() ->
|
||||||
[{Package, upgrade(Package)} || {Package, _Spec} <- installed()].
|
[{Package, upgrade(Package)} || {Package, _Spec} <- installed()].
|
||||||
upgrade(Module) when is_atom(Module) ->
|
upgrade(Module) when is_atom(Module) ->
|
||||||
upgrade(aux:atom_to_binary(Module));
|
upgrade(misc:atom_to_binary(Module));
|
||||||
upgrade(Package) when is_binary(Package) ->
|
upgrade(Package) when is_binary(Package) ->
|
||||||
uninstall(Package),
|
uninstall(Package),
|
||||||
install(Package).
|
install(Package).
|
||||||
|
@ -240,7 +240,7 @@ add_sources(Path) when is_list(Path) ->
|
||||||
add_sources(_, "") ->
|
add_sources(_, "") ->
|
||||||
{error, no_url};
|
{error, no_url};
|
||||||
add_sources(Module, Path) when is_atom(Module), is_list(Path) ->
|
add_sources(Module, Path) when is_atom(Module), is_list(Path) ->
|
||||||
add_sources(aux:atom_to_binary(Module), Path);
|
add_sources(misc:atom_to_binary(Module), Path);
|
||||||
add_sources(Package, Path) when is_binary(Package), is_list(Path) ->
|
add_sources(Package, Path) when is_binary(Package), is_list(Path) ->
|
||||||
DestDir = sources_dir(),
|
DestDir = sources_dir(),
|
||||||
RepDir = filename:join(DestDir, module_name(Path)),
|
RepDir = filename:join(DestDir, module_name(Path)),
|
||||||
|
@ -261,18 +261,18 @@ add_sources(Package, Path) when is_binary(Package), is_list(Path) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
del_sources(Module) when is_atom(Module) ->
|
del_sources(Module) when is_atom(Module) ->
|
||||||
del_sources(aux:atom_to_binary(Module));
|
del_sources(misc:atom_to_binary(Module));
|
||||||
del_sources(Package) when is_binary(Package) ->
|
del_sources(Package) when is_binary(Package) ->
|
||||||
case uninstall(Package) of
|
case uninstall(Package) of
|
||||||
ok ->
|
ok ->
|
||||||
SrcDir = module_src_dir(aux:binary_to_atom(Package)),
|
SrcDir = module_src_dir(misc:binary_to_atom(Package)),
|
||||||
delete_path(SrcDir);
|
delete_path(SrcDir);
|
||||||
Error ->
|
Error ->
|
||||||
Error
|
Error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
check(Module) when is_atom(Module) ->
|
check(Module) when is_atom(Module) ->
|
||||||
check(aux:atom_to_binary(Module));
|
check(misc:atom_to_binary(Module));
|
||||||
check(Package) when is_binary(Package) ->
|
check(Package) when is_binary(Package) ->
|
||||||
case {available(Package), installed(Package)} of
|
case {available(Package), installed(Package)} of
|
||||||
{false, _} ->
|
{false, _} ->
|
||||||
|
@ -281,11 +281,11 @@ check(Package) when is_binary(Package) ->
|
||||||
Status = install(Package),
|
Status = install(Package),
|
||||||
uninstall(Package),
|
uninstall(Package),
|
||||||
case Status of
|
case Status of
|
||||||
ok -> check_sources(aux:binary_to_atom(Package));
|
ok -> check_sources(misc:binary_to_atom(Package));
|
||||||
Error -> Error
|
Error -> Error
|
||||||
end;
|
end;
|
||||||
_ ->
|
_ ->
|
||||||
check_sources(aux:binary_to_atom(Package))
|
check_sources(misc:binary_to_atom(Package))
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% -- archives and variables functions
|
%% -- archives and variables functions
|
||||||
|
@ -420,7 +420,7 @@ module_name(Id) ->
|
||||||
filename:basename(filename:rootname(Id)).
|
filename:basename(filename:rootname(Id)).
|
||||||
|
|
||||||
module(Id) ->
|
module(Id) ->
|
||||||
aux:binary_to_atom(iolist_to_binary(module_name(Id))).
|
misc:binary_to_atom(iolist_to_binary(module_name(Id))).
|
||||||
|
|
||||||
module_spec(Spec) ->
|
module_spec(Spec) ->
|
||||||
[{path, filename:dirname(Spec)}
|
[{path, filename:dirname(Spec)}
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
%%%
|
%%%
|
||||||
%%%-------------------------------------------------------------------
|
%%%-------------------------------------------------------------------
|
||||||
-module(aux).
|
-module(misc).
|
||||||
|
|
||||||
%% API
|
%% API
|
||||||
-export([tolower/1, term_to_base64/1, base64_to_term/1,
|
-export([tolower/1, term_to_base64/1, base64_to_term/1,
|
|
@ -673,7 +673,7 @@ get_cookie() ->
|
||||||
atom_to_list(erlang:get_cookie()).
|
atom_to_list(erlang:get_cookie()).
|
||||||
|
|
||||||
restart_module(Host, Module) when is_binary(Module) ->
|
restart_module(Host, Module) when is_binary(Module) ->
|
||||||
restart_module(Host, aux:binary_to_atom(Module));
|
restart_module(Host, misc:binary_to_atom(Module));
|
||||||
restart_module(Host, Module) when is_atom(Module) ->
|
restart_module(Host, Module) when is_atom(Module) ->
|
||||||
List = gen_mod:loaded_modules_with_opts(Host),
|
List = gen_mod:loaded_modules_with_opts(Host),
|
||||||
case proplists:get_value(Module, List) of
|
case proplists:get_value(Module, List) of
|
||||||
|
@ -1031,8 +1031,8 @@ set_presence(User, Host, Resource, Type, Show, Status, Priority0) ->
|
||||||
From = jid:make(User, Host, Resource),
|
From = jid:make(User, Host, Resource),
|
||||||
To = jid:make(User, Host),
|
To = jid:make(User, Host),
|
||||||
Presence = #presence{from = From, to = To,
|
Presence = #presence{from = From, to = To,
|
||||||
type = aux:binary_to_atom(Type),
|
type = misc:binary_to_atom(Type),
|
||||||
show = aux:binary_to_atom(Show),
|
show = misc:binary_to_atom(Show),
|
||||||
status = xmpp:mk_text(Status),
|
status = xmpp:mk_text(Status),
|
||||||
priority = Priority},
|
priority = Priority},
|
||||||
Pid ! {route, Presence},
|
Pid ! {route, Presence},
|
||||||
|
@ -1317,7 +1317,7 @@ build_roster_item(U, S, {add, Nick, Subs, Group}) ->
|
||||||
Groups = binary:split(Group,<<";">>, [global]),
|
Groups = binary:split(Group,<<";">>, [global]),
|
||||||
#roster_item{jid = jid:make(U, S),
|
#roster_item{jid = jid:make(U, S),
|
||||||
name = Nick,
|
name = Nick,
|
||||||
subscription = aux:binary_to_atom(Subs),
|
subscription = misc:binary_to_atom(Subs),
|
||||||
groups = Groups};
|
groups = Groups};
|
||||||
build_roster_item(U, S, remove) ->
|
build_roster_item(U, S, remove) ->
|
||||||
#roster_item{jid = jid:make(U, S), subscription = remove}.
|
#roster_item{jid = jid:make(U, S), subscription = remove}.
|
||||||
|
@ -1410,7 +1410,7 @@ srg_get_info(Group, Host) ->
|
||||||
Os when is_list(Os) -> Os;
|
Os when is_list(Os) -> Os;
|
||||||
error -> []
|
error -> []
|
||||||
end,
|
end,
|
||||||
[{aux:atom_to_binary(Title), btl(Value)} || {Title, Value} <- Opts].
|
[{misc:atom_to_binary(Title), btl(Value)} || {Title, Value} <- Opts].
|
||||||
|
|
||||||
btl([]) -> [];
|
btl([]) -> [];
|
||||||
btl([B|L]) -> [btl(B)|btl(L)];
|
btl([B|L]) -> [btl(B)|btl(L)];
|
||||||
|
@ -1443,7 +1443,7 @@ send_message(Type, From, To, Subject, Body) ->
|
||||||
ejabberd_router:route(xmpp:set_from_to(Packet, FromJID, ToJID)).
|
ejabberd_router:route(xmpp:set_from_to(Packet, FromJID, ToJID)).
|
||||||
|
|
||||||
build_packet(Type, Subject, Body) ->
|
build_packet(Type, Subject, Body) ->
|
||||||
#message{type = aux:binary_to_atom(Type),
|
#message{type = misc:binary_to_atom(Type),
|
||||||
body = xmpp:mk_text(Body),
|
body = xmpp:mk_text(Body),
|
||||||
subject = xmpp:mk_text(Subject)}.
|
subject = xmpp:mk_text(Subject)}.
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ init() ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
open_session(SID, Pid) ->
|
open_session(SID, Pid) ->
|
||||||
PidS = aux:encode_pid(Pid),
|
PidS = misc:encode_pid(Pid),
|
||||||
Node = erlang:atom_to_binary(node(Pid), latin1),
|
Node = erlang:atom_to_binary(node(Pid), latin1),
|
||||||
case ?SQL_UPSERT(?MYNAME, "bosh",
|
case ?SQL_UPSERT(?MYNAME, "bosh",
|
||||||
["!sid=%(SID)s",
|
["!sid=%(SID)s",
|
||||||
|
@ -57,7 +57,7 @@ find_session(SID) ->
|
||||||
?MYNAME,
|
?MYNAME,
|
||||||
?SQL("select @(pid)s, @(node)s from bosh where sid=%(SID)s")) of
|
?SQL("select @(pid)s, @(node)s from bosh where sid=%(SID)s")) of
|
||||||
{selected, [{Pid, Node}]} ->
|
{selected, [{Pid, Node}]} ->
|
||||||
try {ok, aux:decode_pid(Pid, Node)}
|
try {ok, misc:decode_pid(Pid, Node)}
|
||||||
catch _:{bad_node, _} -> error
|
catch _:{bad_node, _} -> error
|
||||||
end;
|
end;
|
||||||
{selected, []} ->
|
{selected, []} ->
|
||||||
|
|
|
@ -420,7 +420,7 @@ make_my_disco_hash(Host) ->
|
||||||
make_disco_hash(DiscoInfo, Algo) ->
|
make_disco_hash(DiscoInfo, Algo) ->
|
||||||
Concat = list_to_binary([concat_identities(DiscoInfo),
|
Concat = list_to_binary([concat_identities(DiscoInfo),
|
||||||
concat_features(DiscoInfo), concat_info(DiscoInfo)]),
|
concat_features(DiscoInfo), concat_info(DiscoInfo)]),
|
||||||
aux:encode_base64(case Algo of
|
misc:encode_base64(case Algo of
|
||||||
md5 -> erlang:md5(Concat);
|
md5 -> erlang:md5(Concat);
|
||||||
sha -> crypto:hash(sha, Concat);
|
sha -> crypto:hash(sha, Concat);
|
||||||
sha224 -> crypto:hash(sha224, Concat);
|
sha224 -> crypto:hash(sha224, Concat);
|
||||||
|
|
|
@ -919,7 +919,7 @@ get_form(Host,
|
||||||
ENode/binary>>,
|
ENode/binary>>,
|
||||||
Instr = ?T(Lang, <<"Choose modules to stop">>),
|
Instr = ?T(Lang, <<"Choose modules to stop">>),
|
||||||
Fs = lists:map(fun(M) ->
|
Fs = lists:map(fun(M) ->
|
||||||
S = aux:atom_to_binary(M),
|
S = misc:atom_to_binary(M),
|
||||||
?XFIELD(boolean, S, S, <<"0">>)
|
?XFIELD(boolean, S, S, <<"0">>)
|
||||||
end, SModules),
|
end, SModules),
|
||||||
{result, #xdata{title = Title,
|
{result, #xdata{title = Title,
|
||||||
|
@ -1224,7 +1224,7 @@ set_form(_From, _Host,
|
||||||
Node ->
|
Node ->
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun(#xdata_field{var = SVar, values = SVals}) ->
|
fun(#xdata_field{var = SVar, values = SVals}) ->
|
||||||
Table = aux:binary_to_atom(SVar),
|
Table = misc:binary_to_atom(SVar),
|
||||||
Type = case SVals of
|
Type = case SVals of
|
||||||
[<<"unknown">>] -> unknown;
|
[<<"unknown">>] -> unknown;
|
||||||
[<<"ram_copies">>] -> ram_copies;
|
[<<"ram_copies">>] -> ram_copies;
|
||||||
|
@ -1258,7 +1258,7 @@ set_form(_From, Host,
|
||||||
fun(#xdata_field{var = Var, values = Vals}) ->
|
fun(#xdata_field{var = Var, values = Vals}) ->
|
||||||
case Vals of
|
case Vals of
|
||||||
[<<"1">>] ->
|
[<<"1">>] ->
|
||||||
Module = aux:binary_to_atom(Var),
|
Module = misc:binary_to_atom(Var),
|
||||||
ejabberd_cluster:call(Node, gen_mod, stop_module,
|
ejabberd_cluster:call(Node, gen_mod, stop_module,
|
||||||
[Host, Module]);
|
[Host, Module]);
|
||||||
_ -> ok
|
_ -> ok
|
||||||
|
@ -1657,7 +1657,7 @@ set_form(From, Host, ?NS_ADMINL(<<"user-stats">>), Lang,
|
||||||
Server),
|
Server),
|
||||||
IPs1 = [ejabberd_sm:get_user_ip(User, Server, Resource)
|
IPs1 = [ejabberd_sm:get_user_ip(User, Server, Resource)
|
||||||
|| Resource <- Resources],
|
|| Resource <- Resources],
|
||||||
IPs = [<<(aux:ip_to_list(IP))/binary, ":",
|
IPs = [<<(misc:ip_to_list(IP))/binary, ":",
|
||||||
(integer_to_binary(Port))/binary>>
|
(integer_to_binary(Port))/binary>>
|
||||||
|| {IP, Port} <- IPs1],
|
|| {IP, Port} <- IPs1],
|
||||||
Items = ejabberd_hooks:run_fold(roster_get, Server, [],
|
Items = ejabberd_hooks:run_fold(roster_get, Server, [],
|
||||||
|
@ -1719,7 +1719,7 @@ stop_node(From, Host, ENode, Action, XData) ->
|
||||||
mod_announce:announce_commands(empty, From, To, Request)
|
mod_announce:announce_commands(empty, From, To, Request)
|
||||||
end,
|
end,
|
||||||
Time = timer:seconds(Delay),
|
Time = timer:seconds(Delay),
|
||||||
Node = aux:binary_to_atom(ENode),
|
Node = misc:binary_to_atom(ENode),
|
||||||
{ok, _} = timer:apply_after(Time, rpc, call, [Node, init, Action, []]),
|
{ok, _} = timer:apply_after(Time, rpc, call, [Node, init, Action, []]),
|
||||||
{result, undefined}.
|
{result, undefined}.
|
||||||
|
|
||||||
|
|
|
@ -166,7 +166,7 @@ code_change(_OldVsn, State, _Extra) ->
|
||||||
-spec log_and_disconnect(ejabberd_c2s:state(), pos_integer(), non_neg_integer())
|
-spec log_and_disconnect(ejabberd_c2s:state(), pos_integer(), non_neg_integer())
|
||||||
-> {stop, ejabberd_c2s:state()}.
|
-> {stop, ejabberd_c2s:state()}.
|
||||||
log_and_disconnect(#{ip := {Addr, _}, lang := Lang} = State, Attempts, UnbanTS) ->
|
log_and_disconnect(#{ip := {Addr, _}, lang := Lang} = State, Attempts, UnbanTS) ->
|
||||||
IP = aux:ip_to_list(Addr),
|
IP = misc:ip_to_list(Addr),
|
||||||
UnbanDate = format_date(
|
UnbanDate = format_date(
|
||||||
calendar:now_to_universal_time(seconds_to_now(UnbanTS))),
|
calendar:now_to_universal_time(seconds_to_now(UnbanTS))),
|
||||||
Format = <<"Too many (~p) failed authentications "
|
Format = <<"Too many (~p) failed authentications "
|
||||||
|
|
|
@ -272,7 +272,7 @@ get_api_version([]) ->
|
||||||
handle(Call, Auth, Args, Version) when is_atom(Call), is_list(Args) ->
|
handle(Call, Auth, Args, Version) when is_atom(Call), is_list(Args) ->
|
||||||
case ejabberd_commands:get_command_format(Call, Auth, Version) of
|
case ejabberd_commands:get_command_format(Call, Auth, Version) of
|
||||||
{ArgsSpec, _} when is_list(ArgsSpec) ->
|
{ArgsSpec, _} when is_list(ArgsSpec) ->
|
||||||
Args2 = [{aux:binary_to_atom(Key), Value} || {Key, Value} <- Args],
|
Args2 = [{misc:binary_to_atom(Key), Value} || {Key, Value} <- Args],
|
||||||
Spec = lists:foldr(
|
Spec = lists:foldr(
|
||||||
fun ({Key, binary}, Acc) ->
|
fun ({Key, binary}, Acc) ->
|
||||||
[{Key, <<>>}|Acc];
|
[{Key, <<>>}|Acc];
|
||||||
|
@ -290,13 +290,13 @@ handle(Call, Auth, Args, Version) when is_atom(Call), is_list(Args) ->
|
||||||
catch throw:not_found ->
|
catch throw:not_found ->
|
||||||
{404, <<"not_found">>};
|
{404, <<"not_found">>};
|
||||||
throw:{not_found, Why} when is_atom(Why) ->
|
throw:{not_found, Why} when is_atom(Why) ->
|
||||||
{404, aux:atom_to_binary(Why)};
|
{404, misc:atom_to_binary(Why)};
|
||||||
throw:{not_found, Msg} ->
|
throw:{not_found, Msg} ->
|
||||||
{404, iolist_to_binary(Msg)};
|
{404, iolist_to_binary(Msg)};
|
||||||
throw:not_allowed ->
|
throw:not_allowed ->
|
||||||
{401, <<"not_allowed">>};
|
{401, <<"not_allowed">>};
|
||||||
throw:{not_allowed, Why} when is_atom(Why) ->
|
throw:{not_allowed, Why} when is_atom(Why) ->
|
||||||
{401, aux:atom_to_binary(Why)};
|
{401, misc:atom_to_binary(Why)};
|
||||||
throw:{not_allowed, Msg} ->
|
throw:{not_allowed, Msg} ->
|
||||||
{401, iolist_to_binary(Msg)};
|
{401, iolist_to_binary(Msg)};
|
||||||
throw:{error, account_unprivileged} ->
|
throw:{error, account_unprivileged} ->
|
||||||
|
@ -306,11 +306,11 @@ handle(Call, Auth, Args, Version) when is_atom(Call), is_list(Args) ->
|
||||||
throw:{invalid_parameter, Msg} ->
|
throw:{invalid_parameter, Msg} ->
|
||||||
{400, iolist_to_binary(Msg)};
|
{400, iolist_to_binary(Msg)};
|
||||||
throw:{error, Why} when is_atom(Why) ->
|
throw:{error, Why} when is_atom(Why) ->
|
||||||
{400, aux:atom_to_binary(Why)};
|
{400, misc:atom_to_binary(Why)};
|
||||||
throw:{error, Msg} ->
|
throw:{error, Msg} ->
|
||||||
{400, iolist_to_binary(Msg)};
|
{400, iolist_to_binary(Msg)};
|
||||||
throw:Error when is_atom(Error) ->
|
throw:Error when is_atom(Error) ->
|
||||||
{400, aux:atom_to_binary(Error)};
|
{400, misc:atom_to_binary(Error)};
|
||||||
throw:Msg when is_list(Msg); is_binary(Msg) ->
|
throw:Msg when is_list(Msg); is_binary(Msg) ->
|
||||||
{400, iolist_to_binary(Msg)};
|
{400, iolist_to_binary(Msg)};
|
||||||
_Error ->
|
_Error ->
|
||||||
|
@ -456,45 +456,45 @@ format_command_result(Cmd, Auth, Result, Version) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
format_result(Atom, {Name, atom}) ->
|
format_result(Atom, {Name, atom}) ->
|
||||||
{aux:atom_to_binary(Name), aux:atom_to_binary(Atom)};
|
{misc:atom_to_binary(Name), misc:atom_to_binary(Atom)};
|
||||||
|
|
||||||
format_result(Int, {Name, integer}) ->
|
format_result(Int, {Name, integer}) ->
|
||||||
{aux:atom_to_binary(Name), Int};
|
{misc:atom_to_binary(Name), Int};
|
||||||
|
|
||||||
format_result([String | _] = StringList, {Name, string}) when is_list(String) ->
|
format_result([String | _] = StringList, {Name, string}) when is_list(String) ->
|
||||||
Binarized = iolist_to_binary(string:join(StringList, "\n")),
|
Binarized = iolist_to_binary(string:join(StringList, "\n")),
|
||||||
{aux:atom_to_binary(Name), Binarized};
|
{misc:atom_to_binary(Name), Binarized};
|
||||||
|
|
||||||
format_result(String, {Name, string}) ->
|
format_result(String, {Name, string}) ->
|
||||||
{aux:atom_to_binary(Name), iolist_to_binary(String)};
|
{misc:atom_to_binary(Name), iolist_to_binary(String)};
|
||||||
|
|
||||||
format_result(Code, {Name, rescode}) ->
|
format_result(Code, {Name, rescode}) ->
|
||||||
{aux:atom_to_binary(Name), Code == true orelse Code == ok};
|
{misc:atom_to_binary(Name), Code == true orelse Code == ok};
|
||||||
|
|
||||||
format_result({Code, Text}, {Name, restuple}) ->
|
format_result({Code, Text}, {Name, restuple}) ->
|
||||||
{aux:atom_to_binary(Name),
|
{misc:atom_to_binary(Name),
|
||||||
{[{<<"res">>, Code == true orelse Code == ok},
|
{[{<<"res">>, Code == true orelse Code == ok},
|
||||||
{<<"text">>, iolist_to_binary(Text)}]}};
|
{<<"text">>, iolist_to_binary(Text)}]}};
|
||||||
|
|
||||||
format_result(Code, {Name, restuple}) ->
|
format_result(Code, {Name, restuple}) ->
|
||||||
{aux:atom_to_binary(Name),
|
{misc:atom_to_binary(Name),
|
||||||
{[{<<"res">>, Code == true orelse Code == ok},
|
{[{<<"res">>, Code == true orelse Code == ok},
|
||||||
{<<"text">>, <<"">>}]}};
|
{<<"text">>, <<"">>}]}};
|
||||||
|
|
||||||
format_result(Els, {Name, {list, {_, {tuple, [{_, atom}, _]}} = Fmt}}) ->
|
format_result(Els, {Name, {list, {_, {tuple, [{_, atom}, _]}} = Fmt}}) ->
|
||||||
{aux:atom_to_binary(Name), {[format_result(El, Fmt) || El <- Els]}};
|
{misc:atom_to_binary(Name), {[format_result(El, Fmt) || El <- Els]}};
|
||||||
|
|
||||||
format_result(Els, {Name, {list, Def}}) ->
|
format_result(Els, {Name, {list, Def}}) ->
|
||||||
{aux:atom_to_binary(Name), [element(2, format_result(El, Def)) || El <- Els]};
|
{misc:atom_to_binary(Name), [element(2, format_result(El, Def)) || El <- Els]};
|
||||||
|
|
||||||
format_result(Tuple, {_Name, {tuple, [{_, atom}, ValFmt]}}) ->
|
format_result(Tuple, {_Name, {tuple, [{_, atom}, ValFmt]}}) ->
|
||||||
{Name2, Val} = Tuple,
|
{Name2, Val} = Tuple,
|
||||||
{_, Val2} = format_result(Val, ValFmt),
|
{_, Val2} = format_result(Val, ValFmt),
|
||||||
{aux:atom_to_binary(Name2), Val2};
|
{misc:atom_to_binary(Name2), Val2};
|
||||||
|
|
||||||
format_result(Tuple, {Name, {tuple, Def}}) ->
|
format_result(Tuple, {Name, {tuple, Def}}) ->
|
||||||
Els = lists:zip(tuple_to_list(Tuple), Def),
|
Els = lists:zip(tuple_to_list(Tuple), Def),
|
||||||
{aux:atom_to_binary(Name), {[format_result(El, ElDef) || {El, ElDef} <- Els]}};
|
{misc:atom_to_binary(Name), {[format_result(El, ElDef) || {El, ElDef} <- Els]}};
|
||||||
|
|
||||||
format_result(404, {_Name, _}) ->
|
format_result(404, {_Name, _}) ->
|
||||||
"not_found".
|
"not_found".
|
||||||
|
@ -537,7 +537,7 @@ json_error(HTTPCode, JSONCode, Message) ->
|
||||||
}.
|
}.
|
||||||
|
|
||||||
log(Call, Args, {Addr, Port}) ->
|
log(Call, Args, {Addr, Port}) ->
|
||||||
AddrS = aux:ip_to_list({Addr, Port}),
|
AddrS = misc:ip_to_list({Addr, Port}),
|
||||||
?INFO_MSG("API call ~s ~p from ~s:~p", [Call, Args, AddrS, Port]);
|
?INFO_MSG("API call ~s ~p from ~s:~p", [Call, Args, AddrS, Port]);
|
||||||
log(Call, Args, IP) ->
|
log(Call, Args, IP) ->
|
||||||
?INFO_MSG("API call ~s ~p (~p)", [Call, Args, IP]).
|
?INFO_MSG("API call ~s ~p (~p)", [Call, Args, IP]).
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
-define(SLOT_TIMEOUT, 18000000). % 5 hours.
|
-define(SLOT_TIMEOUT, 18000000). % 5 hours.
|
||||||
-define(FORMAT(Error), file:format_error(Error)).
|
-define(FORMAT(Error), file:format_error(Error)).
|
||||||
-define(URL_ENC(URL), binary_to_list(ejabberd_http:url_encode(URL))).
|
-define(URL_ENC(URL), binary_to_list(ejabberd_http:url_encode(URL))).
|
||||||
-define(ADDR_TO_STR(IP), ejabberd_config:may_hide_data(aux:ip_to_list(IP))).
|
-define(ADDR_TO_STR(IP), ejabberd_config:may_hide_data(misc:ip_to_list(IP))).
|
||||||
-define(STR_TO_INT(Str, B), binary_to_integer(iolist_to_binary(Str), B)).
|
-define(STR_TO_INT(Str, B), binary_to_integer(iolist_to_binary(Str), B)).
|
||||||
-define(DEFAULT_CONTENT_TYPE, <<"application/octet-stream">>).
|
-define(DEFAULT_CONTENT_TYPE, <<"application/octet-stream">>).
|
||||||
-define(CONTENT_TYPES,
|
-define(CONTENT_TYPES,
|
||||||
|
@ -502,12 +502,12 @@ get_proc_name(ServerHost, ModuleName) ->
|
||||||
|
|
||||||
expand_home(Input) ->
|
expand_home(Input) ->
|
||||||
{ok, [[Home]]} = init:get_argument(home),
|
{ok, [[Home]]} = init:get_argument(home),
|
||||||
aux:expand_keyword(<<"@HOME@">>, Input, Home).
|
misc:expand_keyword(<<"@HOME@">>, Input, Home).
|
||||||
|
|
||||||
-spec expand_host(binary(), binary()) -> binary().
|
-spec expand_host(binary(), binary()) -> binary().
|
||||||
|
|
||||||
expand_host(Input, Host) ->
|
expand_host(Input, Host) ->
|
||||||
aux:expand_keyword(<<"@HOST@">>, Input, Host).
|
misc:expand_keyword(<<"@HOST@">>, Input, Host).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Internal functions.
|
%% Internal functions.
|
||||||
|
|
|
@ -55,7 +55,7 @@ get_data(LServer, Host, From) ->
|
||||||
|
|
||||||
set_data(LServer, Host, From, Data) ->
|
set_data(LServer, Host, From, Data) ->
|
||||||
SJID = jid:encode(jid:tolower(jid:remove_resource(From))),
|
SJID = jid:encode(jid:tolower(jid:remove_resource(From))),
|
||||||
SData = aux:term_to_expr(Data),
|
SData = misc:term_to_expr(Data),
|
||||||
F = fun () ->
|
F = fun () ->
|
||||||
?SQL_UPSERT_T(
|
?SQL_UPSERT_T(
|
||||||
"irc_custom",
|
"irc_custom",
|
||||||
|
@ -73,7 +73,7 @@ export(_Server) ->
|
||||||
case str:suffix(Host, IRCHost) of
|
case str:suffix(Host, IRCHost) of
|
||||||
true ->
|
true ->
|
||||||
SJID = jid:encode(jid:make(U, S)),
|
SJID = jid:encode(jid:make(U, S)),
|
||||||
SData = aux:term_to_expr(Data),
|
SData = misc:term_to_expr(Data),
|
||||||
[?SQL("delete from irc_custom"
|
[?SQL("delete from irc_custom"
|
||||||
" where jid=%(SJID)s and host=%(IRCHost)s;"),
|
" where jid=%(SJID)s and host=%(IRCHost)s;"),
|
||||||
?SQL("insert into irc_custom(jid, host, data)"
|
?SQL("insert into irc_custom(jid, host, data)"
|
||||||
|
|
|
@ -436,7 +436,7 @@ delete_old_messages(TypeBin, Days) when TypeBin == <<"chat">>;
|
||||||
TypeBin == <<"all">> ->
|
TypeBin == <<"all">> ->
|
||||||
Diff = Days * 24 * 60 * 60 * 1000000,
|
Diff = Days * 24 * 60 * 60 * 1000000,
|
||||||
TimeStamp = usec_to_now(p1_time_compat:system_time(micro_seconds) - Diff),
|
TimeStamp = usec_to_now(p1_time_compat:system_time(micro_seconds) - Diff),
|
||||||
Type = aux:binary_to_atom(TypeBin),
|
Type = misc:binary_to_atom(TypeBin),
|
||||||
DBTypes = lists:usort(
|
DBTypes = lists:usort(
|
||||||
lists:map(
|
lists:map(
|
||||||
fun(Host) ->
|
fun(Host) ->
|
||||||
|
|
|
@ -58,7 +58,7 @@ remove_room(LServer, LName, LHost) ->
|
||||||
|
|
||||||
delete_old_messages(ServerHost, TimeStamp, Type) ->
|
delete_old_messages(ServerHost, TimeStamp, Type) ->
|
||||||
TypeClause = if Type == all -> <<"">>;
|
TypeClause = if Type == all -> <<"">>;
|
||||||
true -> [<<" and kind='">>, aux:atom_to_binary(Type), <<"'">>]
|
true -> [<<" and kind='">>, misc:atom_to_binary(Type), <<"'">>]
|
||||||
end,
|
end,
|
||||||
TS = integer_to_binary(now_to_usec(TimeStamp)),
|
TS = integer_to_binary(now_to_usec(TimeStamp)),
|
||||||
ejabberd_sql:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
|
@ -83,7 +83,7 @@ store(Pkt, LServer, {LUser, LHost}, Type, Peer, Nick, _Dir) ->
|
||||||
jid:tolower(Peer)),
|
jid:tolower(Peer)),
|
||||||
XML = fxml:element_to_binary(Pkt),
|
XML = fxml:element_to_binary(Pkt),
|
||||||
Body = fxml:get_subtag_cdata(Pkt, <<"body">>),
|
Body = fxml:get_subtag_cdata(Pkt, <<"body">>),
|
||||||
SType = aux:atom_to_binary(Type),
|
SType = misc:atom_to_binary(Type),
|
||||||
case ejabberd_sql:sql_query(
|
case ejabberd_sql:sql_query(
|
||||||
LServer,
|
LServer,
|
||||||
?SQL("insert into archive (username, timestamp,"
|
?SQL("insert into archive (username, timestamp,"
|
||||||
|
@ -107,8 +107,8 @@ write_prefs(LUser, _LServer, #archive_prefs{default = Default,
|
||||||
always = Always},
|
always = Always},
|
||||||
ServerHost) ->
|
ServerHost) ->
|
||||||
SDefault = erlang:atom_to_binary(Default, utf8),
|
SDefault = erlang:atom_to_binary(Default, utf8),
|
||||||
SAlways = aux:term_to_expr(Always),
|
SAlways = misc:term_to_expr(Always),
|
||||||
SNever = aux:term_to_expr(Never),
|
SNever = misc:term_to_expr(Never),
|
||||||
case ?SQL_UPSERT(
|
case ?SQL_UPSERT(
|
||||||
ServerHost,
|
ServerHost,
|
||||||
"archive_prefs",
|
"archive_prefs",
|
||||||
|
@ -321,7 +321,7 @@ make_archive_el(TS, XML, Peer, Kind, Nick, MsgType, JidRequestor, JidArchive) ->
|
||||||
T = case Kind of
|
T = case Kind of
|
||||||
<<"">> -> chat;
|
<<"">> -> chat;
|
||||||
null -> chat;
|
null -> chat;
|
||||||
_ -> aux:binary_to_atom(Kind)
|
_ -> misc:binary_to_atom(Kind)
|
||||||
end,
|
end,
|
||||||
mod_mam:msg_to_el(
|
mod_mam:msg_to_el(
|
||||||
#archive_msg{timestamp = Now,
|
#archive_msg{timestamp = Now,
|
||||||
|
|
|
@ -133,7 +133,7 @@ send_metrics(Host, Probe, Peer, Port) ->
|
||||||
% grapherl metrics are named first with service domain, then nodename
|
% grapherl metrics are named first with service domain, then nodename
|
||||||
% and name of the data itself, followed by type timestamp and value
|
% and name of the data itself, followed by type timestamp and value
|
||||||
% example => process-one.net/xmpp-1.user_receive_packet:c/1441784958:1
|
% example => process-one.net/xmpp-1.user_receive_packet:c/1441784958:1
|
||||||
[_, NodeId] = str:tokens(aux:atom_to_binary(node()), <<"@">>),
|
[_, NodeId] = str:tokens(misc:atom_to_binary(node()), <<"@">>),
|
||||||
[Node | _] = str:tokens(NodeId, <<".">>),
|
[Node | _] = str:tokens(NodeId, <<".">>),
|
||||||
BaseId = <<Host/binary, "/", Node/binary, ".">>,
|
BaseId = <<Host/binary, "/", Node/binary, ".">>,
|
||||||
DateTime = erlang:universaltime(),
|
DateTime = erlang:universaltime(),
|
||||||
|
@ -144,11 +144,11 @@ send_metrics(Host, Probe, Peer, Port) ->
|
||||||
case Probe of
|
case Probe of
|
||||||
{Key, Val} ->
|
{Key, Val} ->
|
||||||
BVal = integer_to_binary(Val),
|
BVal = integer_to_binary(Val),
|
||||||
Data = <<BaseId/binary, (aux:atom_to_binary(Key))/binary,
|
Data = <<BaseId/binary, (misc:atom_to_binary(Key))/binary,
|
||||||
":g/", TS/binary, ":", BVal/binary>>,
|
":g/", TS/binary, ":", BVal/binary>>,
|
||||||
gen_udp:send(Socket, Peer, Port, Data);
|
gen_udp:send(Socket, Peer, Port, Data);
|
||||||
Key ->
|
Key ->
|
||||||
Data = <<BaseId/binary, (aux:atom_to_binary(Key))/binary,
|
Data = <<BaseId/binary, (misc:atom_to_binary(Key))/binary,
|
||||||
":c/", TS/binary, ":1">>,
|
":c/", TS/binary, ":1">>,
|
||||||
gen_udp:send(Socket, Peer, Port, Data)
|
gen_udp:send(Socket, Peer, Port, Data)
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -450,10 +450,10 @@ prepare_room_info(Room_info) ->
|
||||||
[NameHost,
|
[NameHost,
|
||||||
integer_to_binary(Num_participants),
|
integer_to_binary(Num_participants),
|
||||||
Ts_last_message,
|
Ts_last_message,
|
||||||
aux:atom_to_binary(Public),
|
misc:atom_to_binary(Public),
|
||||||
aux:atom_to_binary(Persistent),
|
misc:atom_to_binary(Persistent),
|
||||||
aux:atom_to_binary(Logging),
|
misc:atom_to_binary(Logging),
|
||||||
aux:atom_to_binary(Just_created),
|
misc:atom_to_binary(Just_created),
|
||||||
Title].
|
Title].
|
||||||
|
|
||||||
|
|
||||||
|
@ -823,7 +823,7 @@ change_room_option(Name, Service, OptionString, ValueString) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
format_room_option(OptionString, ValueString) ->
|
format_room_option(OptionString, ValueString) ->
|
||||||
Option = aux:binary_to_atom(OptionString),
|
Option = misc:binary_to_atom(OptionString),
|
||||||
Value = case Option of
|
Value = case Option of
|
||||||
title -> ValueString;
|
title -> ValueString;
|
||||||
description -> ValueString;
|
description -> ValueString;
|
||||||
|
@ -831,7 +831,7 @@ format_room_option(OptionString, ValueString) ->
|
||||||
subject ->ValueString;
|
subject ->ValueString;
|
||||||
subject_author ->ValueString;
|
subject_author ->ValueString;
|
||||||
max_users -> binary_to_integer(ValueString);
|
max_users -> binary_to_integer(ValueString);
|
||||||
_ -> aux:binary_to_atom(ValueString)
|
_ -> misc:binary_to_atom(ValueString)
|
||||||
end,
|
end,
|
||||||
{Option, Value}.
|
{Option, Value}.
|
||||||
|
|
||||||
|
@ -892,9 +892,9 @@ get_room_options(Pid) ->
|
||||||
get_options(Config).
|
get_options(Config).
|
||||||
|
|
||||||
get_options(Config) ->
|
get_options(Config) ->
|
||||||
Fields = [aux:atom_to_binary(Field) || Field <- record_info(fields, config)],
|
Fields = [misc:atom_to_binary(Field) || Field <- record_info(fields, config)],
|
||||||
[config | ValuesRaw] = tuple_to_list(Config),
|
[config | ValuesRaw] = tuple_to_list(Config),
|
||||||
Values = lists:map(fun(V) when is_atom(V) -> aux:atom_to_binary(V);
|
Values = lists:map(fun(V) when is_atom(V) -> misc:atom_to_binary(V);
|
||||||
(V) when is_integer(V) -> integer_to_binary(V);
|
(V) when is_integer(V) -> integer_to_binary(V);
|
||||||
(V) when is_tuple(V); is_list(V) -> list_to_binary(hd(io_lib:format("~w", [V])));
|
(V) when is_tuple(V); is_list(V) -> list_to_binary(hd(io_lib:format("~w", [V])));
|
||||||
(V) -> V end, ValuesRaw),
|
(V) -> V end, ValuesRaw),
|
||||||
|
@ -936,7 +936,7 @@ get_room_affiliations(Name, Service) ->
|
||||||
%% If the affiliation is 'none', the action is to remove,
|
%% If the affiliation is 'none', the action is to remove,
|
||||||
%% In any other case the action will be to create the affiliation.
|
%% In any other case the action will be to create the affiliation.
|
||||||
set_room_affiliation(Name, Service, JID, AffiliationString) ->
|
set_room_affiliation(Name, Service, JID, AffiliationString) ->
|
||||||
Affiliation = aux:binary_to_atom(AffiliationString),
|
Affiliation = misc:binary_to_atom(AffiliationString),
|
||||||
case mod_muc:find_online_room(Name, Service) of
|
case mod_muc:find_online_room(Name, Service) of
|
||||||
{ok, Pid} ->
|
{ok, Pid} ->
|
||||||
%% Get the PID for the online room so we can get the state of the room
|
%% Get the PID for the online room so we can get the state of the room
|
||||||
|
|
|
@ -537,7 +537,7 @@ make_dir_rec(Dir) ->
|
||||||
%% {ok, F1}=file:open("valid-xhtml10.png", [read]).
|
%% {ok, F1}=file:open("valid-xhtml10.png", [read]).
|
||||||
%% {ok, F1b}=file:read(F1, 1000000).
|
%% {ok, F1b}=file:read(F1, 1000000).
|
||||||
%% c("../../ejabberd/src/jlib.erl").
|
%% c("../../ejabberd/src/jlib.erl").
|
||||||
%% aux:encode_base64(F1b).
|
%% misc:encode_base64(F1b).
|
||||||
|
|
||||||
image_base64(<<"powered-by-erlang.png">>) ->
|
image_base64(<<"powered-by-erlang.png">>) ->
|
||||||
<<"iVBORw0KGgoAAAANSUhEUgAAAGUAAAAfCAYAAAD+xQNoA"
|
<<"iVBORw0KGgoAAAANSUhEUgAAAGUAAAAfCAYAAAD+xQNoA"
|
||||||
|
@ -713,7 +713,7 @@ create_image_files(Images_dir) ->
|
||||||
lists:foreach(fun (Filename) ->
|
lists:foreach(fun (Filename) ->
|
||||||
Filename_full = fjoin([Images_dir, Filename]),
|
Filename_full = fjoin([Images_dir, Filename]),
|
||||||
{ok, F} = file:open(Filename_full, [write]),
|
{ok, F} = file:open(Filename_full, [write]),
|
||||||
Image = aux:decode_base64(image_base64(Filename)),
|
Image = misc:decode_base64(image_base64(Filename)),
|
||||||
io:format(F, <<"~s">>, [Image]),
|
io:format(F, <<"~s">>, [Image]),
|
||||||
file:close(F)
|
file:close(F)
|
||||||
end,
|
end,
|
||||||
|
@ -1051,7 +1051,7 @@ roomconfig_to_string(Options, Lang, FileFormat) ->
|
||||||
allow_private_messages_from_visitors ->
|
allow_private_messages_from_visitors ->
|
||||||
<<"<div class=\"rcot\">",
|
<<"<div class=\"rcot\">",
|
||||||
OptText/binary, ": \"",
|
OptText/binary, ": \"",
|
||||||
(htmlize(?T(aux:atom_to_binary(T)),
|
(htmlize(?T(misc:atom_to_binary(T)),
|
||||||
FileFormat))/binary,
|
FileFormat))/binary,
|
||||||
"\"</div>">>;
|
"\"</div>">>;
|
||||||
_ -> <<"\"", T/binary, "\"">>
|
_ -> <<"\"", T/binary, "\"">>
|
||||||
|
|
|
@ -1156,13 +1156,13 @@ handle_iq_vcard(ToJID, NewId, #iq{type = Type, sub_els = SubEls} = IQ) ->
|
||||||
-spec stanzaid_pack(binary(), binary()) -> binary().
|
-spec stanzaid_pack(binary(), binary()) -> binary().
|
||||||
stanzaid_pack(OriginalId, Resource) ->
|
stanzaid_pack(OriginalId, Resource) ->
|
||||||
<<"berd",
|
<<"berd",
|
||||||
(aux:encode_base64(<<"ejab\000",
|
(misc:encode_base64(<<"ejab\000",
|
||||||
OriginalId/binary, "\000",
|
OriginalId/binary, "\000",
|
||||||
Resource/binary>>))/binary>>.
|
Resource/binary>>))/binary>>.
|
||||||
|
|
||||||
-spec stanzaid_unpack(binary()) -> {binary(), binary()}.
|
-spec stanzaid_unpack(binary()) -> {binary(), binary()}.
|
||||||
stanzaid_unpack(<<"berd", StanzaIdBase64/binary>>) ->
|
stanzaid_unpack(<<"berd", StanzaIdBase64/binary>>) ->
|
||||||
StanzaId = aux:decode_base64(StanzaIdBase64),
|
StanzaId = misc:decode_base64(StanzaIdBase64),
|
||||||
[<<"ejab">>, OriginalId, Resource] =
|
[<<"ejab">>, OriginalId, Resource] =
|
||||||
str:tokens(StanzaId, <<"\000">>),
|
str:tokens(StanzaId, <<"\000">>),
|
||||||
{OriginalId, Resource}.
|
{OriginalId, Resource}.
|
||||||
|
|
|
@ -57,7 +57,7 @@ init(Host, Opts) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
store_room(LServer, Host, Name, Opts) ->
|
store_room(LServer, Host, Name, Opts) ->
|
||||||
SOpts = aux:term_to_expr(Opts),
|
SOpts = misc:term_to_expr(Opts),
|
||||||
F = fun () ->
|
F = fun () ->
|
||||||
?SQL_UPSERT_T(
|
?SQL_UPSERT_T(
|
||||||
"muc_room",
|
"muc_room",
|
||||||
|
@ -171,7 +171,7 @@ search_affiliation(_ServerHost, _Room, _Host, _Affiliation) ->
|
||||||
{error, not_implemented}.
|
{error, not_implemented}.
|
||||||
|
|
||||||
register_online_room(ServerHost, Room, Host, Pid) ->
|
register_online_room(ServerHost, Room, Host, Pid) ->
|
||||||
PidS = aux:encode_pid(Pid),
|
PidS = misc:encode_pid(Pid),
|
||||||
NodeS = erlang:atom_to_binary(node(Pid), latin1),
|
NodeS = erlang:atom_to_binary(node(Pid), latin1),
|
||||||
case ?SQL_UPSERT(ServerHost,
|
case ?SQL_UPSERT(ServerHost,
|
||||||
"muc_online_room",
|
"muc_online_room",
|
||||||
|
@ -188,7 +188,7 @@ register_online_room(ServerHost, Room, Host, Pid) ->
|
||||||
|
|
||||||
unregister_online_room(ServerHost, Room, Host, Pid) ->
|
unregister_online_room(ServerHost, Room, Host, Pid) ->
|
||||||
%% TODO: report errors
|
%% TODO: report errors
|
||||||
PidS = aux:encode_pid(Pid),
|
PidS = misc:encode_pid(Pid),
|
||||||
NodeS = erlang:atom_to_binary(node(Pid), latin1),
|
NodeS = erlang:atom_to_binary(node(Pid), latin1),
|
||||||
ejabberd_sql:sql_query(
|
ejabberd_sql:sql_query(
|
||||||
ServerHost,
|
ServerHost,
|
||||||
|
@ -201,7 +201,7 @@ find_online_room(ServerHost, Room, Host) ->
|
||||||
?SQL("select @(pid)s, @(node)s from muc_online_room where "
|
?SQL("select @(pid)s, @(node)s from muc_online_room where "
|
||||||
"name=%(Room)s and host=%(Host)s")) of
|
"name=%(Room)s and host=%(Host)s")) of
|
||||||
{selected, [{PidS, NodeS}]} ->
|
{selected, [{PidS, NodeS}]} ->
|
||||||
try {ok, aux:decode_pid(PidS, NodeS)}
|
try {ok, misc:decode_pid(PidS, NodeS)}
|
||||||
catch _:{bad_node, _} -> error
|
catch _:{bad_node, _} -> error
|
||||||
end;
|
end;
|
||||||
{selected, []} ->
|
{selected, []} ->
|
||||||
|
@ -231,7 +231,7 @@ get_online_rooms(ServerHost, Host, _RSM) ->
|
||||||
{selected, Rows} ->
|
{selected, Rows} ->
|
||||||
lists:flatmap(
|
lists:flatmap(
|
||||||
fun({Room, PidS, NodeS}) ->
|
fun({Room, PidS, NodeS}) ->
|
||||||
try [{Room, Host, aux:decode_pid(PidS, NodeS)}]
|
try [{Room, Host, misc:decode_pid(PidS, NodeS)}]
|
||||||
catch _:{bad_node, _} -> []
|
catch _:{bad_node, _} -> []
|
||||||
end
|
end
|
||||||
end, Rows);
|
end, Rows);
|
||||||
|
@ -296,7 +296,7 @@ export(_Server) ->
|
||||||
fun(Host, #muc_room{name_host = {Name, RoomHost}, opts = Opts}) ->
|
fun(Host, #muc_room{name_host = {Name, RoomHost}, opts = Opts}) ->
|
||||||
case str:suffix(Host, RoomHost) of
|
case str:suffix(Host, RoomHost) of
|
||||||
true ->
|
true ->
|
||||||
SOpts = aux:term_to_expr(Opts),
|
SOpts = misc:term_to_expr(Opts),
|
||||||
[?SQL("delete from muc_room where name=%(Name)s"
|
[?SQL("delete from muc_room where name=%(Name)s"
|
||||||
" and host=%(RoomHost)s;"),
|
" and host=%(RoomHost)s;"),
|
||||||
?SQL("insert into muc_room(name, host, opts) "
|
?SQL("insert into muc_room(name, host, opts) "
|
||||||
|
|
|
@ -113,7 +113,7 @@ update(Server, JID, Dir) ->
|
||||||
?WARNING_MSG("Flooder detected: ~s, on IP: ~s ignoring "
|
?WARNING_MSG("Flooder detected: ~s, on IP: ~s ignoring "
|
||||||
"sent presence subscriptions~n",
|
"sent presence subscriptions~n",
|
||||||
[jid:encode(JID),
|
[jid:encode(JID),
|
||||||
aux:ip_to_list(IP)])
|
misc:ip_to_list(IP)])
|
||||||
end,
|
end,
|
||||||
{stop, deny};
|
{stop, deny};
|
||||||
true ->
|
true ->
|
||||||
|
|
|
@ -253,9 +253,9 @@ process_bytestreams(#iq{type = set, lang = Lang, from = InitiatorJID, to = To,
|
||||||
transform_module_options(Opts) ->
|
transform_module_options(Opts) ->
|
||||||
lists:map(
|
lists:map(
|
||||||
fun({ip, IP}) when is_tuple(IP) ->
|
fun({ip, IP}) when is_tuple(IP) ->
|
||||||
{ip, aux:ip_to_list(IP)};
|
{ip, misc:ip_to_list(IP)};
|
||||||
({hostname, IP}) when is_tuple(IP) ->
|
({hostname, IP}) when is_tuple(IP) ->
|
||||||
{hostname, aux:ip_to_list(IP)};
|
{hostname, misc:ip_to_list(IP)};
|
||||||
(Opt) ->
|
(Opt) ->
|
||||||
Opt
|
Opt
|
||||||
end, Opts).
|
end, Opts).
|
||||||
|
@ -265,7 +265,7 @@ get_streamhost(Host, ServerHost) ->
|
||||||
{Port, IP} = get_port_ip(ServerHost),
|
{Port, IP} = get_port_ip(ServerHost),
|
||||||
HostName = gen_mod:get_module_opt(ServerHost, mod_proxy65, hostname,
|
HostName = gen_mod:get_module_opt(ServerHost, mod_proxy65, hostname,
|
||||||
fun iolist_to_binary/1,
|
fun iolist_to_binary/1,
|
||||||
aux:ip_to_list(IP)),
|
misc:ip_to_list(IP)),
|
||||||
Resource = ejabberd_cluster:node_id(),
|
Resource = ejabberd_cluster:node_id(),
|
||||||
#streamhost{jid = jid:make(<<"">>, Host, Resource),
|
#streamhost{jid = jid:make(<<"">>, Host, Resource),
|
||||||
host = HostName,
|
host = HostName,
|
||||||
|
|
|
@ -50,7 +50,7 @@ init() ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
register_stream(SID, Pid) ->
|
register_stream(SID, Pid) ->
|
||||||
PidS = aux:encode_pid(Pid),
|
PidS = misc:encode_pid(Pid),
|
||||||
NodeS = erlang:atom_to_binary(node(Pid), latin1),
|
NodeS = erlang:atom_to_binary(node(Pid), latin1),
|
||||||
F = fun() ->
|
F = fun() ->
|
||||||
case ejabberd_sql:sql_query_t(
|
case ejabberd_sql:sql_query_t(
|
||||||
|
@ -94,8 +94,8 @@ activate_stream(SID, IJID, MaxConnections, _Node) ->
|
||||||
"sid=%(SID)s")) of
|
"sid=%(SID)s")) of
|
||||||
{selected, [{TPidS, TNodeS, IPidS, INodeS, <<"">>}]}
|
{selected, [{TPidS, TNodeS, IPidS, INodeS, <<"">>}]}
|
||||||
when IPidS /= <<"">> ->
|
when IPidS /= <<"">> ->
|
||||||
try {aux:decode_pid(TPidS, TNodeS),
|
try {misc:decode_pid(TPidS, TNodeS),
|
||||||
aux:decode_pid(IPidS, INodeS)} of
|
misc:decode_pid(IPidS, INodeS)} of
|
||||||
{TPid, IPid} ->
|
{TPid, IPid} ->
|
||||||
case ejabberd_sql:sql_query_t(
|
case ejabberd_sql:sql_query_t(
|
||||||
?SQL("update proxy65 set jid_i=%(IJID)s "
|
?SQL("update proxy65 set jid_i=%(IJID)s "
|
||||||
|
|
|
@ -3439,9 +3439,9 @@ subscription_plugin(Host) ->
|
||||||
-spec submodule(host(), binary()) -> atom().
|
-spec submodule(host(), binary()) -> atom().
|
||||||
submodule(Host, Name) ->
|
submodule(Host, Name) ->
|
||||||
case gen_mod:db_type(serverhost(Host), ?MODULE) of
|
case gen_mod:db_type(serverhost(Host), ?MODULE) of
|
||||||
mnesia -> aux:binary_to_atom(Name);
|
mnesia -> misc:binary_to_atom(Name);
|
||||||
Type -> aux:binary_to_atom(<<Name/binary, "_",
|
Type -> misc:binary_to_atom(<<Name/binary, "_",
|
||||||
(aux:atom_to_binary(Type))/binary>>)
|
(misc:atom_to_binary(Type))/binary>>)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec config(binary(), any()) -> any().
|
-spec config(binary(), any()) -> any().
|
||||||
|
|
|
@ -289,7 +289,7 @@ try_set_password(User, Server, Password, #iq{lang = Lang, meta = M} = IQ) ->
|
||||||
?INFO_MSG("~s has changed password from ~s",
|
?INFO_MSG("~s has changed password from ~s",
|
||||||
[jid:encode({User, Server, <<"">>}),
|
[jid:encode({User, Server, <<"">>}),
|
||||||
ejabberd_config:may_hide_data(
|
ejabberd_config:may_hide_data(
|
||||||
aux:ip_to_list(maps:get(ip, M, {0,0,0,0})))]),
|
misc:ip_to_list(maps:get(ip, M, {0,0,0,0})))]),
|
||||||
xmpp:make_iq_result(IQ);
|
xmpp:make_iq_result(IQ);
|
||||||
{error, empty_password} ->
|
{error, empty_password} ->
|
||||||
Txt = <<"Empty password">>,
|
Txt = <<"Empty password">>,
|
||||||
|
@ -522,7 +522,7 @@ remove_timeout(Source) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
ip_to_string(Source) when is_tuple(Source) ->
|
ip_to_string(Source) when is_tuple(Source) ->
|
||||||
aux:ip_to_list(Source);
|
misc:ip_to_list(Source);
|
||||||
ip_to_string(undefined) -> <<"undefined">>;
|
ip_to_string(undefined) -> <<"undefined">>;
|
||||||
ip_to_string(_) -> <<"unknown">>.
|
ip_to_string(_) -> <<"unknown">>.
|
||||||
|
|
||||||
|
@ -575,7 +575,7 @@ transform_ip_access(Opts) ->
|
||||||
"use access rules instead.", []),
|
"use access rules instead.", []),
|
||||||
ACLs = lists:flatmap(
|
ACLs = lists:flatmap(
|
||||||
fun({Action, S}) ->
|
fun({Action, S}) ->
|
||||||
ACLName = aux:binary_to_atom(
|
ACLName = misc:binary_to_atom(
|
||||||
iolist_to_binary(
|
iolist_to_binary(
|
||||||
["ip_", S])),
|
["ip_", S])),
|
||||||
[{Action, ACLName},
|
[{Action, ACLName},
|
||||||
|
|
|
@ -147,7 +147,7 @@ s2s_out_auth_result(#{db_enabled := true,
|
||||||
%% Sending dialback request, section 2.1.1, step 1
|
%% Sending dialback request, section 2.1.1, step 1
|
||||||
?INFO_MSG("(~s) Retrying with s2s dialback authentication: ~s -> ~s (~s)",
|
?INFO_MSG("(~s) Retrying with s2s dialback authentication: ~s -> ~s (~s)",
|
||||||
[SockMod:pp(Socket), LServer, RServer,
|
[SockMod:pp(Socket), LServer, RServer,
|
||||||
ejabberd_config:may_hide_data(aux:ip_to_list(IP))]),
|
ejabberd_config:may_hide_data(misc:ip_to_list(IP))]),
|
||||||
State1 = maps:remove(stop_reason, State#{on_route => queue}),
|
State1 = maps:remove(stop_reason, State#{on_route => queue}),
|
||||||
{stop, send_db_request(State1)};
|
{stop, send_db_request(State1)};
|
||||||
s2s_out_auth_result(State, _) ->
|
s2s_out_auth_result(State, _) ->
|
||||||
|
@ -168,7 +168,7 @@ s2s_out_downgraded(#{db_enabled := true,
|
||||||
?INFO_MSG("(~s) Trying s2s dialback authentication with "
|
?INFO_MSG("(~s) Trying s2s dialback authentication with "
|
||||||
"non-RFC compliant server: ~s -> ~s (~s)",
|
"non-RFC compliant server: ~s -> ~s (~s)",
|
||||||
[SockMod:pp(Socket), LServer, RServer,
|
[SockMod:pp(Socket), LServer, RServer,
|
||||||
ejabberd_config:may_hide_data(aux:ip_to_list(IP))]),
|
ejabberd_config:may_hide_data(misc:ip_to_list(IP))]),
|
||||||
{stop, send_db_request(State)};
|
{stop, send_db_request(State)};
|
||||||
s2s_out_downgraded(State, _) ->
|
s2s_out_downgraded(State, _) ->
|
||||||
State.
|
State.
|
||||||
|
|
|
@ -462,7 +462,7 @@ get_user_part_re(String, Pattern) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
parse_options(Host, Opts) ->
|
parse_options(Host, Opts) ->
|
||||||
Eldap_ID = aux:atom_to_binary(gen_mod:get_module_proc(Host, ?MODULE)),
|
Eldap_ID = misc:atom_to_binary(gen_mod:get_module_proc(Host, ?MODULE)),
|
||||||
Cfg = eldap_utils:get_config(Host, Opts),
|
Cfg = eldap_utils:get_config(Host, Opts),
|
||||||
GroupAttr = gen_mod:get_opt(ldap_groupattr, Opts,
|
GroupAttr = gen_mod:get_opt(ldap_groupattr, Opts,
|
||||||
fun iolist_to_binary/1,
|
fun iolist_to_binary/1,
|
||||||
|
|
|
@ -67,7 +67,7 @@ groups_with_opts(Host) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
create_group(Host, Group, Opts) ->
|
create_group(Host, Group, Opts) ->
|
||||||
SOpts = aux:term_to_expr(Opts),
|
SOpts = misc:term_to_expr(Opts),
|
||||||
F = fun () ->
|
F = fun () ->
|
||||||
?SQL_UPSERT_T(
|
?SQL_UPSERT_T(
|
||||||
"sr_group",
|
"sr_group",
|
||||||
|
@ -98,7 +98,7 @@ get_group_opts(Host, Group) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
set_group_opts(Host, Group, Opts) ->
|
set_group_opts(Host, Group, Opts) ->
|
||||||
SOpts = aux:term_to_expr(Opts),
|
SOpts = misc:term_to_expr(Opts),
|
||||||
F = fun () ->
|
F = fun () ->
|
||||||
?SQL_UPSERT_T(
|
?SQL_UPSERT_T(
|
||||||
"sr_group",
|
"sr_group",
|
||||||
|
@ -172,7 +172,7 @@ export(_Server) ->
|
||||||
[{sr_group,
|
[{sr_group,
|
||||||
fun(Host, #sr_group{group_host = {Group, LServer}, opts = Opts})
|
fun(Host, #sr_group{group_host = {Group, LServer}, opts = Opts})
|
||||||
when LServer == Host ->
|
when LServer == Host ->
|
||||||
SOpts = aux:term_to_expr(Opts),
|
SOpts = misc:term_to_expr(Opts),
|
||||||
[?SQL("delete from sr_group where name=%(Group)s;"),
|
[?SQL("delete from sr_group where name=%(Group)s;"),
|
||||||
?SQL("insert into sr_group(name, opts) values ("
|
?SQL("insert into sr_group(name, opts) values ("
|
||||||
"%(Group)s, %(SOpts)s);")];
|
"%(Group)s, %(SOpts)s);")];
|
||||||
|
|
|
@ -570,7 +570,7 @@ route_unacked_stanzas(_State) ->
|
||||||
{error, binary(), non_neg_integer()}.
|
{error, binary(), non_neg_integer()}.
|
||||||
inherit_session_state(#{user := U, server := S,
|
inherit_session_state(#{user := U, server := S,
|
||||||
mgmt_queue_type := QueueType} = State, ResumeID) ->
|
mgmt_queue_type := QueueType} = State, ResumeID) ->
|
||||||
case aux:base64_to_term(ResumeID) of
|
case misc:base64_to_term(ResumeID) of
|
||||||
{term, {R, Time}} ->
|
{term, {R, Time}} ->
|
||||||
case ejabberd_sm:get_session_pid(U, S, R) of
|
case ejabberd_sm:get_session_pid(U, S, R) of
|
||||||
none ->
|
none ->
|
||||||
|
@ -627,7 +627,7 @@ resume_session({Time, Pid}, _State) ->
|
||||||
|
|
||||||
-spec make_resume_id(state()) -> binary().
|
-spec make_resume_id(state()) -> binary().
|
||||||
make_resume_id(#{sid := {Time, _}, resource := Resource}) ->
|
make_resume_id(#{sid := {Time, _}, resource := Resource}) ->
|
||||||
aux:term_to_base64({Resource, Time}).
|
misc:term_to_base64({Resource, Time}).
|
||||||
|
|
||||||
-spec add_resent_delay_info(state(), stanza(), erlang:timestamp()) -> stanza();
|
-spec add_resent_delay_info(state(), stanza(), erlang:timestamp()) -> stanza();
|
||||||
(state(), xmlel(), erlang:timestamp()) -> xmlel().
|
(state(), xmlel(), erlang:timestamp()) -> xmlel().
|
||||||
|
|
|
@ -362,7 +362,7 @@ parse_options(Host, Opts) ->
|
||||||
fun(infinity) -> 0;
|
fun(infinity) -> 0;
|
||||||
(I) when is_integer(I), I>0 -> I
|
(I) when is_integer(I), I>0 -> I
|
||||||
end, 30),
|
end, 30),
|
||||||
Eldap_ID = aux:atom_to_binary(gen_mod:get_module_proc(Host, ?PROCNAME)),
|
Eldap_ID = misc:atom_to_binary(gen_mod:get_module_proc(Host, ?PROCNAME)),
|
||||||
Cfg = eldap_utils:get_config(Host, Opts),
|
Cfg = eldap_utils:get_config(Host, Opts),
|
||||||
UIDsTemp = gen_mod:get_opt(
|
UIDsTemp = gen_mod:get_opt(
|
||||||
{ldap_uids, Host}, Opts,
|
{ldap_uids, Host}, Opts,
|
||||||
|
|
|
@ -99,7 +99,7 @@ vcard_set(LUser, LServer, VCARD) ->
|
||||||
<<>> -> remove_xupdate(LUser, LServer);
|
<<>> -> remove_xupdate(LUser, LServer);
|
||||||
BinVal ->
|
BinVal ->
|
||||||
add_xupdate(LUser, LServer,
|
add_xupdate(LUser, LServer,
|
||||||
str:sha(aux:decode_base64(BinVal)))
|
str:sha(misc:decode_base64(BinVal)))
|
||||||
end,
|
end,
|
||||||
ejabberd_sm:force_update_presence(US).
|
ejabberd_sm:force_update_presence(US).
|
||||||
|
|
||||||
|
|
|
@ -652,7 +652,7 @@ get_items(Nidx, From, undefined) ->
|
||||||
?SQL("select @(val)s from pubsub_node_option "
|
?SQL("select @(val)s from pubsub_node_option "
|
||||||
"where nodeid=%(Nidx)d and name='max_items'")) of
|
"where nodeid=%(Nidx)d and name='max_items'")) of
|
||||||
{selected, [{Value}]} ->
|
{selected, [{Value}]} ->
|
||||||
aux:expr_to_term(Value);
|
misc:expr_to_term(Value);
|
||||||
_ ->
|
_ ->
|
||||||
?MAXITEMS
|
?MAXITEMS
|
||||||
end,
|
end,
|
||||||
|
@ -665,7 +665,7 @@ get_items(Nidx, _From, #rsm_set{max = Max, index = IncIndex,
|
||||||
Before /= undefined -> {<<">">>, <<"asc">>};
|
Before /= undefined -> {<<">">>, <<"asc">>};
|
||||||
true -> {<<"is not">>, <<"desc">>}
|
true -> {<<"is not">>, <<"desc">>}
|
||||||
end,
|
end,
|
||||||
SNidx = aux:i2l(Nidx),
|
SNidx = misc:i2l(Nidx),
|
||||||
I = if After /= undefined -> After;
|
I = if After /= undefined -> After;
|
||||||
Before /= undefined -> Before;
|
Before /= undefined -> Before;
|
||||||
true -> undefined
|
true -> undefined
|
||||||
|
@ -774,8 +774,8 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, _SubId, RSM
|
||||||
end.
|
end.
|
||||||
|
|
||||||
get_last_items(Nidx, _From, Count) ->
|
get_last_items(Nidx, _From, Count) ->
|
||||||
Limit = aux:i2l(Count),
|
Limit = misc:i2l(Count),
|
||||||
SNidx = aux:i2l(Nidx),
|
SNidx = misc:i2l(Nidx),
|
||||||
Query = fun(mssql, _) ->
|
Query = fun(mssql, _) ->
|
||||||
ejabberd_sql:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
[<<"select top ">>, Limit,
|
[<<"select top ">>, Limit,
|
||||||
|
@ -851,7 +851,7 @@ set_item(Item) ->
|
||||||
Payload = Item#pubsub_item.payload,
|
Payload = Item#pubsub_item.payload,
|
||||||
XML = str:join([fxml:element_to_binary(X) || X<-Payload], <<>>),
|
XML = str:join([fxml:element_to_binary(X) || X<-Payload], <<>>),
|
||||||
S = fun ({T1, T2, T3}) ->
|
S = fun ({T1, T2, T3}) ->
|
||||||
str:join([aux:i2l(T1, 6), aux:i2l(T2, 6), aux:i2l(T3, 6)], <<":">>)
|
str:join([misc:i2l(T1, 6), misc:i2l(T2, 6), misc:i2l(T3, 6)], <<":">>)
|
||||||
end,
|
end,
|
||||||
SM = S(M),
|
SM = S(M),
|
||||||
SC = S(C),
|
SC = S(C),
|
||||||
|
@ -877,7 +877,7 @@ del_items(Nidx, [ItemId]) ->
|
||||||
del_item(Nidx, ItemId);
|
del_item(Nidx, ItemId);
|
||||||
del_items(Nidx, ItemIds) ->
|
del_items(Nidx, ItemIds) ->
|
||||||
I = str:join([[<<"'">>, ejabberd_sql:escape(X), <<"'">>] || X <- ItemIds], <<",">>),
|
I = str:join([[<<"'">>, ejabberd_sql:escape(X), <<"'">>] || X <- ItemIds], <<",">>),
|
||||||
SNidx = aux:i2l(Nidx),
|
SNidx = misc:i2l(Nidx),
|
||||||
catch
|
catch
|
||||||
ejabberd_sql:sql_query_t([<<"delete from pubsub_item where itemid in (">>,
|
ejabberd_sql:sql_query_t([<<"delete from pubsub_item where itemid in (">>,
|
||||||
I, <<") and nodeid='">>, SNidx, <<"';">>]).
|
I, <<") and nodeid='">>, SNidx, <<"';">>]).
|
||||||
|
@ -1031,7 +1031,7 @@ raw_to_item(Nidx, {ItemId, SJID, Creation, Modification, XML}) ->
|
||||||
JID = decode_jid(SJID),
|
JID = decode_jid(SJID),
|
||||||
ToTime = fun (Str) ->
|
ToTime = fun (Str) ->
|
||||||
[T1, T2, T3] = str:tokens(Str, <<":">>),
|
[T1, T2, T3] = str:tokens(Str, <<":">>),
|
||||||
{aux:l2i(T1), aux:l2i(T2), aux:l2i(T3)}
|
{misc:l2i(T1), misc:l2i(T2), misc:l2i(T3)}
|
||||||
end,
|
end,
|
||||||
Payload = case fxml_stream:parse_element(XML) of
|
Payload = case fxml_stream:parse_element(XML) of
|
||||||
{error, _Reason} -> [];
|
{error, _Reason} -> [];
|
||||||
|
|
|
@ -125,11 +125,11 @@ get_subnodes_tree(Host, Node) ->
|
||||||
{error, _} ->
|
{error, _} ->
|
||||||
[];
|
[];
|
||||||
Rec ->
|
Rec ->
|
||||||
BasePlugin = aux:binary_to_atom(<<"node_",
|
BasePlugin = misc:binary_to_atom(<<"node_",
|
||||||
(Rec#pubsub_node.type)/binary>>),
|
(Rec#pubsub_node.type)/binary>>),
|
||||||
BasePath = BasePlugin:node_to_path(Node),
|
BasePath = BasePlugin:node_to_path(Node),
|
||||||
mnesia:foldl(fun (#pubsub_node{nodeid = {H, N}} = R, Acc) ->
|
mnesia:foldl(fun (#pubsub_node{nodeid = {H, N}} = R, Acc) ->
|
||||||
Plugin = aux:binary_to_atom(<<"node_",
|
Plugin = misc:binary_to_atom(<<"node_",
|
||||||
(R#pubsub_node.type)/binary>>),
|
(R#pubsub_node.type)/binary>>),
|
||||||
Path = Plugin:node_to_path(N),
|
Path = Plugin:node_to_path(N),
|
||||||
case lists:prefix(BasePath, Path) and (H == Host) of
|
case lists:prefix(BasePath, Path) and (H == Host) of
|
||||||
|
|
|
@ -101,7 +101,7 @@ set_node(Record) when is_record(Record, pubsub_node) ->
|
||||||
_ ->
|
_ ->
|
||||||
lists:foreach(fun ({Key, Value}) ->
|
lists:foreach(fun ({Key, Value}) ->
|
||||||
SKey = iolist_to_binary(atom_to_list(Key)),
|
SKey = iolist_to_binary(atom_to_list(Key)),
|
||||||
SValue = aux:term_to_expr(Value),
|
SValue = misc:term_to_expr(Value),
|
||||||
catch
|
catch
|
||||||
ejabberd_sql:sql_query_t(
|
ejabberd_sql:sql_query_t(
|
||||||
?SQL("insert into pubsub_node_option(nodeid, "
|
?SQL("insert into pubsub_node_option(nodeid, "
|
||||||
|
@ -278,13 +278,13 @@ raw_to_node(Host, {Node, Parent, Type, Nidx}) ->
|
||||||
of
|
of
|
||||||
{selected, ROptions} ->
|
{selected, ROptions} ->
|
||||||
DbOpts = lists:map(fun ({Key, Value}) ->
|
DbOpts = lists:map(fun ({Key, Value}) ->
|
||||||
RKey = aux:binary_to_atom(Key),
|
RKey = misc:binary_to_atom(Key),
|
||||||
Tokens = element(2, erl_scan:string(binary_to_list(<<Value/binary, ".">>))),
|
Tokens = element(2, erl_scan:string(binary_to_list(<<Value/binary, ".">>))),
|
||||||
RValue = element(2, erl_parse:parse_term(Tokens)),
|
RValue = element(2, erl_parse:parse_term(Tokens)),
|
||||||
{RKey, RValue}
|
{RKey, RValue}
|
||||||
end,
|
end,
|
||||||
ROptions),
|
ROptions),
|
||||||
Module = aux:binary_to_atom(<<"node_", Type/binary, "_sql">>),
|
Module = misc:binary_to_atom(<<"node_", Type/binary, "_sql">>),
|
||||||
StdOpts = Module:options(),
|
StdOpts = Module:options(),
|
||||||
lists:foldl(fun ({Key, Value}, Acc) ->
|
lists:foldl(fun ({Key, Value}, Acc) ->
|
||||||
lists:keyreplace(Key, 1, Acc, {Key, Value})
|
lists:keyreplace(Key, 1, Acc, {Key, Value})
|
||||||
|
|
|
@ -113,9 +113,9 @@ maybe_get_scram_auth(Data) ->
|
||||||
case proplists:get_value(<<"iteration_count">>, Data, no_ic) of
|
case proplists:get_value(<<"iteration_count">>, Data, no_ic) of
|
||||||
IC when is_float(IC) -> %% A float like 4096.0 is read
|
IC when is_float(IC) -> %% A float like 4096.0 is read
|
||||||
#scram{
|
#scram{
|
||||||
storedkey = aux:hex_to_base64(proplists:get_value(<<"stored_key">>, Data, <<"">>)),
|
storedkey = misc:hex_to_base64(proplists:get_value(<<"stored_key">>, Data, <<"">>)),
|
||||||
serverkey = aux:hex_to_base64(proplists:get_value(<<"server_key">>, Data, <<"">>)),
|
serverkey = misc:hex_to_base64(proplists:get_value(<<"server_key">>, Data, <<"">>)),
|
||||||
salt = aux:hex_to_base64(proplists:get_value(<<"salt">>, Data, <<"">>)),
|
salt = misc:hex_to_base64(proplists:get_value(<<"salt">>, Data, <<"">>)),
|
||||||
iterationcount = round(IC)
|
iterationcount = round(IC)
|
||||||
};
|
};
|
||||||
_ -> <<"">>
|
_ -> <<"">>
|
||||||
|
@ -247,7 +247,7 @@ convert_roster_item(LUser, LServer, JIDstring, LuaList) ->
|
||||||
end, Val),
|
end, Val),
|
||||||
R#roster{groups = Gs};
|
R#roster{groups = Gs};
|
||||||
({<<"subscription">>, Sub}, R) ->
|
({<<"subscription">>, Sub}, R) ->
|
||||||
R#roster{subscription = aux:binary_to_atom(Sub)};
|
R#roster{subscription = misc:binary_to_atom(Sub)};
|
||||||
({<<"ask">>, <<"subscribe">>}, R) ->
|
({<<"ask">>, <<"subscribe">>}, R) ->
|
||||||
R#roster{ask = out};
|
R#roster{ask = out};
|
||||||
({<<"name">>, Name}, R) ->
|
({<<"name">>, Name}, R) ->
|
||||||
|
@ -263,7 +263,7 @@ convert_room_affiliations(Data) ->
|
||||||
fun({J, Aff}) ->
|
fun({J, Aff}) ->
|
||||||
try jid:decode(J) of
|
try jid:decode(J) of
|
||||||
#jid{luser = U, lserver = S} ->
|
#jid{luser = U, lserver = S} ->
|
||||||
[{{U, S, <<>>}, aux:binary_to_atom(Aff)}]
|
[{{U, S, <<>>}, misc:binary_to_atom(Aff)}]
|
||||||
catch _:{bad_jid, _} ->
|
catch _:{bad_jid, _} ->
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
|
@ -301,7 +301,7 @@ convert_room_config(Data) ->
|
||||||
convert_privacy_item({_, Item}) ->
|
convert_privacy_item({_, Item}) ->
|
||||||
Action = proplists:get_value(<<"action">>, Item, <<"allow">>),
|
Action = proplists:get_value(<<"action">>, Item, <<"allow">>),
|
||||||
Order = proplists:get_value(<<"order">>, Item, 0),
|
Order = proplists:get_value(<<"order">>, Item, 0),
|
||||||
T = aux:binary_to_atom(proplists:get_value(<<"type">>, Item, <<"none">>)),
|
T = misc:binary_to_atom(proplists:get_value(<<"type">>, Item, <<"none">>)),
|
||||||
V = proplists:get_value(<<"value">>, Item, <<"">>),
|
V = proplists:get_value(<<"value">>, Item, <<"">>),
|
||||||
MatchIQ = proplists:get_bool(<<"iq">>, Item),
|
MatchIQ = proplists:get_bool(<<"iq">>, Item),
|
||||||
MatchMsg = proplists:get_bool(<<"message">>, Item),
|
MatchMsg = proplists:get_bool(<<"message">>, Item),
|
||||||
|
@ -317,14 +317,14 @@ convert_privacy_item({_, Item}) ->
|
||||||
none -> {T, none};
|
none -> {T, none};
|
||||||
group -> {T, V};
|
group -> {T, V};
|
||||||
jid -> {T, jid:tolower(jid:decode(V))};
|
jid -> {T, jid:tolower(jid:decode(V))};
|
||||||
subscription -> {T, aux:binary_to_atom(V)}
|
subscription -> {T, misc:binary_to_atom(V)}
|
||||||
end
|
end
|
||||||
catch _:_ ->
|
catch _:_ ->
|
||||||
{none, none}
|
{none, none}
|
||||||
end,
|
end,
|
||||||
#listitem{type = Type,
|
#listitem{type = Type,
|
||||||
value = Value,
|
value = Value,
|
||||||
action = aux:binary_to_atom(Action),
|
action = misc:binary_to_atom(Action),
|
||||||
order = erlang:trunc(Order),
|
order = erlang:trunc(Order),
|
||||||
match_all = MatchAll,
|
match_all = MatchAll,
|
||||||
match_iq = MatchIQ,
|
match_iq = MatchIQ,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user