mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-20 17:27:00 +01:00
parent
ff06bdf144
commit
25abf8b634
@ -144,7 +144,7 @@ noreply(#state{expire = Expire} = State) ->
|
|||||||
-spec encode_id(non_neg_integer(), binary()) -> binary().
|
-spec encode_id(non_neg_integer(), binary()) -> binary().
|
||||||
encode_id(Expire, Rnd) ->
|
encode_id(Expire, Rnd) ->
|
||||||
ExpireBin = integer_to_binary(Expire),
|
ExpireBin = integer_to_binary(Expire),
|
||||||
Node = atom_to_binary(node(), utf8),
|
Node = ejabberd_cluster:node_id(),
|
||||||
CheckSum = calc_checksum(<<ExpireBin/binary, Rnd/binary, Node/binary>>),
|
CheckSum = calc_checksum(<<ExpireBin/binary, Rnd/binary, Node/binary>>),
|
||||||
<<"rr-", ExpireBin/binary, $-, Rnd/binary, $-, CheckSum/binary, $-, Node/binary>>.
|
<<"rr-", ExpireBin/binary, $-, Rnd/binary, $-, CheckSum/binary, $-, Node/binary>>.
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ decode_id(<<"rr-", ID/binary>>) ->
|
|||||||
[Rnd, Rest] = binary:split(Tail, <<"-">>),
|
[Rnd, Rest] = binary:split(Tail, <<"-">>),
|
||||||
[CheckSum, NodeBin] = binary:split(Rest, <<"-">>),
|
[CheckSum, NodeBin] = binary:split(Rest, <<"-">>),
|
||||||
CheckSum = calc_checksum(<<ExpireBin/binary, Rnd/binary, NodeBin/binary>>),
|
CheckSum = calc_checksum(<<ExpireBin/binary, Rnd/binary, NodeBin/binary>>),
|
||||||
Node = erlang:binary_to_existing_atom(NodeBin, utf8),
|
Node = ejabberd_cluster:get_node_by_id(NodeBin),
|
||||||
Expire = binary_to_integer(ExpireBin),
|
Expire = binary_to_integer(ExpireBin),
|
||||||
{ok, Expire, Rnd, Node}
|
{ok, Expire, Rnd, Node}
|
||||||
catch _:{badmatch, _} ->
|
catch _:{badmatch, _} ->
|
||||||
|
Loading…
Reference in New Issue
Block a user