anchor.diff:  	    L when is_list(L) ->
   		Res ++ L
   	end,
  -    format_siplookup_result2(InPort, ReqURI, HostIn, T, NewRes).
  -
  -%% format_siplookup_result2_sslnames, part of format_siplookup_result2.
  -%% Returns : Names = list() of string()
  -format_siplookup_result2_sslnames(Proto, HostIn, Host) when Proto == tls; Proto == tls6 ->
  -    %% Determine what we will later use to validate the SSL connection made. The default
  -    %% is to use HostIn (which is typically what a user entered as domain-name in a URL),
  -    %% but it is very common to have a per-server certificate, so if configured to we
  -    %% will instead use the hostname from the NAPTR/SRV lookup. This is of course less
  -    %% secure, unless the NAPTR/SRV DNS lookup is secured using DNSSEC.
  -    case yxa_config:get_env(ssl_check_subject_altname_allow_servername) of
  -	{ok, true} ->
  -	    case HostIn of
  -		undefined -> [Host];
  -		_ ->
  -		    L = [Host | [HostIn]],
  -		    lists:usort(L)
  -	    end;
  -	{ok, false} ->
  -	    [HostIn]
  -    end;
  -format_siplookup_result2_sslnames(_Proto, _HostIn, _Host) ->
  +    format_siplookup_result2(InPort, ReqURI, SSLNames, SSL_AddHost, Test, T, NewRes).
  +
  +
  +%%--------------------------------------------------------------------
  +%% Function: format_siplookup_result2_sslnames(Proto, SSLNames,
  +%%                                             AddHost, Host)
  +%%           Proto    = tls | tls6 | ...
  +%%           SSLNames = list() of string(), extra SSL names to allow
  +%%           AddHost  = bool()
  +%%           Host     = string(), hostname we are resolving
  +%% Descrip.: Determine what we will later use to validate the SSL
  +%%           connection made. The default is to use SSLNames (which is
  +%%           typically what a user entered as domain-name in a URL),
  +%%           but it is very common to have a per-server certificate,
  +%%           so if configured to we will also allow the hostname from
  +%%           the NAPTR/SRV lookup. This is of course less secure,
  +%%           unless the NAPTR/SRV DNS lookup is secured using DNSSEC.
  +%% Returns : AllSSLNames = list() of string()
  +%%--------------------------------------------------------------------
  +format_siplookup_result2_sslnames(Proto, SSLNames, true, Host) when Proto == tls; Proto == tls6 ->
  +    %% AddHost is true, return SSLNames and Host merged together
  +    L = [Host | SSLNames],
  +    lists:usort(L);
  +format_siplookup_result2_sslnames(Proto, SSLNames, false, _Host) when Proto == tls; Proto == tls6 ->
  +    %% AddHost is false, just return SSLNames
  +    SSLNames;
  +format_siplookup_result2_sslnames(_Proto, _SSLNames, _AddHost, _Host) ->
       %% Not TLS, no reason to construct a list of validation names
       [].
   
  
