Skip to content

Commit 205f5a5

Browse files
KingPrimesKingPrimes
KingPrimes
authored and
KingPrimes
committed
feat(utils): 添加本地地址绕过代理的判断
- 在 shouldBypassProxy 函数中增加对 localhost 和 127.0.0.1 的判断 - 如果主机名是本地地址,则直接返回 true,无需代理
1 parent 1785495 commit 205f5a5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/com/nyx/bot/utils/http/ProxyUtils.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,10 @@ private static Proxy fromSpringConfig() {
240240

241241
public static boolean shouldBypassProxy(String host) {
242242
if (host == null) return true;
243-
243+
// 添加对本地地址(如 localhost、127.0.0.1)的判断
244+
if (host.equals("localhost") || host.equals("127.0.0.1")) {
245+
return true;
246+
}
244247
Set<String> noProxyHosts = getNoProxyHosts();
245248
for (String pattern : noProxyHosts) {
246249
if (pattern.startsWith(".") && host.endsWith(pattern)) {

0 commit comments

Comments
 (0)