Skip to content

Commit 337225a

Browse files
committed
Fix remote prflx candidate being created with invalid transport
1 parent 1bb3ace commit 337225a

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

lib/ex_ice/priv/ice_agent.ex

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,7 +1580,6 @@ defmodule ExICE.Priv.ICEAgent do
15801580
{:ok, role_attr} <- get_role_attribute(msg),
15811581
{:ok, use_cand_attr} <- get_use_cand_attribute(msg),
15821582
{:ok, ice_agent} <- check_req_role_conflict(ice_agent, role_attr) do
1583-
# OOOO NIEEEEEE
15841583
{remote_cand, ice_agent} =
15851584
get_or_create_remote_cand(ice_agent, local_cand, src_ip, src_port, prio_attr)
15861585

@@ -2252,11 +2251,12 @@ defmodule ExICE.Priv.ICEAgent do
22522251
end)
22532252
end
22542253

2255-
defp tcp_types_ok?(nil, nil), do: true
2256-
defp tcp_types_ok?(:so, :so), do: true
2257-
defp tcp_types_ok?(:active, :passive), do: true
2258-
defp tcp_types_ok?(:passive, :active), do: true
2259-
defp tcp_types_ok?(_, _), do: false
2254+
defp tcp_types_ok?(t1, t2), do: get_matching_tcp_type(t1) == t2
2255+
2256+
defp get_matching_tcp_type(nil), do: nil
2257+
defp get_matching_tcp_type(:so), do: :so
2258+
defp get_matching_tcp_type(:active), do: :passive
2259+
defp get_matching_tcp_type(:passive), do: :active
22602260

22612261
defp symmetric?(ice_agent, socket, response_src, conn_check_pair) do
22622262
local_cand = Map.fetch!(ice_agent.local_cands, conn_check_pair.local_cand_id)
@@ -2348,14 +2348,13 @@ defmodule ExICE.Priv.ICEAgent do
23482348
defp get_or_create_remote_cand(ice_agent, local_cand, src_ip, src_port, prio_attr) do
23492349
case find_remote_cand(Map.values(ice_agent.remote_cands), src_ip, src_port) do
23502350
nil ->
2351-
# OOOOO NIEEEEEE
2352-
IO.inspect(local_cand, label: :LOCAL_CANDIDATE)
23532351
cand =
23542352
ExICE.Candidate.new(:prflx,
23552353
address: src_ip,
23562354
port: src_port,
23572355
priority: prio_attr.priority,
2358-
transport: local_cand.base.transport
2356+
transport: local_cand.base.transport,
2357+
tcp_type: get_matching_tcp_type(local_cand.base.tcp_type)
23592358
)
23602359

23612360
Logger.debug("Adding new remote prflx candidate: #{inspect(cand)}")

0 commit comments

Comments
 (0)