Improved random ip generators.
This commit is contained in:
parent
f77179c3f1
commit
25e0fb5f64
@ -19,6 +19,7 @@
|
|||||||
package fr.devinsy.logar.app.anonymizer;
|
package fr.devinsy.logar.app.anonymizer;
|
||||||
|
|
||||||
import org.apache.commons.lang3.RandomUtils;
|
import org.apache.commons.lang3.RandomUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -236,13 +237,17 @@ public final class Ipv4Generator
|
|||||||
{
|
{
|
||||||
result = null;
|
result = null;
|
||||||
}
|
}
|
||||||
|
else if (StringUtils.equalsAny(ip, "0.0.0.0", "127.0.0.1"))
|
||||||
|
{
|
||||||
|
result = ip;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result = random(ip.length());
|
result = random(ip.length());
|
||||||
|
|
||||||
if (result.equals(ip))
|
while (StringUtils.equals(result, ip))
|
||||||
{
|
{
|
||||||
random(ip);
|
result = random(ip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
package fr.devinsy.logar.app.anonymizer;
|
package fr.devinsy.logar.app.anonymizer;
|
||||||
|
|
||||||
import org.apache.commons.lang3.RandomStringUtils;
|
import org.apache.commons.lang3.RandomStringUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -80,9 +81,9 @@ public final class Ipv6Generator
|
|||||||
}
|
}
|
||||||
result = buffer.toString();
|
result = buffer.toString();
|
||||||
|
|
||||||
if (result.equals(ip))
|
while (StringUtils.equals(result, ip))
|
||||||
{
|
{
|
||||||
random(ip);
|
result = random(ip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user