Commit 7b051605 authored by Philipp Huebner's avatar Philipp Huebner

Merge branch 'master' into stretch-backports

parents ca5b507a a079a0d4
# Version 1.0.22
* Updating fast_tls to version a166f0e.
# Version 1.0.21
* Updating fast_tls to version 1.0.21.
* Updating p1_utils to version 1.0.11.
* Fix compilation with rebar3
* Fix warning about deprecated random
* Fix typo in README
# Version 1.0.20
* Updating fast_tls to version 1.0.20.
......
......@@ -20,7 +20,7 @@ They are part of a more general negotiation technique know as
To summarize:
* A STUN server is used to get an external network address. It does
not serve as a relay for the mediat raffic.
not serve as a relay for the media traffic.
* TURN servers are used to relay traffic if direct (peer to peer)
connection fails.
......
erlang-p1-stun (1.0.20-1~bpo9+1) stretch-backports; urgency=medium
erlang-p1-stun (1.0.22-1) unstable; urgency=medium
* Rebuild for stretch-backports.
* New upstream version 1.0.22
* Updated Standards-Version: 4.1.4 (no changes needed)
-- Philipp Huebner <debalance@debian.org> Thu, 18 Jan 2018 14:28:35 +0100
-- Philipp Huebner <debalance@debian.org> Wed, 09 May 2018 17:20:22 +0200
erlang-p1-stun (1.0.21-1) unstable; urgency=medium
* use secure copyright format uri in debian/copyright
* New upstream version 1.0.21
* Switched to debhelper 11
-- Philipp Huebner <debalance@debian.org> Tue, 27 Mar 2018 23:30:10 +0200
erlang-p1-stun (1.0.20-1) unstable; urgency=medium
......
Source: erlang-p1-stun
Priority: optional
Maintainer: Ejabberd Packaging Team <ejabberd@packages.debian.org>
Uploaders: Philipp Huebner <debalance@debian.org>
Build-Depends: debhelper (>= 9), dh-rebar, erlang-base (>= 1:19.2), erlang-eunit, erlang-p1-tls (>= 1.0.20),
erlang-p1-utils (>= 1.0.10), erlang-syntax-tools
Standards-Version: 4.1.3
Section: libs
Homepage: https://github.com/processone/stun
Vcs-Git: https://salsa.debian.org/ejabberd-packaging-team/erlang-p1-stun.git
Priority: optional
Build-Depends: debhelper (>= 11~),
dh-rebar,
erlang-base (>= 1:19.2),
erlang-eunit,
erlang-p1-tls (>= 1.0.22),
erlang-p1-utils (>= 1.0.11),
erlang-syntax-tools
Standards-Version: 4.1.4
Vcs-Browser: https://salsa.debian.org/ejabberd-packaging-team/erlang-p1-stun
Vcs-Git: https://salsa.debian.org/ejabberd-packaging-team/erlang-p1-stun.git
Homepage: https://github.com/processone/stun
Package: erlang-p1-stun
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, erlang-base (>= 1:19.2) | ${erlang-abi:Depends},
${erlang:Depends}, erlang-p1-tls (>= 1.0.20), erlang-p1-utils (>= 1.0.10)
Depends: ${shlibs:Depends},
${misc:Depends},
erlang-base (>= 1:19.2) | ${erlang-abi:Depends},
${erlang:Depends},
erlang-p1-tls (>= 1.0.22),
erlang-p1-utils (>= 1.0.11)
Suggests: stun-server | turn-server
Description: STUN library for Erlang
This library was written for ejabberd which still uses it.
......
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: stun
Source: https://github.com/processone/stun
......
......@@ -11,8 +11,8 @@ Index: erlang-p1-stun/rebar.config
{erl_opts, [debug_info, {i, "include"}]}.
-{deps, [{fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "1.0.20"}}},
- {p1_utils, ".*", {git, "https://github.com/processone/p1_utils", {tag, "1.0.10"}}}]}.
-{deps, [{fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "a166f0e"}}},
- {p1_utils, ".*", {git, "https://github.com/processone/p1_utils", {tag, "1.0.11"}}}]}.
{cover_enabled, true}.
{cover_export_enabled, true}.
erlang-p1-stun source: debian-watch-does-not-check-gpg-signature
erlang-p1-stun source: testsuite-autopkgtest-missing
......@@ -22,8 +22,8 @@
{erl_opts, [debug_info, {i, "include"}]}.
{deps, [{fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "1.0.20"}}},
{p1_utils, ".*", {git, "https://github.com/processone/p1_utils", {tag, "1.0.10"}}}]}.
{deps, [{fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "a166f0e"}}},
{p1_utils, ".*", {git, "https://github.com/processone/p1_utils", {tag, "1.0.11"}}}]}.
{cover_enabled, true}.
{cover_export_enabled, true}.
......
......@@ -23,7 +23,7 @@
IsRebar3 = case application:get_key(rebar, vsn) of
{ok, VSN} ->
[VSN1 | _] = string:tokens(VSN, "-"),
[Maj, Min, Patch] = string:tokens(VSN1, "."),
[Maj|_] = string:tokens(VSN1, "."),
(list_to_integer(Maj) >= 3);
undefined ->
lists:keymember(mix, 1, application:loaded_applications())
......@@ -93,11 +93,16 @@ GlobalDepsFilter = fun(Deps) ->
end, DepNames)
end,
code:ensure_loaded(rand),
RandUniform = erlang:function_exported(rand, uniform, 1),
Rules = [
{[deps], IsRebar3,
Rebar3DepsFilter, []},
{[plugins], IsRebar3,
AppendList([rebar3_hex, pc]), []},
{[erl_opts], RandUniform,
AppendList([{d, 'RAND_UNIFORM'}]), []},
{[provider_hooks], IsRebar3,
AppendList([{pre, [
{compile, {pc, compile}},
......
......@@ -23,7 +23,7 @@
{application, stun,
[{description, "STUN and TURN library for Erlang / Elixir"},
{vsn, "1.0.20"},
{vsn, "1.0.22"},
{modules, []},
{registered, []},
{applications, [kernel, stdlib, p1_utils]},
......
......@@ -46,6 +46,9 @@
%% gen_fsm states
-export([session_established/2]).
%% helper functions
-export([rand_uniform/0, rand_uniform/1, rand_uniform/2]).
-include("stun.hrl").
-define(MAX_BUF_SIZE, 64*1024). %% 64kb
......@@ -101,7 +104,6 @@ tcp_init(_Sock, Opts) ->
Opts.
udp_init(Sock, Opts) ->
seed(),
prepare_state(Opts, Sock, {{0,0,0,0}, 0}, gen_udp).
udp_recv(Sock, Addr, Port, Data, State) ->
......@@ -120,7 +122,6 @@ udp_recv(Sock, Addr, Port, Data, State) ->
init([Sock, Opts]) ->
case inet:peername(Sock) of
{ok, Addr} ->
seed(),
TRef = erlang:start_timer(?TIMEOUT, self(), stop),
SockMod = get_sockmod(Opts),
State = prepare_state(Opts, Sock, Addr, SockMod),
......@@ -597,7 +598,7 @@ clean_treap(Treap, CleanPriority) ->
make_nonce(Addr, Nonces) ->
Priority = now_priority(),
{TS, _} = Priority,
Nonce = list_to_binary(integer_to_list(random:uniform(1 bsl 32))),
Nonce = list_to_binary(integer_to_list(rand_uniform(1 bsl 32))),
NewNonces = clean_treap(Nonces, TS + ?NONCE_LIFETIME),
{Nonce, treap:insert(Nonce, Priority, Addr, NewNonces)}.
......@@ -642,12 +643,31 @@ maybe_starttls(Sock, fast_tls, CertFile, _PeerAddr) ->
maybe_starttls(Sock, gen_tcp, _CertFile, _PeerAddr) ->
{ok, Sock}.
seed() ->
{A, B, C} = p1_time_compat:timestamp(),
random:seed(A, B, C).
prepare_response(State, Msg) ->
#stun{method = Msg#stun.method,
magic = Msg#stun.magic,
trid = Msg#stun.trid,
'SOFTWARE' = State#state.server_name}.
-define(THRESHOLD, 16#10000000000000000).
-ifdef(RAND_UNIFORM).
rand_uniform() ->
rand:uniform().
rand_uniform(N) ->
rand:uniform(N).
rand_uniform(N, M) ->
rand:uniform(M-N+1) + N-1.
-else.
rand_uniform() ->
crypto:rand_uniform(0, ?THRESHOLD)/?THRESHOLD.
rand_uniform(N) ->
crypto:rand_uniform(1, N+1).
rand_uniform(N, M) ->
crypto:rand_uniform(N, M+1).
-endif.
......@@ -355,9 +355,7 @@ recv(TLSSocket, Buf, true) ->
end.
mk_trid() ->
{A, B, C} = p1_time_compat:timestamp(),
random:seed(A, B, C),
random:uniform(1 bsl 96).
stun:rand_uniform(1 bsl 96).
get_cert() ->
<<"-----BEGIN CERTIFICATE-----
......
......@@ -115,8 +115,6 @@ init([Opts]) ->
ok
end,
TRef = erlang:start_timer(?DEFAULT_LIFETIME, self(), stop),
{A1, A2, A3} = p1_time_compat:timestamp(),
random:seed(A1, A2, A3),
case turn_sm:add_allocation(AddrPort, Username, Realm, MaxAllocs, self()) of
ok ->
{ok, wait_for_allocate, State#state{life_timer = TRef}};
......@@ -436,7 +434,7 @@ time_left(TRef) ->
%% draft-ietf-tsvwg-port-randomization-04
allocate_addr({Min, Max}) ->
Count = Max - Min + 1,
Next = Min + random:uniform(Count) - 1,
Next = Min + stun:rand_uniform(Count) - 1,
allocate_addr(Min, Max, Next, Count).
allocate_addr(_Min, _Max, _Next, 0) ->
......
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