Commit c4cd3818 authored by Philipp Huebner's avatar Philipp Huebner

Imported Upstream version 0.2015.07.21

parent 08f039ca
......@@ -5,7 +5,7 @@
%%% 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
%%% modify it under the terms of the GNU General Public License as
......
{erl_opts, [debug_info, {i, "include"}]}.
{deps, [{p1_tls, ".*", {git, "git://github.com/processone/tls"}},
{p1_utils, ".*", {git, "git://github.com/processone/p1_utils"}}]}.
{deps, [{p1_tls, ".*", {git, "https://github.com/processone/tls"}},
{p1_utils, ".*", {git, "https://github.com/processone/p1_utils"}}]}.
%% Local Variables:
%% mode: erlang
......
......@@ -2,11 +2,10 @@
%%% File : stun.erl
%%% Author : Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% Description : RFC5389/RFC5766 implementation.
%%%
%%% 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
%%% modify it under the terms of the GNU General Public License as
......@@ -24,6 +23,7 @@
%%% 02111-1307 USA
%%%
%%%-------------------------------------------------------------------
-module(stun).
-define(GEN_FSM, gen_fsm).
......
%%%-------------------------------------------------------------------
%%% @author Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% @copyright (C) 2013, Evgeniy Khramtsov
%%% @doc
%%%
%%% @end
%%%----------------------------------------------------------------------
%%% File : stun_app.erl
%%% Author : Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% Purpose : stun application
%%% 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).
-behaviour(application).
......
......@@ -5,7 +5,7 @@
%%% 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
%%% modify it under the terms of the GNU General Public License as
......@@ -23,6 +23,7 @@
%%% 02111-1307 USA
%%%
%%%-------------------------------------------------------------------
-module(stun_codec).
%% API
......@@ -100,13 +101,13 @@ encode(#stun{class = Class,
if Key /= undefined ->
NewKey = case Key of
{User, Realm, Password} ->
crypto:md5([User, $:, Realm, $:, Password]);
crypto:hash(md5, [User, $:, Realm, $:, Password]);
_ ->
Key
end,
Data = <<0:2, Type:14, (Len+24):16, Magic:32,
TrID:96, Attrs/binary>>,
MessageIntegrity = crypto:sha_mac(NewKey, Data),
MessageIntegrity = crypto:hmac(sha, NewKey, Data),
<<Data/binary, ?STUN_ATTR_MESSAGE_INTEGRITY:16,
20:16, MessageIntegrity/binary>>;
true ->
......@@ -123,11 +124,11 @@ check_integrity(#stun{raw = Raw, 'MESSAGE-INTEGRITY' = MI}, Key)
when is_binary(Raw), is_binary(MI), Key /= undefined ->
NewKey = case Key of
{User, Realm, Password} ->
crypto:md5([User, $:, Realm, $:, Password]);
crypto:hash(md5, [User, $:, Realm, $:, Password]);
_ ->
Key
end,
crypto:sha_mac(NewKey, Raw) == MI;
crypto:hmac(sha, NewKey, Raw) == MI;
check_integrity(_Msg, _Key) ->
false.
......
%%%-------------------------------------------------------------------
%%% @author Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% @copyright (C) 2011, Evgeniy Khramtsov
%%% @doc
%%%
%%% @end
%%%----------------------------------------------------------------------
%%% File : stun_listener.erl
%%% Author : Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% Purpose :
%%% 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).
-behaviour(gen_server).
......@@ -18,7 +36,7 @@
terminate/2, code_change/3]).
-define(TCP_SEND_TIMEOUT, 10000).
-record(state, {listeners = dict:new() :: dict()}).
-record(state, {listeners = dict:new()}).
%%%===================================================================
%%% API
......
......@@ -5,7 +5,7 @@
%%% 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
%%% modify it under the terms of the GNU General Public License as
......
%%%-------------------------------------------------------------------
%%% @author Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% @copyright (C) 2013, Evgeniy Khramtsov
%%% @doc
%%%
%%% @end
%%%----------------------------------------------------------------------
%%% File : stun_sup.erl
%%% Author : Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% Purpose : stun supervisor
%%% 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).
-behaviour(supervisor).
......
......@@ -5,7 +5,7 @@
%%% 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
%%% modify it under the terms of the GNU General Public License as
......@@ -23,6 +23,7 @@
%%% 02111-1307 USA
%%%
%%%-------------------------------------------------------------------
-module(stun_test).
-export([bind_udp/2, bind_tcp/2, allocate_udp/5]).
......
%%%-------------------------------------------------------------------
%%% @author Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% @copyright (C) 2013, Evgeniy Khramtsov
%%% @doc
%%%
%%% @end
%%%----------------------------------------------------------------------
%%% File : stun_tmp_sup.erl
%%% Author : Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% Purpose :
%%% 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).
-behaviour(supervisor).
......
......@@ -5,7 +5,7 @@
%%% 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
%%% modify it under the terms of the GNU General Public License as
......@@ -23,6 +23,7 @@
%%% 02111-1307 USA
%%%
%%%-------------------------------------------------------------------
-module(turn).
-define(GEN_FSM, gen_fsm).
......@@ -64,8 +65,8 @@
realm = <<"">> :: binary(),
key = {<<"">>, <<"">>, <<"">>} :: {binary(), binary(), binary()},
server_name = <<"">> :: binary(),
permissions = ?DICT:new() :: dict(),
channels = ?DICT:new() :: dict(),
permissions = ?DICT:new(),
channels = ?DICT:new(),
max_permissions :: non_neg_integer() | atom(),
relay_ip = {127,0,0,1} :: inet:ip_address(),
min_port = 49152 :: non_neg_integer(),
......
......@@ -5,7 +5,7 @@
%%% 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
%%% modify it under the terms of the GNU General Public License as
......@@ -23,6 +23,7 @@
%%% 02111-1307 USA
%%%
%%%-------------------------------------------------------------------
-module(turn_sm).
-behaviour(gen_server).
......
%%%-------------------------------------------------------------------
%%% @author Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% @copyright (C) 2013, Evgeniy Khramtsov
%%% @doc
%%%
%%% @end
%%%----------------------------------------------------------------------
%%% File : turn_tmp_sup.erl
%%% Author : Evgeniy Khramtsov <ekhramtsov@process-one.net>
%%% Purpose :
%%% 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).
-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