Skip to content

Commit

Permalink
Fix UriTool to retrieve correct IP when preferredNetworks is null
Browse files Browse the repository at this point in the history
  • Loading branch information
li-zheng-hao committed Nov 19, 2024
1 parent c02eca0 commit 8415f99
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Nacos.AspNetCore/UriTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ private static string GetCurrentIp(string preferredNetworks)
// 获取所有可用网卡IP信息
var ipCollection = nics?.Select(x => x.GetIPProperties())?.SelectMany(x => x.UnicastAddresses);

var preferredNetworksArr = preferredNetworks.Split(",");
var preferredNetworksArr = string.IsNullOrEmpty(preferredNetworks)
? new string[0] : preferredNetworks.Split(",");
foreach (var ipadd in ipCollection)
{
if (!IPAddress.IsLoopback(ipadd.Address) &&
Expand Down

0 comments on commit 8415f99

Please sign in to comment.