Skip to content

Commit

Permalink
本地地址可以是127.0.*,最多取5个地址,排序,避免多域名访问时,配置文件频繁改变
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Nov 15, 2024
1 parent 79f7a59 commit 195cfa3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Stardust.Extensions/TracerMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ public static void SaveServiceAddress(HttpContext ctx)
var p = host.LastIndexOf(':');
if (p >= 0) host = host[..p];
if (host.EqualIgnoreCase("127.0.0.1", "localhost", "[::1]")) return;
if (host.StartsWith("127.0.")) return;

var baseAddress = $"{uri.Scheme}://{uri.Authority}";

Expand All @@ -231,7 +232,7 @@ public static void SaveServiceAddress(HttpContext ctx)
ss = ss.Where(e => !e.EqualIgnoreCase("127.0.0.1", "localhost", "[::1]")).ToList();

ss.Insert(0, baseAddress);
set.ServiceAddress = ss.Take(3).Join(",");
set.ServiceAddress = ss.Take(5).OrderBy(e => e).Join(",");
set.Save();
}
}
Expand Down

0 comments on commit 195cfa3

Please sign in to comment.