@@ -223,7 +223,24 @@ ranch_ref(#listener{port = Port}) ->
223
223
{acceptor , IPAddress , Port };
224
224
ranch_ref (Listener ) when is_list (Listener ) ->
225
225
Port = rabbit_misc :pget (port , Listener ),
226
- [{IPAddress , Port , _Family } | _ ] = tcp_listener_addresses (Port ),
226
+ IPAddress = case rabbit_misc :pget (ip , Listener ) of
227
+ undefined ->
228
+ [{Value , _Port , _Family } | _ ] = tcp_listener_addresses (Port ),
229
+ Value ;
230
+ Value when is_list (Value ) ->
231
+ % % since we only use this function to parse the address, only one result should
232
+ % % be returned
233
+ [{Parsed , _Family } | _ ] = gethostaddr (Value , auto ),
234
+ Parsed ;
235
+ Value when is_binary (Value ) ->
236
+ Str = rabbit_data_coercion :to_list (Value ),
237
+ % % since we only use this function to parse the address, only one result should
238
+ % % be returned
239
+ [{Parsed , _Family } | _ ] = gethostaddr (Str , auto ),
240
+ Parsed ;
241
+ Value when is_tuple (Value ) ->
242
+ Value
243
+ end ,
227
244
{acceptor , IPAddress , Port };
228
245
ranch_ref (undefined ) ->
229
246
undefined .
@@ -692,6 +709,7 @@ getaddr(Host, Family) ->
692
709
{error , _ } -> gethostaddr (Host , Family )
693
710
end .
694
711
712
+ -spec gethostaddr (string (), inet :address_family () | 'auto' ) -> [{inet :ip_address (), inet :address_family ()}].
695
713
gethostaddr (Host , auto ) ->
696
714
Lookups = [{Family , inet :getaddr (Host , Family )} || Family <- [inet , inet6 ]],
697
715
case [{IP , Family } || {Family , {ok , IP }} <- Lookups ] of
0 commit comments