Skip to content

Commit 2087f93

Browse files
committed
Fix compile warnings, bump deps+CI
1 parent d230a73 commit 2087f93

13 files changed

Lines changed: 219 additions & 182 deletions

File tree

.github/workflows/ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ jobs:
66
name: lint OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}}
77
strategy:
88
matrix:
9-
otp: ['26']
10-
elixir: ['1.15']
9+
otp: ['29']
10+
elixir: ['1.20']
1111
steps:
1212
- uses: actions/checkout@v2
1313
- uses: erlef/setup-beam@v1
@@ -24,8 +24,8 @@ jobs:
2424
name: test OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}}
2525
strategy:
2626
matrix:
27-
otp: ['26']
28-
elixir: ['1.15']
27+
otp: ['29']
28+
elixir: ['1.20']
2929
env:
3030
MIX_ENV: test
3131
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -39,4 +39,4 @@ jobs:
3939
- run: mix coveralls.json
4040
- uses: codecov/codecov-action@v4
4141
with:
42-
token: ${{ secrets.CODECOV_TOKEN }}
42+
token: ${{ secrets.CODECOV_TOKEN }}

lib/ex_ice/ice_agent.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ defmodule ExICE.ICEAgent do
164164
@doc """
165165
Gets agent's role.
166166
"""
167-
@spec get_role(pid()) :: ExICE.Agent.t() | nil
167+
@spec get_role(pid()) :: role() | nil
168168
def get_role(ice_agent) do
169169
GenServer.call(ice_agent, :get_role)
170170
end

lib/ex_ice/priv/candidate_pair.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
defmodule ExICE.Priv.CandidatePair do
22
@moduledoc false
3-
require Logger
43

54
alias ExICE.Priv.{Candidate, Utils}
65

@@ -62,8 +61,9 @@ defmodule ExICE.Priv.CandidatePair do
6261
]
6362

6463
@doc false
65-
@spec new(Candidate.t(), Candidate.t(), ExICE.ICEAgent.role(), state(), valid?: boolean()) ::
66-
t()
64+
@spec new(Candidate.t(), Candidate.t(), ExICE.ICEAgent.role(), state(), [
65+
{:valid?, boolean()} | {:last_seen, integer()}
66+
]) :: t()
6767
def new(local_cand, remote_cand, agent_role, state, opts \\ []) do
6868
priority = priority(agent_role, local_cand.base.priority, remote_cand.priority)
6969

@@ -94,8 +94,8 @@ defmodule ExICE.Priv.CandidatePair do
9494

9595
@doc false
9696
@spec recompute_priority(t(), integer(), integer(), ExICE.ICEAgent.role()) :: t()
97-
def recompute_priority(pair, local_cand_prio, remote_cand_prio, role) do
98-
%__MODULE__{pair | priority: priority(role, local_cand_prio, remote_cand_prio)}
97+
def recompute_priority(%__MODULE__{} = pair, local_cand_prio, remote_cand_prio, role) do
98+
%{pair | priority: priority(role, local_cand_prio, remote_cand_prio)}
9999
end
100100

101101
@doc false

lib/ex_ice/priv/checklist.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ defmodule ExICE.Priv.Checklist do
9696

9797
@spec timeout_pairs(t(), [integer()]) :: t()
9898
def timeout_pairs(checklist, ids) do
99-
for {_id, pair} <- checklist, into: %{} do
99+
for {_id, %CandidatePair{} = pair} <- checklist, into: %{} do
100100
if pair.id in ids do
101-
{pair.id, %CandidatePair{pair | valid?: false, state: :failed}}
101+
{pair.id, %{pair | valid?: false, state: :failed}}
102102
else
103103
{pair.id, pair}
104104
end

lib/ex_ice/priv/conn_check_handler/controlled.ex

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ defmodule ExICE.Priv.ConnCheckHandler.Controlled do
2424