positive.code: 	{ok, _IPtuple} ->
  	    Port = sipurl:get_port(URL),
  	    logger:log(debug, "url_to_dstlist: ~p is an IP address, not performing domain NAPTR/SRV lookup", [Host]),
  	    Proto = get_proto_from_parameters(URL),
  	    case address_to_address_and_proto(Host, Proto) of
  		{error, E} ->
  		    logger:log(debug, "Warning: Could not make a destination of ~p:~p (~p)",
  			       [Host, Port, E]),
  		    {error, "Coult not make destination out of URL"};
  		{ok, UseAddr, UseProto} ->
  		    UsePort = sipsocket:default_port(UseProto, Port),
  		    %% We don't fill in sipdst.ssl_hostname here since we are extremely unlikely
  		    %% to encounter a SSL certificate for an IP address anyways.
  		    [#sipdst{proto=UseProto, addr=UseAddr, port=UsePort, uri=ReqURI}]
  	    end;
  	_ ->
  	    url_to_dstlist_not_ip(URL, ApproxMsgSize, ReqURI)
      end.
  
  %% part of url_to_dstlist/3 - determine protocol to use from sipurl records parameters
  %% Returns : tcp | udp | tls
  get_proto_from_parameters(URL) when is_record(URL, sipurl) ->
      %% Find requested transport in URL parameters and lowercase it
      case url_param:find(URL#sipurl.param_pairs, "transport") of
  	[Transport] ->
  	    case httpd_util:to_lower(Transport) of
  		"tcp" -> tcp;
  		"udp" -> udp;
  		"tls" -> tls;
  		Unknown ->
  		    %% RFC3263 4.1 says we SHOULD use UDP for sip: and TCP for sips: when target is IP
  		    %% and no transport is indicated in the parameters
  		    case URL#sipurl.proto of
  			"sips" ->
  			    logger:log(debug, "url_to_dstlist: transport protocol ~p not recognized,"
  				       " defaulting to TLS for SIPS URL", [Unknown]),
  			    tls;
  			_ ->
  			    logger:log(debug, "url_to_dstlist: transport protocol ~p not recognized,"
  				       " defaulting to UDP for non-SIPS URL", [Unknown]),
  			    udp
  		    end
  	    end;
  	_ ->
  	    %% RFC3263 #4.1 (Selecting a Transport Protocol) "Otherwise, if no transport
  	    %% protocol is specified, but the TARGET is a numeric IP address, the client
  	    %% SHOULD use UDP for a SIP URI, and TCP for a SIPS URI
  	    case (URL#sipurl.proto == "sips") of
  		true -> tls;
  		false -> udp
  	    end
      end.
  
  %%--------------------------------------------------------------------
  
negative.code: %%           In       = list() of sipdns_hostport record() - typically
  %%                      the result of a call to dnsutil:get_ip_port()
  %% Descrip.: Turns the result of a dnsutil:get_ip_port() into a list
  %%           of sipdst records. get_ip_port() return a list of
  %%           sipdns_hostport records where the addr element is a
  %%           string ("10.0.0.1", "[2001:6b0:5:987::1]"). The family
  %%           element is 'inet' or 'inet6' and we need to know to
  %%           convert Proto as necessary. The order of the input tuples
  %%           is preserved in the resulting list.
  %% Returns : DstList | {error, Reason}
  %%           DstList = list() of sipdst record()
  %%           Reason  = string()
  %%--------------------------------------------------------------------
  make_sipdst_from_hostport(Proto, URI, SSLNames, In) when (Proto == tcp orelse Proto == udp
  							  orelse Proto == tls orelse Proto == yxa_test),
  							 is_record(URI, sipurl), is_list(SSLNames), is_list(In) ->
      UseSSLNames = case Proto == tls of
  		      true -> SSLNames;
  		      false -> []
  		  end,
      make_sipdst_from_hostport2(Proto, URI, UseSSLNames, In, []).
  
  %%
  %% sipdns_hostport.family == inet
  %%
  make_sipdst_from_hostport2(Proto, URI, SSLNames, [#sipdns_hostport{family = inet} = H | T], Res) ->
      UsePort = sipsocket:default_port(Proto, H#sipdns_hostport.port),
      This = #sipdst{proto	= Proto,
  		   addr		= H#sipdns_hostport.addr,
  		   port		= UsePort,
  		   uri		= URI,
  		   ssl_names	= SSLNames
  		  },
      make_sipdst_from_hostport2(Proto, URI, SSLNames, T, [This | Res]);
  %%
  %% sipdns_hostport.family == inet6
  %%
  make_sipdst_from_hostport2(Proto, URI, SSLNames, [#sipdns_hostport{family = inet6} = H | T], Res) ->
      %% inet6 family, must turn Proto into IPv6 variant
      UseProto = case Proto of
  		   tcp -> tcp6;
  		   udp -> udp6;
  		   tls -> tls6;
  		   yxa_test -> yxa_test6
  	       end,
      UsePort = sipsocket:default_port(UseProto, H#sipdns_hostport.port),
      This = #sipdst{proto	= UseProto,
  		   addr		= H#sipdns_hostport.addr,
  		   port		= UsePort,
  		   uri		= URI,
  		   ssl_names	= SSLNames
  		  },
      make_sipdst_from_hostport2(Proto, URI, SSLNames, T, [This | Res]);
  %%
  %% No more input
  %%
  make_sipdst_from_hostport2(_Proto, _URI, _SSLNames, [], Res) ->
      lists:reverse(Res).
  
  
  %%--------------------------------------------------------------------
  %% Function: format_siplookup_result(InPort, ReqURI, HostIn, DstList,
  %%                                   Test)
  %%           InPort  = integer() | none
  %%           ReqURI  = sipurl record()
  %%           HostIn  = string() | undefined, the hostname (or
  %%                     domain name) we got as input
  %%           SrvList = list() of sipdns_srv record()
  %%           Test    = bool(), unit testing or not?
  %% Descrip.: Turns the result of a dnsutil:siplookup() into a list
  %%           of sipdst records. The ordering is preserved.
  %% Returns : DstList, list() of sipdst record()
  %%--------------------------------------------------------------------
  format_siplookup_result(InPort, ReqURI, HostIn, SrvList, Test)
    when (is_integer(InPort) orelse InPort == none), is_record(ReqURI, sipurl),
         (is_list(HostIn) orelse HostIn == undefined), is_list(SrvList) ->
      SSLNames = [HostIn],
      {ok, AllowServerName} = yxa_config:get_env(ssl_check_subject_altname_allow_servername),
      format_siplookup_result2(InPort, ReqURI, SSLNames, AllowServerName, Test, SrvList, []).
  
  format_siplookup_result2(_InPort, _ReqURI, _SSLNames, _SSL_AddHost, _Test, [], Res) ->
      Res;
  format_siplookup_result2(InPort, ReqURI, SSLNames, SSL_AddHost, Test, [H | T], Res) when is_record(H, sipdns_srv) ->
      {Proto, Host, Port} = {H#sipdns_srv.proto, H#sipdns_srv.host, H#sipdns_srv.port},
      %% If InPort is 'none', then use the port from DNS. Otherwise, use InPort.
      %% This is to handle if we for example receive a request with a Request-URI of
  