mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-09-30 12:25:51 +00:00
Improve performance for ip parse
This commit is contained in:
@@ -49,6 +49,11 @@ public class HostHelper {
|
||||
}
|
||||
|
||||
public static Optional<Inet4Address> parseIpv4(String host) {
|
||||
var potential = host.chars().allMatch(value -> Character.isDigit(value) || value == '.');
|
||||
if (!potential) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
Inet4Address inet4Address;
|
||||
try {
|
||||
inet4Address = Inet4Address.ofLiteral(host);
|
||||
|
||||
Reference in New Issue
Block a user