@@ -234,7 +234,24 @@ ranch_ref(#listener{port = Port}) ->
234234 {acceptor , IPAddress , Port };
235235ranch_ref (Listener ) when is_list (Listener ) ->
236236 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 ,
238255 {acceptor , IPAddress , Port };
239256ranch_ref (undefined ) ->
240257 undefined .
@@ -637,6 +654,7 @@ getaddr(Host, Family) ->
637654 {error , _ } -> gethostaddr (Host , Family )
638655 end .
639656
657+ -spec gethostaddr (string (), inet :address_family () | 'auto' ) -> [{inet :ip_address (), inet :address_family ()}].
640658gethostaddr (Host , auto ) ->
641659 Lookups = [{Family , inet :getaddr (Host , Family )} || Family <- [inet , inet6 ]],
642660 case [{IP , Family } || {Family , {ok , IP }} <- Lookups ] of
0 commit comments