aboutsummaryrefslogtreecommitdiff
path: root/src/misc.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/misc.erl')
-rw-r--r--src/misc.erl23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/misc.erl b/src/misc.erl
index 3b65aa557..c91809015 100644
--- a/src/misc.erl
+++ b/src/misc.erl
@@ -41,6 +41,7 @@
intersection/2, format_val/1, cancel_timer/1, unique_timestamp/0,
is_mucsub_message/1, best_match/2, pmap/2, peach/2, format_exception/4,
get_my_ipv4_address/0, get_my_ipv6_address/0, parse_ip_mask/1,
+ crypto_hmac/3, crypto_hmac/4, uri_parse/1,
match_ip_mask/3, format_hosts_list/1, format_cycle/1, delete_dir/1]).
%% Deprecated functions
@@ -54,6 +55,26 @@
-type distance_cache() :: #{{string(), string()} => non_neg_integer()}.
+-ifdef(USE_OLD_HTTP_URI).
+uri_parse(URL) when is_binary(URL) ->
+ uri_parse(binary_to_list(URL));
+uri_parse(URL) ->
+ {ok, {Scheme, _UserInfo, Host, Port, Path, _Query}} = http_uri:parse(URL),
+ {ok, Scheme, Host, Port, Path}.
+-else.
+uri_parse(URL) ->
+ #{scheme:=Scheme,host:=Host,port:=Port,path:=Path} = uri_string:parse(URL),
+ {ok, Scheme, Host, Port, Path}.
+-endif.
+
+-ifdef(USE_OLD_CRYPTO_HMAC).
+crypto_hmac(Type, Key, Data) -> crypto:hmac(Type, Key, Data).
+crypto_hmac(Type, Key, Data, MacL) -> crypto:hmac(Type, Key, Data, MacL).
+-else.
+crypto_hmac(Type, Key, Data) -> crypto:mac(hmac, Type, Key, Data).
+crypto_hmac(Type, Key, Data, MacL) -> crypto:macN(hmac, Type, Key, Data, MacL).
+-endif.
+
%%%===================================================================
%%% API
%%%===================================================================
@@ -328,7 +349,7 @@ try_url(URL0) ->
V when is_binary(V) -> binary_to_list(V);
_ -> URL0
end,
- case http_uri:parse(URL) of
+ case uri_parse(URL) of
{ok, {Scheme, _, _, _, _, _}} when Scheme /= http, Scheme /= https ->
?ERROR_MSG("Unsupported URI scheme: ~ts", [URL]),
erlang:error(badarg);