Package dev.demeng.sentinel.client.util
Class PublicIp
java.lang.Object
dev.demeng.sentinel.client.util.PublicIp
Resolves the public IP address of the current machine by querying an external service.
This is useful as a workaround when the Sentinel server sits behind a reverse proxy that does
not forward the real client IP (e.g. missing X-Forwarded-For headers). The resolved
address can be passed to ValidationRequest.Builder.ip(String) so that
Sentinel sees the correct IP regardless of proxy configuration.
ValidationRequest request = ValidationRequest.builder()
.product("my-product")
.ip(PublicIp.resolve())
.build();
-
Method Summary
-
Method Details
-
resolve
Resolves the public IP address of the current machine.- Returns:
- the public IP address, or
nullif the lookup fails for any reason
-