2525
nil when ice_agent.state in [:new, :checking, :connected] ->
2626
Logger.debug("Adding new candidate pair: #{inspect(pair)}")
27-
pair = %CandidatePair{pair | requests_received: 1}
27+
pair = %{pair | requests_received: 1}
2828
checklist = Map.put(ice_agent.checklist, pair.id, pair)
29-
ice_agent = %ICEAgent{ice_agent | checklist: checklist}
29+
ice_agent = %{ice_agent | checklist: checklist}
3030
ICEAgent.send_binding_success_response(ice_agent, pair, msg)
3131

3232
%CandidatePair{} = checklist_pair ->
3333
cond do
3434
ice_agent.state == :failed ->
3535
r_pair = resolve_pair(ice_agent, checklist_pair)
3636

37-
r_pair = %CandidatePair{
37+
r_pair = %{
3838
r_pair
3939
| last_seen: pair.last_seen,
4040
requests_received: r_pair.requests_received + 1
@@ -45,7 +45,7 @@ defmodule ExICE.Priv.ConnCheckHandler.Controlled do
4545
checklist_pair.state == :failed and ice_agent.state == :completed ->
4646
r_pair = resolve_pair(ice_agent, checklist_pair)
4747

48-
r_pair = %CandidatePair{
48+
r_pair = %{
4949
r_pair
5050
| last_seen: pair.last_seen,
5151
requests_received: r_pair.requests_received + 1
@@ -56,7 +56,7 @@ defmodule ExICE.Priv.ConnCheckHandler.Controlled do
5656
checklist_pair.state == :failed ->
5757
r_pair = resolve_pair(ice_agent, checklist_pair)
5858

59-
r_pair = %CandidatePair{
59+
r_pair = %{
6060
r_pair
6161
| state: :waiting,
6262
last_seen: pair.last_seen,
@@ -69,7 +69,7 @@ defmodule ExICE.Priv.ConnCheckHandler.Controlled do
6969
true ->
7070
r_pair = resolve_pair(ice_agent, checklist_pair)
7171

72-
r_pair = %CandidatePair{
72+
r_pair = %{
7373
r_pair
7474
| last_seen: pair.last_seen,
7575
requests_received: r_pair.requests_received + 1
@@ -98,16 +98,16 @@ defmodule ExICE.Priv.ConnCheckHandler.Controlled do
9898
successful conn check: #{inspect(pair.id)}\
9999
""")
100100

101-
pair = %CandidatePair{pair | nominate?: true, requests_received: 1}
101+
pair = %{pair | nominate?: true, requests_received: 1}
102102
checklist = Map.put(ice_agent.checklist, pair.id, pair)
103103

104-
ice_agent = %ICEAgent{ice_agent | checklist: checklist}
104+
ice_agent = %{ice_agent | checklist: checklist}
105105
ICEAgent.send_binding_success_response(ice_agent, pair, msg)
106106

107107
%CandidatePair{state: :succeeded} = checklist_pair when ice_agent.state != :failed ->
108108
discovered_pair = Map.fetch!(ice_agent.checklist, checklist_pair.discovered_pair_id)
109109

110-
discovered_pair = %CandidatePair{
110+
discovered_pair = %{
111111
discovered_pair
112112
| last_seen: pair.last_seen,
113113
requests_received: discovered_pair.requests_received + 1
@@ -133,7 +133,7 @@ defmodule ExICE.Priv.ConnCheckHandler.Controlled do
133133
Pair: #{inspect(pair.id)}
134134
""")
135135

136-
r_pair = %CandidatePair{
136+
r_pair = %{
137137
r_pair
138138
| nominate?: true,
139139
last_seen: pair.last_seen,
@@ -151,7 +151,7 @@ defmodule ExICE.Priv.ConnCheckHandler.Controlled do
151151
Pair: #{inspect(checklist_pair.id)}
152152
""")
153153

154-
checklist_pair = %CandidatePair{
154+
checklist_pair = %{
155155
checklist_pair
156156
| nominate?: true,
157157
last_seen: pair.last_seen,
@@ -164,7 +164,7 @@ defmodule ExICE.Priv.ConnCheckHandler.Controlled do
164164
%CandidatePair{} = checklist_pair ->
165165
r_pair = resolve_pair(ice_agent, checklist_pair)
166166

167-
r_pair = %CandidatePair{
167+
r_pair = %{
168168
r_pair
169169
| last_seen: pair.last_seen,
170170
requests_received: r_pair.requests_received + 1
@@ -182,22 +182,22 @@ defmodule ExICE.Priv.ConnCheckHandler.Controlled do
182182
Logger.debug("Nomination succeeded, pair: #{pair_id}")
183183

184184
pair = Map.fetch!(ice_agent.checklist, pair_id)
185-
pair = %CandidatePair{pair | nominate?: false, nominated?: true}
185+
pair = %{pair | nominate?: false, nominated?: true}
186186

187187
checklist = Map.put(ice_agent.checklist, pair.id, pair)
188-
ice_agent = %ICEAgent{ice_agent | checklist: checklist}
188+
ice_agent = %{ice_agent | checklist: checklist}
189189

190190
cond do
191191
ice_agent.selected_pair_id == nil ->
192192
Logger.debug("Selecting pair: #{pair_id}")
193193

194-
%ICEAgent{
194+
%{
195195
ice_agent
196196
| selected_pair_id: pair.id,
197197
selected_candidate_pair_changes: ice_agent.selected_candidate_pair_changes + 1
198198
}
199199

200-
ice_agent.selected_pair_id != nil and pair.id != ice_agent.selected_pair_id ->
200+
pair.id != ice_agent.selected_pair_id ->
201201
selected_pair = Map.fetch!(ice_agent.checklist, ice_agent.selected_pair_id)
202202

203203
if pair.priority >= selected_pair.priority do
@@ -206,7 +206,7 @@ defmodule ExICE.Priv.ConnCheckHandler.Controlled do
206206
New pair: #{pair_id}, old pair: #{ice_agent.selected_pair_id}.\
207207
""")
208208

209-
%ICEAgent{
209+
%{
210210
ice_agent
211211
| selected_pair_id: pair.id,
212212
selected_candidate_pair_changes: ice_agent.selected_candidate_pair_changes + 1

lib/ex_ice/priv/conn_check_handler/controlling.ex

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ defmodule ExICE.Priv.ConnCheckHandler.Controlling do
3636

3737
nil when ice_agent.state in [:new, :checking, :connected] ->
3838
Logger.debug("Adding new candidate pair: #{inspect(pair)}")
39-
pair = %CandidatePair{pair | requests_received: 1}
39+
pair = %{pair | requests_received: 1}
4040
checklist = Map.put(ice_agent.checklist, pair.id, pair)
41-
ice_agent = %ICEAgent{ice_agent | checklist: checklist}
41+
ice_agent = %{ice_agent | checklist: checklist}
4242
ICEAgent.send_binding_success_response(ice_agent, pair, msg)
4343

4444
%CandidatePair{} = checklist_pair ->
4545
cond do
4646
ice_agent.state == :failed ->
4747
r_pair = resolve_pair(ice_agent, checklist_pair)
4848

49-
r_pair = %CandidatePair{
49+
r_pair = %{
5050
r_pair
5151
| last_seen: pair.last_seen,
5252
requests_received: r_pair.requests_received + 1
@@ -57,7 +57,7 @@ defmodule ExICE.Priv.ConnCheckHandler.Controlling do
5757
checklist_pair.state == :failed and ice_agent.state == :completed ->
5858
r_pair = resolve_pair(ice_agent, checklist_pair)
5959

60-
r_pair = %CandidatePair{
60+
r_pair = %{
6161
r_pair
6262
| last_seen: pair.last_seen,
6363
requests_received: r_pair.requests_received + 1
@@ -68,7 +68,7 @@ defmodule ExICE.Priv.ConnCheckHandler.Controlling do
6868
checklist_pair.state == :failed ->
6969
r_pair = resolve_pair(ice_agent, checklist_pair)
7070

71-
r_pair = %CandidatePair{
71+
r_pair = %{
7272
r_pair
7373
| state: :waiting,
7474
last_seen: pair.last_seen,
@@ -81,7 +81,7 @@ defmodule ExICE.Priv.ConnCheckHandler.Controlling do
8181
true ->
8282
r_pair = resolve_pair(ice_agent, checklist_pair)
8383

84-
r_pair = %CandidatePair{
84+
r_pair = %{
8585
r_pair
8686
| last_seen: pair.last_seen,
8787
requests_received: r_pair.requests_received + 1
@@ -106,21 +106,21 @@ defmodule ExICE.Priv.ConnCheckHandler.Controlling do
106106
Logger.debug("Nomination succeeded. Selecting pair: #{inspect(pair_id)}")
107107

108108
pair = Map.fetch!(ice_agent.checklist, pair_id)
109-
pair = %CandidatePair{pair | nominate?: false, nominated?: true}
109+
pair = %{pair | nominate?: false, nominated?: true}
110110
ice_agent = put_in(ice_agent.checklist[pair.id], pair)
111111

112112
ice_agent =
113113
cond do
114114
ice_agent.selected_pair_id == nil ->
115115
Logger.debug("Selecting pair: #{pair_id}")
116116

117-
%ICEAgent{
117+
%{
118118
ice_agent
119119
| selected_pair_id: pair.id,
120120
selected_candidate_pair_changes: ice_agent.selected_candidate_pair_changes + 1
121121
}
122122

123-
ice_agent.selected_pair_id != nil and pair.id != ice_agent.selected_pair_id ->
123+
pair.id != ice_agent.selected_pair_id ->
124124
selected_pair = Map.fetch!(ice_agent.checklist, ice_agent.selected_pair_id)
125125

126126
if pair.priority >= selected_pair.priority do
@@ -129,7 +129,7 @@ defmodule ExICE.Priv.ConnCheckHandler.Controlling do
129129
New pair: #{pair_id}, old pair: #{ice_agent.selected_pair_id}.\
130130
""")
131131

132-
%ICEAgent{
132+
%{
133133
ice_agent
134134
| selected_pair_id: pair.id,
135135
selected_candidate_pair_changes: ice_agent.selected_candidate_pair_changes + 1
@@ -150,7 +150,7 @@ defmodule ExICE.Priv.ConnCheckHandler.Controlling do
150150
Logger.warning("Nomination succeeded but checklist hasn't finished.")
151151
end
152152

153-
%ICEAgent{ice_agent | nominating?: {false, nil}}
153+
%{ice_agent | nominating?: {false, nil}}
154154
end
155155

156156
defp resolve_pair(ice_agent, pair) do

lib/ex_ice/priv/gatherer.ex

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ defmodule ExICE.Priv.Gatherer do
1010

1111
require Logger
1212

13+
@type local_preferences :: %{:inet.ip_address() => non_neg_integer()}
14+
1315
@type t() :: %__MODULE__{
1416
if_discovery_module: module(),
1517
transport_module: module(),
@@ -95,9 +97,8 @@ defmodule ExICE.Priv.Gatherer do
9597
end)
9698
end
9799

98-
@spec gather_host_candidates(t(), %{:inet.ip_address() => non_neg_integer()}, [
99-
{Transport.socket(), map()}
100-
]) :: [Candidate.t()]
100+
@spec gather_host_candidates(t(), local_preferences(), [{Transport.socket(), map()}]) ::
101+
{local_preferences(), [Candidate.t()]}
101102
def gather_host_candidates(gatherer, local_preferences, sockets) do
102103
{local_preferences, cands} =
103104
Enum.reduce(sockets, {local_preferences, []}, fn socket, {local_preferences, cands} ->

0 commit comments

Comments
 (0)