Skip to content

Commit 5b6c4b4

Browse files
authored
check if the provided ip address could be converted to an IPv4 address (eclipse#1627)
1 parent 928b1f2 commit 5b6c4b4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

server/src/main/java/org/eclipse/openvsx/ratelimit/CustomerService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ public Optional<Customer> getCustomerById(long id) {
5454

5555
public Optional<Customer> getCustomerByIpAddress(String ipAddress) {
5656
var ip = new IPAddressString(ipAddress).getAddress().toIPv4();
57+
if (ip == null) {
58+
logger.warn("Could not determine IP address from string {}", ipAddress);
59+
return Optional.empty();
60+
}
61+
5762
var node = customersByIPAddress.elementsContaining(ip);
5863
if (node != null) {
5964
return Optional.of(node.getValue());

0 commit comments

Comments
 (0)