@@ -142,9 +142,9 @@ defmodule ExICE.Priv.ICEAgent do
142142 { local_ufrag , local_pwd } = generate_credentials ( )
143143
144144 controlling_process = Keyword . fetch! ( opts , :controlling_process )
145+ transport_module = Keyword . fetch! ( opts , :transport_module )
145146
146147 if_discovery_module = opts [ :if_discovery_module ] || IfDiscovery.Inet
147- transport_module = opts [ :transport_module ] || Transport.UDP
148148 ip_filter = opts [ :ip_filter ] || fn _ -> true end
149149 ports = opts [ :ports ] || [ 0 ]
150150
@@ -944,7 +944,7 @@ defmodule ExICE.Priv.ICEAgent do
944944
945945 { :send , dst , data , client } ->
946946 tr = % { tr | client: client }
947- :ok = ice_agent . transport_module . send ( tr . socket , dst , data )
947+ :ok = Transport . send ( ice_agent . transport_module , tr . socket , dst , data )
948948 put_in ( ice_agent . gathering_transactions [ tr_id ] , tr )
949949
950950 { :error , _reason , _client } ->
@@ -962,7 +962,7 @@ defmodule ExICE.Priv.ICEAgent do
962962 cand = % { cand | client: client }
963963 ice_agent = put_in ( ice_agent . local_cands [ cand . base . id ] , cand )
964964 # we can't use do_send here as it will try to create permission for the turn address
965- :ok = ice_agent . transport_module . send ( cand . base . socket , dst , data )
965+ :ok = Transport . send ( ice_agent . transport_module , cand . base . socket , dst , data )
966966 ice_agent
967967
968968 { :error , _reason , client } ->
@@ -1013,7 +1013,7 @@ defmodule ExICE.Priv.ICEAgent do
10131013 for turn_server <- turn_servers , % { socket: socket } <- sockets do
10141014 with { :ok , client } <-
10151015 ExTURN.Client . new ( turn_server . url , turn_server . username , turn_server . credential ) ,
1016- { :ok , { sock_ip , _sock_port } } <- ice_agent . transport_module . sockname ( socket ) ,
1016+ { :ok , { sock_ip , _sock_port } } <- Transport . sockname ( ice_agent . transport_module , socket ) ,
10171017 { true , _ , _ } <-
10181018 { Utils . family ( client . turn_ip ) == Utils . family ( sock_ip ) , client , sock_ip } do
10191019 t_id = { socket , { client . turn_ip , client . turn_port } }
@@ -1098,7 +1098,7 @@ defmodule ExICE.Priv.ICEAgent do
10981098 end
10991099
11001100 defp execute_gathering_transaction ( ice_agent , % { stun_server: stun_server } = tr ) do
1101- { :ok , { sock_ip , sock_port } } = ice_agent . transport_module . sockname ( tr . socket )
1101+ { :ok , { sock_ip , sock_port } } = Transport . sockname ( ice_agent . transport_module , tr . socket )
11021102
11031103 Logger . debug ( """
11041104 Sending binding request to gather srflx candidate for:
@@ -1124,7 +1124,7 @@ defmodule ExICE.Priv.ICEAgent do
11241124 end
11251125
11261126 defp execute_gathering_transaction ( ice_agent , % { client: client } = tr ) do
1127- { :ok , { sock_ip , sock_port } } = ice_agent . transport_module . sockname ( tr . socket )
1127+ { :ok , { sock_ip , sock_port } } = Transport . sockname ( ice_agent . transport_module , tr . socket )
11281128
11291129 Logger . debug ( """
11301130 Starting the process of gathering relay candidate for:
@@ -1135,7 +1135,7 @@ defmodule ExICE.Priv.ICEAgent do
11351135 { :send , turn_addr , data , client } = ExTURN.Client . allocate ( client )
11361136 tr = Map . put ( tr , :client , client )
11371137
1138- case ice_agent . transport_module . send ( tr . socket , turn_addr , data ) do
1138+ case Transport . send ( ice_agent . transport_module , tr . socket , turn_addr , data ) do
11391139 :ok ->
11401140 tr = % { tr | state: :in_progress , send_time: now ( ) }
11411141 ice_agent = put_in ( ice_agent . gathering_transactions [ tr . t_id ] , tr )
@@ -1215,7 +1215,7 @@ defmodule ExICE.Priv.ICEAgent do
12151215
12161216 # Use sock_addr for calculating priority.
12171217 # In other case, we might get duplicates.
1218- { :ok , { sock_addr , _sock_port } } = ice_agent . transport_module . sockname ( tr . socket )
1218+ { :ok , { sock_addr , _sock_port } } = Transport . sockname ( ice_agent . transport_module , tr . socket )
12191219
12201220 # TODO: set correct tcp_type here
12211221 { local_preferences , priority } =
@@ -1250,7 +1250,7 @@ defmodule ExICE.Priv.ICEAgent do
12501250
12511251 { :send , turn_addr , data , client } ->
12521252 tr = % { tr | client: client }
1253- :ok = ice_agent . transport_module . send ( tr . socket , turn_addr , data )
1253+ :ok = Transport . send ( ice_agent . transport_module , tr . socket , turn_addr , data )
12541254 put_in ( ice_agent . gathering_transactions [ tr_id ] , tr )
12551255
12561256 { :error , _reason , _client } ->
@@ -1912,7 +1912,7 @@ defmodule ExICE.Priv.ICEAgent do
19121912
19131913 case find_local_cand ( Map . values ( ice_agent . local_cands ) , xor_addr , xor_port ) do
19141914 nil ->
1915- { :ok , { base_addr , base_port } } = ice_agent . transport_module . sockname ( tr . socket )
1915+ { :ok , { base_addr , base_port } } = Transport . sockname ( ice_agent . transport_module , tr . socket )
19161916
19171917 host_cand = find_host_cand ( Map . values ( ice_agent . local_cands ) , tr . socket )
19181918
@@ -2423,7 +2423,7 @@ defmodule ExICE.Priv.ICEAgent do
24232423 # Alternatively, we could create a callback for `:inet.info/1`,
24242424 # but it's return type is not standardized - sometimes it's %{states: [:closed]},
24252425 # some other time %{rstates: [:closed], wstates: [:closed]}.
2426- case ice_agent . transport_module . sockname ( socket ) do
2426+ case Transport . sockname ( ice_agent . transport_module , socket ) do
24272427 { :error , :closed } -> ice_agent
24282428 _ -> do_close_socket ( ice_agent , socket )
24292429 end
@@ -2448,7 +2448,7 @@ defmodule ExICE.Priv.ICEAgent do
24482448
24492449 tr_rtx = ice_agent . tr_rtx -- Map . keys ( removed_gathering_transactions )
24502450
2451- :ok = ice_agent . transport_module . close ( socket )
2451+ :ok = Transport . close ( ice_agent . transport_module , socket )
24522452 :ok = flush_socket_msg ( socket )
24532453
24542454 % { ice_agent | tr_rtx: tr_rtx , gathering_transactions: gathering_transactions }
@@ -2513,12 +2513,12 @@ defmodule ExICE.Priv.ICEAgent do
25132513
25142514 defp do_restart ( ice_agent ) do
25152515 Enum . each ( ice_agent . sockets , fn socket ->
2516- case ice_agent . transport_module . sockname ( socket ) do
2516+ case Transport . sockname ( ice_agent . transport_module , socket ) do
25172517 { :ok , { ip , port } } ->
25182518 # we could use close_socket function here but because we are
25192519 # clearing the whole state anyway, we can close the socket manually
25202520 Logger . debug ( "Closing socket: #{ inspect ( ip ) } :#{ port } ." )
2521- :ok = ice_agent . transport_module . close ( socket )
2521+ :ok = Transport . close ( ice_agent . transport_module , socket )
25222522 :ok = flush_socket_msg ( socket )
25232523
25242524 { :error , :closed } ->
@@ -3116,7 +3116,7 @@ defmodule ExICE.Priv.ICEAgent do
31163116 priority =
31173117 if local_candidate . base . type == :relay do
31183118 { :ok , { sock_addr , _sock_port } } =
3119- ice_agent . transport_module . sockname ( local_candidate . base . socket )
3119+ Transport . sockname ( ice_agent . transport_module , local_candidate . base . socket )
31203120
31213121 Candidate . priority! (
31223122 ice_agent . local_preferences ,
0 commit comments