@@ -234,7 +234,24 @@ ranch_ref(#listener{port = Port}) ->
234
234
{acceptor , IPAddress , Port };
235
235
ranch_ref (Listener ) when is_list (Listener ) ->
236
236
Port = rabbit_misc :pget (port , Listener ),
237
- [{IPAddress , Port , _Family } | _ ] = tcp_listener_addresses (Port ),
237
+ IPAddress = case rabbit_misc :pget (ip , Listener ) of
238
+ undefined ->
239
+ [{Value , _Port , _Family } | _ ] = tcp_listener_addresses (Port ),
240
+ Value ;
241
+ Value when is_list (Value ) ->
242
+ % % since we only use this function to parse the address, only one result should
243
+ % % be returned
244
+ [{Parsed , _Family } | _ ] = gethostaddr (Value , auto ),
245
+ Parsed ;
246
+ Value when is_binary (Value ) ->
247
+ Str = rabbit_data_coercion :to_list (Value ),
248
+ % % since we only use this function to parse the address, only one result should
249
+ % % be returned
250
+ [{Parsed , _Family } | _ ] = gethostaddr (Str , auto ),
251
+ Parsed ;
252
+ Value when is_tuple (Value ) ->
253
+ Value
254
+ end ,
238
255
{acceptor , IPAddress , Port };
239
256
ranch_ref (undefined ) ->
240
257
undefined .
@@ -637,6 +654,7 @@ getaddr(Host, Family) ->
637
654
{error , _ } -> gethostaddr (Host , Family )
638
655
end .
639
656
657
+ -spec gethostaddr (string (), inet :address_family () | 'auto' ) -> [{inet :ip_address (), inet :address_family ()}].
640
658
gethostaddr (Host , auto ) ->
641
659
Lookups = [{Family , inet :getaddr (Host , Family )} || Family <- [inet , inet6 ]],
642
660
case [{IP , Family } || {Family , {ok , IP }} <- Lookups ] of
0 commit comments