mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-24 18:04:54 +08:00
fix bug
This commit is contained in:
parent
b2ce71d9c8
commit
e75f4617aa
@ -743,8 +743,8 @@ public class NetUtil {
|
|||||||
*/
|
*/
|
||||||
public static String getMultistageReverseProxyIp(String ip) {
|
public static String getMultistageReverseProxyIp(String ip) {
|
||||||
// 多级反向代理检测
|
// 多级反向代理检测
|
||||||
if (ip != null && ip.indexOf(",") > 0) {
|
if (ip != null && StrUtil.indexOf(ip, ',') > 0) {
|
||||||
final String[] ips = ip.trim().split(",");
|
final List<String> ips = StrUtil.splitTrim(ip, ',');
|
||||||
for (final String subIp : ips) {
|
for (final String subIp : ips) {
|
||||||
if (false == isUnknown(subIp)) {
|
if (false == isUnknown(subIp)) {
|
||||||
ip = subIp;
|
ip = subIp;
|
||||||
|
@ -112,4 +112,11 @@ public class NetUtilTest {
|
|||||||
Assert.assertFalse(NetUtil.isInRange("114.114.114.114","192.168.3.4/32"));
|
Assert.assertFalse(NetUtil.isInRange("114.114.114.114","192.168.3.4/32"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void issueI64P9JTest() {
|
||||||
|
// 获取结果应该去掉空格
|
||||||
|
final String ips = "unknown, 12.34.56.78, 23.45.67.89";
|
||||||
|
final String ip = NetUtil.getMultistageReverseProxyIp(ips);
|
||||||
|
Assert.assertEquals("12.34.56.78", ip);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user