mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +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) {
|
||||
// 多级反向代理检测
|
||||
if (ip != null && ip.indexOf(",") > 0) {
|
||||
final String[] ips = ip.trim().split(",");
|
||||
if (ip != null && StrUtil.indexOf(ip, ',') > 0) {
|
||||
final List<String> ips = StrUtil.splitTrim(ip, ',');
|
||||
for (final String subIp : ips) {
|
||||
if (false == isUnknown(subIp)) {
|
||||
ip = subIp;
|
||||
|
@ -112,4 +112,11 @@ public class NetUtilTest {
|
||||
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…
x
Reference in New Issue
Block a user