mirror of
https://github.com/TuxCoding/FastLogin.git
synced 2025-07-31 11:17:33 +02:00
Fix finding the correct login sessions in Velocity
Velocity uses different objects during each login phase. Therefore, keys are no persistent. Only an internal variable is shared and exposed with `getConnection()`, but this method is not available in the API. We use `InetSocketAddress` objects until there is a better method for identifying sessions. Related #1297
This commit is contained in:
@ -354,6 +354,14 @@
|
|||||||
<version>v3.0.0</version>
|
<version>v3.0.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
|
|
||||||
|
<!-- Exclude dependencies to prevent potential version conflicts-->
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>*</groupId>
|
||||||
|
<artifactId>*</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--No maven repository :(-->
|
<!--No maven repository :(-->
|
||||||
|
@ -46,7 +46,6 @@ import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
|||||||
import com.velocitypowered.api.event.proxy.ProxyShutdownEvent;
|
import com.velocitypowered.api.event.proxy.ProxyShutdownEvent;
|
||||||
import com.velocitypowered.api.plugin.Plugin;
|
import com.velocitypowered.api.plugin.Plugin;
|
||||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||||
import com.velocitypowered.api.proxy.InboundConnection;
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
import com.velocitypowered.api.proxy.messages.ChannelMessageSink;
|
import com.velocitypowered.api.proxy.messages.ChannelMessageSink;
|
||||||
@ -58,6 +57,7 @@ import org.geysermc.geyser.GeyserImpl;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
@ -75,7 +75,7 @@ public class FastLoginVelocity implements PlatformPlugin<CommandSource> {
|
|||||||
private final ProxyServer server;
|
private final ProxyServer server;
|
||||||
private final Path dataDirectory;
|
private final Path dataDirectory;
|
||||||
private final Logger logger;
|
private final Logger logger;
|
||||||
private final ConcurrentMap<InboundConnection, VelocityLoginSession> session = new MapMaker().weakKeys().makeMap();
|
private final ConcurrentMap<InetSocketAddress, VelocityLoginSession> session = new MapMaker().weakKeys().makeMap();
|
||||||
private static final String PROXY_ID_FILE = "proxyId.txt";
|
private static final String PROXY_ID_FILE = "proxyId.txt";
|
||||||
|
|
||||||
private FastLoginCore<Player, CommandSource, FastLoginVelocity> core;
|
private FastLoginCore<Player, CommandSource, FastLoginVelocity> core;
|
||||||
@ -175,7 +175,7 @@ public class FastLoginVelocity implements PlatformPlugin<CommandSource> {
|
|||||||
return core;
|
return core;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConcurrentMap<InboundConnection, VelocityLoginSession> getSession() {
|
public ConcurrentMap<InetSocketAddress, VelocityLoginSession> getSession() {
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ public class ConnectListener {
|
|||||||
@Subscribe
|
@Subscribe
|
||||||
public void onGameProfileRequest(GameProfileRequestEvent event) {
|
public void onGameProfileRequest(GameProfileRequestEvent event) {
|
||||||
if (event.isOnlineMode()) {
|
if (event.isOnlineMode()) {
|
||||||
LoginSession session = plugin.getSession().get(event.getConnection());
|
LoginSession session = plugin.getSession().get(event.getConnection().getRemoteAddress());
|
||||||
if (session == null) {
|
if (session == null) {
|
||||||
plugin.getLog().error("No active login session found for onlinemode player {}", event.getUsername());
|
plugin.getLog().error("No active login session found for onlinemode player {}", event.getUsername());
|
||||||
return;
|
return;
|
||||||
@ -173,7 +173,7 @@ public class ConnectListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VelocityLoginSession session = plugin.getSession().get(player);
|
VelocityLoginSession session = plugin.getSession().get(player.getRemoteAddress());
|
||||||
if (session == null) {
|
if (session == null) {
|
||||||
plugin.getLog().info("No active login session found on server connect for {}", player);
|
plugin.getLog().info("No active login session found on server connect for {}", player);
|
||||||
return;
|
return;
|
||||||
@ -193,7 +193,7 @@ public class ConnectListener {
|
|||||||
Player player = disconnectEvent.getPlayer();
|
Player player = disconnectEvent.getPlayer();
|
||||||
plugin.getCore().getPendingConfirms().remove(player.getUniqueId());
|
plugin.getCore().getPendingConfirms().remove(player.getUniqueId());
|
||||||
|
|
||||||
plugin.getSession().remove(player);
|
plugin.getSession().remove(player.getRemoteAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -127,7 +127,7 @@ public class PluginMessageListener {
|
|||||||
if (shouldPersist) {
|
if (shouldPersist) {
|
||||||
//bukkit module successfully received and force logged in the user
|
//bukkit module successfully received and force logged in the user
|
||||||
//update only on success to prevent corrupt data
|
//update only on success to prevent corrupt data
|
||||||
VelocityLoginSession loginSession = plugin.getSession().get(forPlayer);
|
VelocityLoginSession loginSession = plugin.getSession().get(forPlayer.getRemoteAddress());
|
||||||
StoredProfile playerProfile = loginSession.getProfile();
|
StoredProfile playerProfile = loginSession.getProfile();
|
||||||
loginSession.setRegistered(true);
|
loginSession.setRegistered(true);
|
||||||
if (!loginSession.isAlreadySaved()) {
|
if (!loginSession.isAlreadySaved()) {
|
||||||
|
@ -58,7 +58,7 @@ public class AsyncPremiumCheck extends JoinManagement<Player, CommandSource, Vel
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
plugin.getSession().remove(connection);
|
plugin.getSession().remove(connection.getRemoteAddress());
|
||||||
super.onLogin(username, new VelocityLoginSource(connection, preLoginEvent));
|
super.onLogin(username, new VelocityLoginSource(connection, preLoginEvent));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +82,8 @@ public class AsyncPremiumCheck extends JoinManagement<Player, CommandSource, Vel
|
|||||||
String username, boolean registered) {
|
String username, boolean registered) {
|
||||||
source.enableOnlinemode();
|
source.enableOnlinemode();
|
||||||
VelocityLoginSession session = new VelocityLoginSession(username, registered, profile);
|
VelocityLoginSession session = new VelocityLoginSession(username, registered, profile);
|
||||||
plugin.getSession().put(source.getConnection(), session);
|
plugin.getLog().error("Putting session: {}", source.getConnection());
|
||||||
|
plugin.getSession().put(source.getConnection().getRemoteAddress(), session);
|
||||||
|
|
||||||
String ip = source.getAddress().getAddress().getHostAddress();
|
String ip = source.getAddress().getAddress().getHostAddress();
|
||||||
plugin.getCore().addLoginAttempt(ip, username);
|
plugin.getCore().addLoginAttempt(ip, username);
|
||||||
@ -91,6 +92,6 @@ public class AsyncPremiumCheck extends JoinManagement<Player, CommandSource, Vel
|
|||||||
@Override
|
@Override
|
||||||
public void startCrackedSession(VelocityLoginSource source, StoredProfile profile, String username) {
|
public void startCrackedSession(VelocityLoginSource source, StoredProfile profile, String username) {
|
||||||
VelocityLoginSession session = new VelocityLoginSession(username, false, profile);
|
VelocityLoginSession session = new VelocityLoginSession(username, false, profile);
|
||||||
plugin.getSession().put(source.getConnection(), session);
|
plugin.getSession().put(source.getConnection().getRemoteAddress(), session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ public class FloodgateAuthTask
|
|||||||
@Override
|
@Override
|
||||||
protected void startLogin() {
|
protected void startLogin() {
|
||||||
VelocityLoginSession session = new VelocityLoginSession(player.getUsername(), isRegistered, profile);
|
VelocityLoginSession session = new VelocityLoginSession(player.getUsername(), isRegistered, profile);
|
||||||
core.getPlugin().getSession().put(player, session);
|
core.getPlugin().getSession().put(player.getRemoteAddress(), session);
|
||||||
|
|
||||||
// enable auto login based on the value of 'autoLoginFloodgate' in config.yml
|
// enable auto login based on the value of 'autoLoginFloodgate' in config.yml
|
||||||
boolean forcedOnlineMode = autoLoginFloodgate.equals("true")
|
boolean forcedOnlineMode = autoLoginFloodgate.equals("true")
|
||||||
|
Reference in New Issue
Block a user