@@ -223,7 +223,24 @@ ranch_ref(#listener{port = Port}) ->
223223 {acceptor , IPAddress , Port };
224224ranch_ref (Listener ) when is_list (Listener ) ->
225225 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 ,
227244 {acceptor , IPAddress , Port };
228245ranch_ref (undefined ) ->
229246 undefined .
@@ -692,6 +709,7 @@ getaddr(Host, Family) ->
692709 {error , _ } -> gethostaddr (Host , Family )
693710 end .
694711
712+ -spec gethostaddr (string (), inet :address_family () | 'auto' ) -> [{inet :ip_address (), inet :address_family ()}].
695713gethostaddr (Host , auto ) ->
696714 Lookups = [{Family , inet :getaddr (Host , Family )} || Family <- [inet , inet6 ]],
697715 case [{IP , Family } || {Family , {ok , IP }} <- Lookups ] of
0 commit comments