Skip to content

Commit 7afd0d2

Browse files
authored
Fix UriTool to retrieve correct IP when preferredNetworks is null (#336)
1 parent c02eca0 commit 7afd0d2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Nacos.AspNetCore/UriTool.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ private static string GetCurrentIp(string preferredNetworks)
142142
// 获取所有可用网卡IP信息
143143
var ipCollection = nics?.Select(x => x.GetIPProperties())?.SelectMany(x => x.UnicastAddresses);
144144

145-
var preferredNetworksArr = preferredNetworks.Split(",");
145+
var preferredNetworksArr = string.IsNullOrEmpty(preferredNetworks)
146+
? new string[0] : preferredNetworks.Split(",");
146147
foreach (var ipadd in ipCollection)
147148
{
148149
if (!IPAddress.IsLoopback(ipadd.Address) &&

0 commit comments

Comments
 (0)