mirror of https://github.com/GeyserMC/Geyser.git
Provide both proxy and real client ip
And add some minor javadocs
This commit is contained in:
parent
c9b2c1abe7
commit
45d8466f84
|
@ -38,9 +38,11 @@ public final class ConnectionRequestEvent implements Event, Cancellable {
|
|||
|
||||
private boolean cancelled;
|
||||
private final InetSocketAddress ip;
|
||||
private final InetSocketAddress proxyIp;
|
||||
|
||||
public ConnectionRequestEvent(@NonNull InetSocketAddress ip) {
|
||||
public ConnectionRequestEvent(@NonNull InetSocketAddress ip, @NonNull InetSocketAddress proxyIp) {
|
||||
this.ip = ip;
|
||||
this.proxyIp = proxyIp;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,13 +54,26 @@ public final class ConnectionRequestEvent implements Event, Cancellable {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return the cancel status of this event. If this event is cancelled, the connection will be rejected.
|
||||
* @return the IP address of the proxy handling the connection, if available, otherwise also the client IP.
|
||||
*/
|
||||
@NonNull
|
||||
public InetSocketAddress getProxyIp() {
|
||||
return proxyIp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the cancel status of this event. If this event is canceled, the connection will be rejected.
|
||||
*/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cancel status of this event. If this event is canceled, the connection will be rejected.
|
||||
*
|
||||
* @param cancelled the cancel status of this event.
|
||||
*/
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
|
|
|
@ -235,7 +235,7 @@ public final class GeyserServer {
|
|||
ip = "<IP address withheld>";
|
||||
}
|
||||
|
||||
ConnectionRequestEvent requestEvent = new ConnectionRequestEvent(inetSocketAddress);
|
||||
ConnectionRequestEvent requestEvent = new ConnectionRequestEvent(inetSocketAddress, this.proxiedAddresses.getOrDefault(inetSocketAddress, inetSocketAddress));
|
||||
geyser.eventBus().fire(requestEvent);
|
||||
if (requestEvent.isCancelled()) {
|
||||
geyser.getLogger().debug("Connection request from " + ip + " was cancelled using the API!");
|
||||
|
|
Loading…
Reference in New Issue