Commit c4cd3818 authored by Philipp Huebner's avatar Philipp Huebner

Imported Upstream version 0.2015.07.21

parent 08f039ca
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
%%% Created : 8 Aug 2009 by Evgeniy Khramtsov <ekhramtsov@process-one.net> %%% Created : 8 Aug 2009 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% %%%
%%% %%%
%%% ejabberd, Copyright (C) 2002-2014 ProcessOne %%% stun, Copyright (C) 2002-2015 ProcessOne
%%% %%%
%%% This program is free software; you can redistribute it and/or %%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as %%% modify it under the terms of the GNU General Public License as
......
{erl_opts, [debug_info, {i, "include"}]}. {erl_opts, [debug_info, {i, "include"}]}.
{deps, [{p1_tls, ".*", {git, "git://github.com/processone/tls"}}, {deps, [{p1_tls, ".*", {git, "https://github.com/processone/tls"}},
{p1_utils, ".*", {git, "git://github.com/processone/p1_utils"}}]}. {p1_utils, ".*", {git, "https://github.com/processone/p1_utils"}}]}.
%% Local Variables: %% Local Variables:
%% mode: erlang %% mode: erlang
......
...@@ -2,11 +2,10 @@ ...@@ -2,11 +2,10 @@
%%% File : stun.erl %%% File : stun.erl
%%% Author : Evgeniy Khramtsov <ekhramtsov@process-one.net> %%% Author : Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% Description : RFC5389/RFC5766 implementation. %%% Description : RFC5389/RFC5766 implementation.
%%%
%%% Created : 8 Aug 2009 by Evgeniy Khramtsov <ekhramtsov@process-one.net> %%% Created : 8 Aug 2009 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% %%%
%%% %%%
%%% stun, Copyright (C) 2002-2014 ProcessOne %%% stun, Copyright (C) 2002-2015 ProcessOne
%%% %%%
%%% This program is free software; you can redistribute it and/or %%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as %%% modify it under the terms of the GNU General Public License as
...@@ -24,6 +23,7 @@ ...@@ -24,6 +23,7 @@
%%% 02111-1307 USA %%% 02111-1307 USA
%%% %%%
%%%------------------------------------------------------------------- %%%-------------------------------------------------------------------
-module(stun). -module(stun).
-define(GEN_FSM, gen_fsm). -define(GEN_FSM, gen_fsm).
......
%%%------------------------------------------------------------------- %%%----------------------------------------------------------------------
%%% @author Evgeniy Khramtsov <ekhramtsov@process-one.net> %%% File : stun_app.erl
%%% @copyright (C) 2013, Evgeniy Khramtsov %%% Author : Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% @doc %%% Purpose : stun application
%%% Created : 2 May 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% %%%
%%% @end %%%
%%% Created : 2 May 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net> %%% stun, Copyright (C) 2002-2015 ProcessOne
%%%------------------------------------------------------------------- %%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as
%%% published by the Free Software Foundation; either version 2 of the
%%% License, or (at your option) any later version.
%%%
%%% This program is distributed in the hope that it will be useful,
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
%%% General Public License for more details.
%%%
%%% You should have received a copy of the GNU General Public License
%%% along with this program; if not, write to the Free Software
%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
%%% 02111-1307 USA
%%%
%%%----------------------------------------------------------------------
-module(stun_app). -module(stun_app).
-behaviour(application). -behaviour(application).
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
%%% Created : 7 Aug 2009 by Evgeniy Khramtsov <ekhramtsov@process-one.net> %%% Created : 7 Aug 2009 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% %%%
%%% %%%
%%% stun, Copyright (C) 2002-2014 ProcessOne %%% stun, Copyright (C) 2002-2015 ProcessOne
%%% %%%
%%% This program is free software; you can redistribute it and/or %%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as %%% modify it under the terms of the GNU General Public License as
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
%%% 02111-1307 USA %%% 02111-1307 USA
%%% %%%
%%%------------------------------------------------------------------- %%%-------------------------------------------------------------------
-module(stun_codec). -module(stun_codec).
%% API %% API
...@@ -100,13 +101,13 @@ encode(#stun{class = Class, ...@@ -100,13 +101,13 @@ encode(#stun{class = Class,
if Key /= undefined -> if Key /= undefined ->
NewKey = case Key of NewKey = case Key of
{User, Realm, Password} -> {User, Realm, Password} ->
crypto:md5([User, $:, Realm, $:, Password]); crypto:hash(md5, [User, $:, Realm, $:, Password]);
_ -> _ ->
Key Key
end, end,
Data = <<0:2, Type:14, (Len+24):16, Magic:32, Data = <<0:2, Type:14, (Len+24):16, Magic:32,
TrID:96, Attrs/binary>>, TrID:96, Attrs/binary>>,
MessageIntegrity = crypto:sha_mac(NewKey, Data), MessageIntegrity = crypto:hmac(sha, NewKey, Data),
<<Data/binary, ?STUN_ATTR_MESSAGE_INTEGRITY:16, <<Data/binary, ?STUN_ATTR_MESSAGE_INTEGRITY:16,
20:16, MessageIntegrity/binary>>; 20:16, MessageIntegrity/binary>>;
true -> true ->
...@@ -123,11 +124,11 @@ check_integrity(#stun{raw = Raw, 'MESSAGE-INTEGRITY' = MI}, Key) ...@@ -123,11 +124,11 @@ check_integrity(#stun{raw = Raw, 'MESSAGE-INTEGRITY' = MI}, Key)
when is_binary(Raw), is_binary(MI), Key /= undefined -> when is_binary(Raw), is_binary(MI), Key /= undefined ->
NewKey = case Key of NewKey = case Key of
{User, Realm, Password} -> {User, Realm, Password} ->
crypto:md5([User, $:, Realm, $:, Password]); crypto:hash(md5, [User, $:, Realm, $:, Password]);
_ -> _ ->
Key Key
end, end,
crypto:sha_mac(NewKey, Raw) == MI; crypto:hmac(sha, NewKey, Raw) == MI;
check_integrity(_Msg, _Key) -> check_integrity(_Msg, _Key) ->
false. false.
......
%%%------------------------------------------------------------------- %%%----------------------------------------------------------------------
%%% @author Evgeniy Khramtsov <ekhramtsov@process-one.net> %%% File : stun_listener.erl
%%% @copyright (C) 2011, Evgeniy Khramtsov %%% Author : Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% @doc %%% Purpose :
%%% Created : 9 Jan 2011 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% %%%
%%% @end %%%
%%% Created : 9 Jan 2011 by Evgeniy Khramtsov <ekhramtsov@process-one.net> %%% stun, Copyright (C) 2002-2015 ProcessOne
%%%------------------------------------------------------------------- %%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as
%%% published by the Free Software Foundation; either version 2 of the
%%% License, or (at your option) any later version.
%%%
%%% This program is distributed in the hope that it will be useful,
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
%%% General Public License for more details.
%%%
%%% You should have received a copy of the GNU General Public License
%%% along with this program; if not, write to the Free Software
%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
%%% 02111-1307 USA
%%%
%%%----------------------------------------------------------------------
-module(stun_listener). -module(stun_listener).
-behaviour(gen_server). -behaviour(gen_server).
...@@ -18,7 +36,7 @@ ...@@ -18,7 +36,7 @@
terminate/2, code_change/3]). terminate/2, code_change/3]).
-define(TCP_SEND_TIMEOUT, 10000). -define(TCP_SEND_TIMEOUT, 10000).
-record(state, {listeners = dict:new() :: dict()}). -record(state, {listeners = dict:new()}).
%%%=================================================================== %%%===================================================================
%%% API %%% API
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
%%% Created : 9 Feb 2003 by Alexey Shchepin <alexey@process-one.net> %%% Created : 9 Feb 2003 by Alexey Shchepin <alexey@process-one.net>
%%% %%%
%%% %%%
%%% stun, Copyright (C) 2002-2014 ProcessOne %%% stun, Copyright (C) 2002-2015 ProcessOne
%%% %%%
%%% This program is free software; you can redistribute it and/or %%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as %%% modify it under the terms of the GNU General Public License as
......
%%%------------------------------------------------------------------- %%%----------------------------------------------------------------------
%%% @author Evgeniy Khramtsov <ekhramtsov@process-one.net> %%% File : stun_sup.erl
%%% @copyright (C) 2013, Evgeniy Khramtsov %%% Author : Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% @doc %%% Purpose : stun supervisor
%%% Created : 2 May 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% %%%
%%% @end %%%
%%% Created : 2 May 2013 by Evgeniy Khramtsov <ekhramtsov@process-one.net> %%% stun, Copyright (C) 2002-2015 ProcessOne
%%%------------------------------------------------------------------- %%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as
%%% published by the Free Software Foundation; either version 2 of the
%%% License, or (at your option) any later version.
%%%
%%% This program is distributed in the hope that it will be useful,
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
%%% General Public License for more details.
%%%
%%% You should have received a copy of the GNU General Public License
%%% along with this program; if not, write to the Free Software
%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
%%% 02111-1307 USA
%%%
%%%----------------------------------------------------------------------
-module(stun_sup). -module(stun_sup).
-behaviour(supervisor). -behaviour(supervisor).
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
%%% Created : 7 Aug 2009 by Evgeniy Khramtsov <ekhramtsov@process-one.net> %%% Created : 7 Aug 2009 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% %%%
%%% %%%
%%% ejabberd, Copyright (C) 2002-2010 ProcessOne %%% stun, Copyright (C) 2002-2015 ProcessOne
%%% %%%
%%% This program is free software; you can redistribute it and/or %%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as %%% modify it under the terms of the GNU General Public License as
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
%%% 02111-1307 USA %%% 02111-1307 USA
%%% %%%
%%%------------------------------------------------------------------- %%%-------------------------------------------------------------------
-module(stun_test). -module(stun_test).
-export([bind_udp/2, bind_tcp/2, allocate_udp/5]). -export([bind_udp/2, bind_tcp/2, allocate_udp/5]).
......
%%%------------------------------------------------------------------- %%%----------------------------------------------------------------------
%%% @author Evgeniy Khramtsov <ekhramtsov@process-one.net> %%% File : stun_tmp_sup.erl
%%% @copyright (C) 2013, Evgeniy Khramtsov %%% Author : Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% @doc %%% Purpose :
%%% Created : 3 May 2014 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% %%%
%%% @end %%%
%%% Created : 3 May 2014 by Evgeniy Khramtsov <ekhramtsov@process-one.net> %%% stun, Copyright (C) 2002-2015 ProcessOne
%%%------------------------------------------------------------------- %%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as
%%% published by the Free Software Foundation; either version 2 of the
%%% License, or (at your option) any later version.
%%%
%%% This program is distributed in the hope that it will be useful,
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
%%% General Public License for more details.
%%%
%%% You should have received a copy of the GNU General Public License
%%% along with this program; if not, write to the Free Software
%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
%%% 02111-1307 USA
%%%
%%%----------------------------------------------------------------------
-module(stun_tmp_sup). -module(stun_tmp_sup).
-behaviour(supervisor). -behaviour(supervisor).
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
%%% Created : 23 Aug 2009 by Evgeniy Khramtsov <ekhramtsov@process-one.net> %%% Created : 23 Aug 2009 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% %%%
%%% %%%
%%% stun, Copyright (C) 2002-2014 ProcessOne %%% stun, Copyright (C) 2002-2015 ProcessOne
%%% %%%
%%% This program is free software; you can redistribute it and/or %%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as %%% modify it under the terms of the GNU General Public License as
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
%%% 02111-1307 USA %%% 02111-1307 USA
%%% %%%
%%%------------------------------------------------------------------- %%%-------------------------------------------------------------------
-module(turn). -module(turn).
-define(GEN_FSM, gen_fsm). -define(GEN_FSM, gen_fsm).
...@@ -64,8 +65,8 @@ ...@@ -64,8 +65,8 @@
realm = <<"">> :: binary(), realm = <<"">> :: binary(),
key = {<<"">>, <<"">>, <<"">>} :: {binary(), binary(), binary()}, key = {<<"">>, <<"">>, <<"">>} :: {binary(), binary(), binary()},
server_name = <<"">> :: binary(), server_name = <<"">> :: binary(),
permissions = ?DICT:new() :: dict(), permissions = ?DICT:new(),
channels = ?DICT:new() :: dict(), channels = ?DICT:new(),
max_permissions :: non_neg_integer() | atom(), max_permissions :: non_neg_integer() | atom(),
relay_ip = {127,0,0,1} :: inet:ip_address(), relay_ip = {127,0,0,1} :: inet:ip_address(),
min_port = 49152 :: non_neg_integer(), min_port = 49152 :: non_neg_integer(),
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
%%% Created : 23 Aug 2009 by Evgeniy Khramtsov <ekhramtsov@process-one.net> %%% Created : 23 Aug 2009 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% %%%
%%% %%%
%%% stun, Copyright (C) 2002-2014 ProcessOne %%% stun, Copyright (C) 2002-2015 ProcessOne
%%% %%%
%%% This program is free software; you can redistribute it and/or %%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as %%% modify it under the terms of the GNU General Public License as
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
%%% 02111-1307 USA %%% 02111-1307 USA
%%% %%%
%%%------------------------------------------------------------------- %%%-------------------------------------------------------------------
-module(turn_sm). -module(turn_sm).
-behaviour(gen_server). -behaviour(gen_server).
......
%%%------------------------------------------------------------------- %%%----------------------------------------------------------------------
%%% @author Evgeniy Khramtsov <ekhramtsov@process-one.net> %%% File : turn_tmp_sup.erl
%%% @copyright (C) 2013, Evgeniy Khramtsov %%% Author : Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% @doc %%% Purpose :
%%% Created : 3 May 2014 by Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% %%%
%%% @end %%%
%%% Created : 3 May 2014 by Evgeniy Khramtsov <ekhramtsov@process-one.net> %%% stun, Copyright (C) 2002-2015 ProcessOne
%%%------------------------------------------------------------------- %%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as
%%% published by the Free Software Foundation; either version 2 of the
%%% License, or (at your option) any later version.
%%%
%%% This program is distributed in the hope that it will be useful,
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
%%% General Public License for more details.
%%%
%%% You should have received a copy of the GNU General Public License
%%% along with this program; if not, write to the Free Software
%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
%%% 02111-1307 USA
%%%
%%%----------------------------------------------------------------------
-module(turn_tmp_sup). -module(turn_tmp_sup).
-behaviour(supervisor). -behaviour(supervisor).
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment