Attempt to store HWID in temporary trace map and account variables.

This commit is contained in:
MobiusDevelopment
2020-10-16 09:28:40 +00:00
parent 9d7ddf9ea4
commit d77326f074
75 changed files with 2760 additions and 420 deletions

View File

@@ -158,13 +158,12 @@ RestartOnDeadlock = False
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Player HWID settings (DO NOT USE) # Player HWID settings
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Check if hardware information is sent upon login. # Check if hardware information is sent upon login.
# Players without hardware information are kicked from the game. # Players without hardware information are kicked from the game.
# WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true. # WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true.
# WARNING: The file system\HardWare.ini must be deleted each time the player logins.(?)
# Default: False # Default: False
EnableHardwareInfo = False EnableHardwareInfo = False

View File

@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.model.holders; package org.l2jmobius.gameserver.model.holders;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
/** /**
* @author Mobius * @author Mobius
*/ */
@@ -64,6 +67,77 @@ public class ClientHardwareInfoHolder
_vgaDriverVersion = vgaDriverVersion; _vgaDriverVersion = vgaDriverVersion;
} }
public ClientHardwareInfoHolder(String info)
{
final String[] split = info.split(AccountVariables.HWIDSLIT_VAR);
_macAddress = split[0];
_windowsPlatformId = Integer.valueOf(split[1]);
_windowsMajorVersion = Integer.valueOf(split[2]);
_windowsMinorVersion = Integer.valueOf(split[3]);
_windowsBuildNumber = Integer.valueOf(split[4]);
_directxVersion = Integer.valueOf(split[5]);
_directxRevision = Integer.valueOf(split[6]);
_cpuName = split[7];
_cpuSpeed = Integer.valueOf(split[8]);
_cpuCoreCount = Integer.valueOf(split[9]);
_vgaCount = Integer.valueOf(split[10]);
_vgaPcxSpeed = Integer.valueOf(split[11]);
_physMemorySlot1 = Integer.valueOf(split[12]);
_physMemorySlot2 = Integer.valueOf(split[13]);
_physMemorySlot3 = Integer.valueOf(split[14]);
_videoMemory = Integer.valueOf(split[15]);
_vgaVersion = Integer.valueOf(split[16]);
_vgaName = split[17];
_vgaDriverVersion = split[18];
}
/**
* Save hardware info to account variables for later use.
* @param player The PlayerInstance related with this hardware info.
*/
public void store(PlayerInstance player)
{
final StringBuilder sb = new StringBuilder();
sb.append(_macAddress);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsPlatformId);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsMajorVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsMinorVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsBuildNumber);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_directxVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_directxRevision);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuName);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuSpeed);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuCoreCount);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaCount);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaPcxSpeed);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot1);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot2);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot3);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_videoMemory);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaName);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaDriverVersion);
player.getAccountVariables().set(AccountVariables.HWID, sb.toString());
}
/** /**
* @return the macAddress * @return the macAddress
*/ */
@@ -215,4 +289,36 @@ public class ClientHardwareInfoHolder
{ {
return _vgaDriverVersion; return _vgaDriverVersion;
} }
@Override
public boolean equals(Object obj)
{
if (obj instanceof ClientHardwareInfoHolder)
{
final ClientHardwareInfoHolder info = (ClientHardwareInfoHolder) obj;
if ((_macAddress.equals(info.getMacAddress())) && //
(_windowsPlatformId == info.getWindowsPlatformId()) && //
(_windowsMajorVersion == info.getWindowsMajorVersion()) && //
(_windowsMinorVersion == info.getWindowsMinorVersion()) && //
(_windowsBuildNumber == info.getWindowsBuildNumber()) && //
(_directxVersion == info.getDirectxVersion()) && //
(_directxRevision == info.getDirectxRevision()) && //
(_cpuName.equals(info.getCpuName())) && //
(_cpuSpeed == info.getCpuSpeed()) && //
(_cpuCoreCount == info.getCpuCoreCount()) && //
(_vgaCount == info.getVgaCount()) && //
(_vgaPcxSpeed == info.getVgaPcxSpeed()) && //
(_physMemorySlot1 == info.getPhysMemorySlot1()) && //
(_physMemorySlot2 == info.getPhysMemorySlot2()) && //
(_physMemorySlot3 == info.getPhysMemorySlot3()) && //
(_videoMemory == info.getVideoMemory()) && //
(_vgaVersion == info.getVgaVersion()) && //
(_vgaName.equals(info.getVgaName())) && //
(_vgaDriverVersion.equals(info.getVgaDriverVersion())))
{
return true;
}
}
return false;
}
} }

View File

@@ -38,6 +38,10 @@ public class AccountVariables extends AbstractVariables
private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?"; private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?";
private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)"; private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)";
// Public variable names
public static final String HWID = "HWID";
public static final String HWIDSLIT_VAR = " ";
private final String _accountName; private final String _accountName;
public AccountVariables(String accountName) public AccountVariables(String accountName)

View File

@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
@@ -50,10 +53,12 @@ import org.l2jmobius.gameserver.model.entity.Fort;
import org.l2jmobius.gameserver.model.entity.FortSiege; import org.l2jmobius.gameserver.model.entity.FortSiege;
import org.l2jmobius.gameserver.model.entity.GameEvent; import org.l2jmobius.gameserver.model.entity.GameEvent;
import org.l2jmobius.gameserver.model.entity.Siege; import org.l2jmobius.gameserver.model.entity.Siege;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.quest.Quest; import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect; import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.ConnectionState; import org.l2jmobius.gameserver.network.ConnectionState;
@@ -110,7 +115,9 @@ import org.l2jmobius.gameserver.util.BuilderUtil;
*/ */
public class EnterWorld implements IClientIncomingPacket public class EnterWorld implements IClientIncomingPacket
{ {
private final int[][] tracert = new int[5][4]; private static final Map<String, ClientHardwareInfoHolder> TRACE_HWINFO = new ConcurrentHashMap<>();
private final int[][] _tracert = new int[5][4];
@Override @Override
public boolean read(GameClient client, PacketReader packet) public boolean read(GameClient client, PacketReader packet)
@@ -119,7 +126,7 @@ public class EnterWorld implements IClientIncomingPacket
{ {
for (int o = 0; o < 4; o++) for (int o = 0; o < 4; o++)
{ {
tracert[i][o] = packet.readC(); _tracert[i][o] = packet.readC();
} }
} }
packet.readD(); // Unknown Value packet.readD(); // Unknown Value
@@ -147,11 +154,11 @@ public class EnterWorld implements IClientIncomingPacket
final String[] adress = new String[5]; final String[] adress = new String[5];
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; adress[i] = _tracert[i][0] + "." + _tracert[i][1] + "." + _tracert[i][2] + "." + _tracert[i][3];
} }
LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress); LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress);
client.setClientTracert(tracert); client.setClientTracert(_tracert);
player.broadcastUserInfo(); player.broadcastUserInfo();
@@ -631,10 +638,69 @@ public class EnterWorld implements IClientIncomingPacket
{ {
ThreadPool.schedule(() -> ThreadPool.schedule(() ->
{ {
if (client.getHardwareInfo() == null) // Generate trace string.
final StringBuilder sb = new StringBuilder();
for (int[] i : _tracert)
{ {
Disconnection.of(client).defaultSequence(false); for (int j : i)
return; {
sb.append(j);
sb.append(".");
}
}
final String trace = sb.toString();
// Get hardware info from client.
ClientHardwareInfoHolder hwInfo = client.getHardwareInfo();
if (hwInfo != null)
{
hwInfo.store(player);
TRACE_HWINFO.put(trace, hwInfo);
}
else
{
// Get hardware info from stored tracert map.
hwInfo = TRACE_HWINFO.get(trace);
if (hwInfo != null)
{
hwInfo.store(player);
client.setHardwareInfo(hwInfo);
}
// Get hardware info from account variables.
else
{
final String storedInfo = player.getAccountVariables().getString(AccountVariables.HWID, "");
if (!storedInfo.isEmpty())
{
hwInfo = new ClientHardwareInfoHolder(storedInfo);
TRACE_HWINFO.put(trace, hwInfo);
client.setHardwareInfo(hwInfo);
}
}
}
// Check max players.
if (Config.MAX_PLAYERS_PER_HWID > 0)
{
if (hwInfo == null)
{
Disconnection.of(client).defaultSequence(false);
}
else
{
int count = 0;
for (PlayerInstance plr : World.getInstance().getPlayers())
{
if ((plr.isOnlineInt() == 1) && (plr.getClient().getHardwareInfo().equals(hwInfo)))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
Disconnection.of(client).defaultSequence(false);
}
}
} }
}, 5000); }, 5000);
} }

View File

@@ -16,12 +16,8 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.GameClient; import org.l2jmobius.gameserver.network.GameClient;
/** /**
@@ -82,20 +78,5 @@ public class RequestHardWareInfo implements IClientIncomingPacket
public void run(GameClient client) public void run(GameClient client)
{ {
client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion)); client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion));
if (Config.HARDWARE_INFO_ENABLED && (Config.MAX_PLAYERS_PER_HWID > 0))
{
int count = 0;
for (PlayerInstance player : World.getInstance().getPlayers())
{
if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo())))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
Disconnection.of(client).defaultSequence(false);
}
}
} }
} }

View File

@@ -158,13 +158,12 @@ RestartOnDeadlock = False
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Player HWID settings (DO NOT USE) # Player HWID settings
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Check if hardware information is sent upon login. # Check if hardware information is sent upon login.
# Players without hardware information are kicked from the game. # Players without hardware information are kicked from the game.
# WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true. # WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true.
# WARNING: The file system\HardWare.ini must be deleted each time the player logins.(?)
# Default: False # Default: False
EnableHardwareInfo = False EnableHardwareInfo = False

View File

@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.model.holders; package org.l2jmobius.gameserver.model.holders;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
/** /**
* @author Mobius * @author Mobius
*/ */
@@ -64,6 +67,77 @@ public class ClientHardwareInfoHolder
_vgaDriverVersion = vgaDriverVersion; _vgaDriverVersion = vgaDriverVersion;
} }
public ClientHardwareInfoHolder(String info)
{
final String[] split = info.split(AccountVariables.HWIDSLIT_VAR);
_macAddress = split[0];
_windowsPlatformId = Integer.valueOf(split[1]);
_windowsMajorVersion = Integer.valueOf(split[2]);
_windowsMinorVersion = Integer.valueOf(split[3]);
_windowsBuildNumber = Integer.valueOf(split[4]);
_directxVersion = Integer.valueOf(split[5]);
_directxRevision = Integer.valueOf(split[6]);
_cpuName = split[7];
_cpuSpeed = Integer.valueOf(split[8]);
_cpuCoreCount = Integer.valueOf(split[9]);
_vgaCount = Integer.valueOf(split[10]);
_vgaPcxSpeed = Integer.valueOf(split[11]);
_physMemorySlot1 = Integer.valueOf(split[12]);
_physMemorySlot2 = Integer.valueOf(split[13]);
_physMemorySlot3 = Integer.valueOf(split[14]);
_videoMemory = Integer.valueOf(split[15]);
_vgaVersion = Integer.valueOf(split[16]);
_vgaName = split[17];
_vgaDriverVersion = split[18];
}
/**
* Save hardware info to account variables for later use.
* @param player The PlayerInstance related with this hardware info.
*/
public void store(PlayerInstance player)
{
final StringBuilder sb = new StringBuilder();
sb.append(_macAddress);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsPlatformId);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsMajorVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsMinorVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsBuildNumber);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_directxVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_directxRevision);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuName);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuSpeed);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuCoreCount);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaCount);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaPcxSpeed);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot1);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot2);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot3);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_videoMemory);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaName);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaDriverVersion);
player.getAccountVariables().set(AccountVariables.HWID, sb.toString());
}
/** /**
* @return the macAddress * @return the macAddress
*/ */
@@ -215,4 +289,36 @@ public class ClientHardwareInfoHolder
{ {
return _vgaDriverVersion; return _vgaDriverVersion;
} }
@Override
public boolean equals(Object obj)
{
if (obj instanceof ClientHardwareInfoHolder)
{
final ClientHardwareInfoHolder info = (ClientHardwareInfoHolder) obj;
if ((_macAddress.equals(info.getMacAddress())) && //
(_windowsPlatformId == info.getWindowsPlatformId()) && //
(_windowsMajorVersion == info.getWindowsMajorVersion()) && //
(_windowsMinorVersion == info.getWindowsMinorVersion()) && //
(_windowsBuildNumber == info.getWindowsBuildNumber()) && //
(_directxVersion == info.getDirectxVersion()) && //
(_directxRevision == info.getDirectxRevision()) && //
(_cpuName.equals(info.getCpuName())) && //
(_cpuSpeed == info.getCpuSpeed()) && //
(_cpuCoreCount == info.getCpuCoreCount()) && //
(_vgaCount == info.getVgaCount()) && //
(_vgaPcxSpeed == info.getVgaPcxSpeed()) && //
(_physMemorySlot1 == info.getPhysMemorySlot1()) && //
(_physMemorySlot2 == info.getPhysMemorySlot2()) && //
(_physMemorySlot3 == info.getPhysMemorySlot3()) && //
(_videoMemory == info.getVideoMemory()) && //
(_vgaVersion == info.getVgaVersion()) && //
(_vgaName.equals(info.getVgaName())) && //
(_vgaDriverVersion.equals(info.getVgaDriverVersion())))
{
return true;
}
}
return false;
}
} }

View File

@@ -38,6 +38,10 @@ public class AccountVariables extends AbstractVariables
private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?"; private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?";
private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)"; private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)";
// Public variable names
public static final String HWID = "HWID";
public static final String HWIDSLIT_VAR = " ";
private final String _accountName; private final String _accountName;
public AccountVariables(String accountName) public AccountVariables(String accountName)

View File

@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
@@ -51,10 +54,12 @@ import org.l2jmobius.gameserver.model.entity.FortSiege;
import org.l2jmobius.gameserver.model.entity.GameEvent; import org.l2jmobius.gameserver.model.entity.GameEvent;
import org.l2jmobius.gameserver.model.entity.Siege; import org.l2jmobius.gameserver.model.entity.Siege;
import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder; import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.quest.Quest; import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect; import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.ConnectionState; import org.l2jmobius.gameserver.network.ConnectionState;
@@ -115,7 +120,9 @@ import org.l2jmobius.gameserver.util.BuilderUtil;
*/ */
public class EnterWorld implements IClientIncomingPacket public class EnterWorld implements IClientIncomingPacket
{ {
private final int[][] tracert = new int[5][4]; private static final Map<String, ClientHardwareInfoHolder> TRACE_HWINFO = new ConcurrentHashMap<>();
private final int[][] _tracert = new int[5][4];
@Override @Override
public boolean read(GameClient client, PacketReader packet) public boolean read(GameClient client, PacketReader packet)
@@ -124,7 +131,7 @@ public class EnterWorld implements IClientIncomingPacket
{ {
for (int o = 0; o < 4; o++) for (int o = 0; o < 4; o++)
{ {
tracert[i][o] = packet.readC(); _tracert[i][o] = packet.readC();
} }
} }
packet.readD(); // Unknown Value packet.readD(); // Unknown Value
@@ -152,11 +159,11 @@ public class EnterWorld implements IClientIncomingPacket
final String[] adress = new String[5]; final String[] adress = new String[5];
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; adress[i] = _tracert[i][0] + "." + _tracert[i][1] + "." + _tracert[i][2] + "." + _tracert[i][3];
} }
LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress); LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress);
client.setClientTracert(tracert); client.setClientTracert(_tracert);
player.broadcastUserInfo(); player.broadcastUserInfo();
@@ -664,10 +671,69 @@ public class EnterWorld implements IClientIncomingPacket
{ {
ThreadPool.schedule(() -> ThreadPool.schedule(() ->
{ {
if (client.getHardwareInfo() == null) // Generate trace string.
final StringBuilder sb = new StringBuilder();
for (int[] i : _tracert)
{ {
Disconnection.of(client).defaultSequence(false); for (int j : i)
return; {
sb.append(j);
sb.append(".");
}
}
final String trace = sb.toString();
// Get hardware info from client.
ClientHardwareInfoHolder hwInfo = client.getHardwareInfo();
if (hwInfo != null)
{
hwInfo.store(player);
TRACE_HWINFO.put(trace, hwInfo);
}
else
{
// Get hardware info from stored tracert map.
hwInfo = TRACE_HWINFO.get(trace);
if (hwInfo != null)
{
hwInfo.store(player);
client.setHardwareInfo(hwInfo);
}
// Get hardware info from account variables.
else
{
final String storedInfo = player.getAccountVariables().getString(AccountVariables.HWID, "");
if (!storedInfo.isEmpty())
{
hwInfo = new ClientHardwareInfoHolder(storedInfo);
TRACE_HWINFO.put(trace, hwInfo);
client.setHardwareInfo(hwInfo);
}
}
}
// Check max players.
if (Config.MAX_PLAYERS_PER_HWID > 0)
{
if (hwInfo == null)
{
Disconnection.of(client).defaultSequence(false);
}
else
{
int count = 0;
for (PlayerInstance plr : World.getInstance().getPlayers())
{
if ((plr.isOnlineInt() == 1) && (plr.getClient().getHardwareInfo().equals(hwInfo)))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
Disconnection.of(client).defaultSequence(false);
}
}
} }
}, 5000); }, 5000);
} }

View File

@@ -16,12 +16,8 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.GameClient; import org.l2jmobius.gameserver.network.GameClient;
/** /**
@@ -82,20 +78,5 @@ public class RequestHardWareInfo implements IClientIncomingPacket
public void run(GameClient client) public void run(GameClient client)
{ {
client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion)); client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion));
if (Config.HARDWARE_INFO_ENABLED && (Config.MAX_PLAYERS_PER_HWID > 0))
{
int count = 0;
for (PlayerInstance player : World.getInstance().getPlayers())
{
if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo())))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
Disconnection.of(client).defaultSequence(false);
}
}
} }
} }

View File

@@ -158,13 +158,12 @@ RestartOnDeadlock = False
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Player HWID settings (DO NOT USE) # Player HWID settings
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Check if hardware information is sent upon login. # Check if hardware information is sent upon login.
# Players without hardware information are kicked from the game. # Players without hardware information are kicked from the game.
# WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true. # WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true.
# WARNING: The file system\HardWare.ini must be deleted each time the player logins.(?)
# Default: False # Default: False
EnableHardwareInfo = False EnableHardwareInfo = False

View File

@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.model.holders; package org.l2jmobius.gameserver.model.holders;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
/** /**
* @author Mobius * @author Mobius
*/ */
@@ -64,6 +67,77 @@ public class ClientHardwareInfoHolder
_vgaDriverVersion = vgaDriverVersion; _vgaDriverVersion = vgaDriverVersion;
} }
public ClientHardwareInfoHolder(String info)
{
final String[] split = info.split(AccountVariables.HWIDSLIT_VAR);
_macAddress = split[0];
_windowsPlatformId = Integer.valueOf(split[1]);
_windowsMajorVersion = Integer.valueOf(split[2]);
_windowsMinorVersion = Integer.valueOf(split[3]);
_windowsBuildNumber = Integer.valueOf(split[4]);
_directxVersion = Integer.valueOf(split[5]);
_directxRevision = Integer.valueOf(split[6]);
_cpuName = split[7];
_cpuSpeed = Integer.valueOf(split[8]);
_cpuCoreCount = Integer.valueOf(split[9]);
_vgaCount = Integer.valueOf(split[10]);
_vgaPcxSpeed = Integer.valueOf(split[11]);
_physMemorySlot1 = Integer.valueOf(split[12]);
_physMemorySlot2 = Integer.valueOf(split[13]);
_physMemorySlot3 = Integer.valueOf(split[14]);
_videoMemory = Integer.valueOf(split[15]);
_vgaVersion = Integer.valueOf(split[16]);
_vgaName = split[17];
_vgaDriverVersion = split[18];
}
/**
* Save hardware info to account variables for later use.
* @param player The PlayerInstance related with this hardware info.
*/
public void store(PlayerInstance player)
{
final StringBuilder sb = new StringBuilder();
sb.append(_macAddress);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsPlatformId);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsMajorVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsMinorVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsBuildNumber);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_directxVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_directxRevision);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuName);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuSpeed);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuCoreCount);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaCount);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaPcxSpeed);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot1);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot2);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot3);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_videoMemory);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaName);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaDriverVersion);
player.getAccountVariables().set(AccountVariables.HWID, sb.toString());
}
/** /**
* @return the macAddress * @return the macAddress
*/ */
@@ -215,4 +289,36 @@ public class ClientHardwareInfoHolder
{ {
return _vgaDriverVersion; return _vgaDriverVersion;
} }
@Override
public boolean equals(Object obj)
{
if (obj instanceof ClientHardwareInfoHolder)
{
final ClientHardwareInfoHolder info = (ClientHardwareInfoHolder) obj;
if ((_macAddress.equals(info.getMacAddress())) && //
(_windowsPlatformId == info.getWindowsPlatformId()) && //
(_windowsMajorVersion == info.getWindowsMajorVersion()) && //
(_windowsMinorVersion == info.getWindowsMinorVersion()) && //
(_windowsBuildNumber == info.getWindowsBuildNumber()) && //
(_directxVersion == info.getDirectxVersion()) && //
(_directxRevision == info.getDirectxRevision()) && //
(_cpuName.equals(info.getCpuName())) && //
(_cpuSpeed == info.getCpuSpeed()) && //
(_cpuCoreCount == info.getCpuCoreCount()) && //
(_vgaCount == info.getVgaCount()) && //
(_vgaPcxSpeed == info.getVgaPcxSpeed()) && //
(_physMemorySlot1 == info.getPhysMemorySlot1()) && //
(_physMemorySlot2 == info.getPhysMemorySlot2()) && //
(_physMemorySlot3 == info.getPhysMemorySlot3()) && //
(_videoMemory == info.getVideoMemory()) && //
(_vgaVersion == info.getVgaVersion()) && //
(_vgaName.equals(info.getVgaName())) && //
(_vgaDriverVersion.equals(info.getVgaDriverVersion())))
{
return true;
}
}
return false;
}
} }

View File

@@ -38,6 +38,10 @@ public class AccountVariables extends AbstractVariables
private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?"; private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?";
private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)"; private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)";
// Public variable names
public static final String HWID = "HWID";
public static final String HWIDSLIT_VAR = " ";
private final String _accountName; private final String _accountName;
public AccountVariables(String accountName) public AccountVariables(String accountName)

View File

@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
@@ -51,10 +54,12 @@ import org.l2jmobius.gameserver.model.entity.FortSiege;
import org.l2jmobius.gameserver.model.entity.GameEvent; import org.l2jmobius.gameserver.model.entity.GameEvent;
import org.l2jmobius.gameserver.model.entity.Siege; import org.l2jmobius.gameserver.model.entity.Siege;
import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder; import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.quest.Quest; import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect; import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.ConnectionState; import org.l2jmobius.gameserver.network.ConnectionState;
@@ -115,7 +120,9 @@ import org.l2jmobius.gameserver.util.BuilderUtil;
*/ */
public class EnterWorld implements IClientIncomingPacket public class EnterWorld implements IClientIncomingPacket
{ {
private final int[][] tracert = new int[5][4]; private static final Map<String, ClientHardwareInfoHolder> TRACE_HWINFO = new ConcurrentHashMap<>();
private final int[][] _tracert = new int[5][4];
@Override @Override
public boolean read(GameClient client, PacketReader packet) public boolean read(GameClient client, PacketReader packet)
@@ -124,7 +131,7 @@ public class EnterWorld implements IClientIncomingPacket
{ {
for (int o = 0; o < 4; o++) for (int o = 0; o < 4; o++)
{ {
tracert[i][o] = packet.readC(); _tracert[i][o] = packet.readC();
} }
} }
packet.readD(); // Unknown Value packet.readD(); // Unknown Value
@@ -152,11 +159,11 @@ public class EnterWorld implements IClientIncomingPacket
final String[] adress = new String[5]; final String[] adress = new String[5];
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; adress[i] = _tracert[i][0] + "." + _tracert[i][1] + "." + _tracert[i][2] + "." + _tracert[i][3];
} }
LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress); LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress);
client.setClientTracert(tracert); client.setClientTracert(_tracert);
player.broadcastUserInfo(); player.broadcastUserInfo();
@@ -664,10 +671,69 @@ public class EnterWorld implements IClientIncomingPacket
{ {
ThreadPool.schedule(() -> ThreadPool.schedule(() ->
{ {
if (client.getHardwareInfo() == null) // Generate trace string.
final StringBuilder sb = new StringBuilder();
for (int[] i : _tracert)
{ {
Disconnection.of(client).defaultSequence(false); for (int j : i)
return; {
sb.append(j);
sb.append(".");
}
}
final String trace = sb.toString();
// Get hardware info from client.
ClientHardwareInfoHolder hwInfo = client.getHardwareInfo();
if (hwInfo != null)
{
hwInfo.store(player);
TRACE_HWINFO.put(trace, hwInfo);
}
else
{
// Get hardware info from stored tracert map.
hwInfo = TRACE_HWINFO.get(trace);
if (hwInfo != null)
{
hwInfo.store(player);
client.setHardwareInfo(hwInfo);
}
// Get hardware info from account variables.
else
{
final String storedInfo = player.getAccountVariables().getString(AccountVariables.HWID, "");
if (!storedInfo.isEmpty())
{
hwInfo = new ClientHardwareInfoHolder(storedInfo);
TRACE_HWINFO.put(trace, hwInfo);
client.setHardwareInfo(hwInfo);
}
}
}
// Check max players.
if (Config.MAX_PLAYERS_PER_HWID > 0)
{
if (hwInfo == null)
{
Disconnection.of(client).defaultSequence(false);
}
else
{
int count = 0;
for (PlayerInstance plr : World.getInstance().getPlayers())
{
if ((plr.isOnlineInt() == 1) && (plr.getClient().getHardwareInfo().equals(hwInfo)))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
Disconnection.of(client).defaultSequence(false);
}
}
} }
}, 5000); }, 5000);
} }

View File

@@ -16,12 +16,8 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.GameClient; import org.l2jmobius.gameserver.network.GameClient;
/** /**
@@ -82,20 +78,5 @@ public class RequestHardWareInfo implements IClientIncomingPacket
public void run(GameClient client) public void run(GameClient client)
{ {
client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion)); client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion));
if (Config.HARDWARE_INFO_ENABLED && (Config.MAX_PLAYERS_PER_HWID > 0))
{
int count = 0;
for (PlayerInstance player : World.getInstance().getPlayers())
{
if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo())))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
Disconnection.of(client).defaultSequence(false);
}
}
} }
} }

View File

@@ -158,13 +158,12 @@ RestartOnDeadlock = False
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Player HWID settings (DO NOT USE) # Player HWID settings
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Check if hardware information is sent upon login. # Check if hardware information is sent upon login.
# Players without hardware information are kicked from the game. # Players without hardware information are kicked from the game.
# WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true. # WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true.
# WARNING: The file system\HardWare.ini must be deleted each time the player logins.(?)
# Default: False # Default: False
EnableHardwareInfo = False EnableHardwareInfo = False

View File

@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.model.holders; package org.l2jmobius.gameserver.model.holders;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
/** /**
* @author Mobius * @author Mobius
*/ */
@@ -64,6 +67,77 @@ public class ClientHardwareInfoHolder
_vgaDriverVersion = vgaDriverVersion; _vgaDriverVersion = vgaDriverVersion;
} }
public ClientHardwareInfoHolder(String info)
{
final String[] split = info.split(AccountVariables.HWIDSLIT_VAR);
_macAddress = split[0];
_windowsPlatformId = Integer.valueOf(split[1]);
_windowsMajorVersion = Integer.valueOf(split[2]);
_windowsMinorVersion = Integer.valueOf(split[3]);
_windowsBuildNumber = Integer.valueOf(split[4]);
_directxVersion = Integer.valueOf(split[5]);
_directxRevision = Integer.valueOf(split[6]);
_cpuName = split[7];
_cpuSpeed = Integer.valueOf(split[8]);
_cpuCoreCount = Integer.valueOf(split[9]);
_vgaCount = Integer.valueOf(split[10]);
_vgaPcxSpeed = Integer.valueOf(split[11]);
_physMemorySlot1 = Integer.valueOf(split[12]);
_physMemorySlot2 = Integer.valueOf(split[13]);
_physMemorySlot3 = Integer.valueOf(split[14]);
_videoMemory = Integer.valueOf(split[15]);
_vgaVersion = Integer.valueOf(split[16]);
_vgaName = split[17];
_vgaDriverVersion = split[18];
}
/**
* Save hardware info to account variables for later use.
* @param player The PlayerInstance related with this hardware info.
*/
public void store(PlayerInstance player)
{
final StringBuilder sb = new StringBuilder();
sb.append(_macAddress);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsPlatformId);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsMajorVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsMinorVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsBuildNumber);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_directxVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_directxRevision);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuName);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuSpeed);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuCoreCount);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaCount);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaPcxSpeed);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot1);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot2);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot3);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_videoMemory);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaName);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaDriverVersion);
player.getAccountVariables().set(AccountVariables.HWID, sb.toString());
}
/** /**
* @return the macAddress * @return the macAddress
*/ */
@@ -215,4 +289,36 @@ public class ClientHardwareInfoHolder
{ {
return _vgaDriverVersion; return _vgaDriverVersion;
} }
@Override
public boolean equals(Object obj)
{
if (obj instanceof ClientHardwareInfoHolder)
{
final ClientHardwareInfoHolder info = (ClientHardwareInfoHolder) obj;
if ((_macAddress.equals(info.getMacAddress())) && //
(_windowsPlatformId == info.getWindowsPlatformId()) && //
(_windowsMajorVersion == info.getWindowsMajorVersion()) && //
(_windowsMinorVersion == info.getWindowsMinorVersion()) && //
(_windowsBuildNumber == info.getWindowsBuildNumber()) && //
(_directxVersion == info.getDirectxVersion()) && //
(_directxRevision == info.getDirectxRevision()) && //
(_cpuName.equals(info.getCpuName())) && //
(_cpuSpeed == info.getCpuSpeed()) && //
(_cpuCoreCount == info.getCpuCoreCount()) && //
(_vgaCount == info.getVgaCount()) && //
(_vgaPcxSpeed == info.getVgaPcxSpeed()) && //
(_physMemorySlot1 == info.getPhysMemorySlot1()) && //
(_physMemorySlot2 == info.getPhysMemorySlot2()) && //
(_physMemorySlot3 == info.getPhysMemorySlot3()) && //
(_videoMemory == info.getVideoMemory()) && //
(_vgaVersion == info.getVgaVersion()) && //
(_vgaName.equals(info.getVgaName())) && //
(_vgaDriverVersion.equals(info.getVgaDriverVersion())))
{
return true;
}
}
return false;
}
} }

View File

@@ -38,6 +38,10 @@ public class AccountVariables extends AbstractVariables
private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?"; private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?";
private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)"; private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)";
// Public variable names
public static final String HWID = "HWID";
public static final String HWIDSLIT_VAR = " ";
private final String _accountName; private final String _accountName;
public AccountVariables(String accountName) public AccountVariables(String accountName)

View File

@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
@@ -51,10 +54,12 @@ import org.l2jmobius.gameserver.model.entity.FortSiege;
import org.l2jmobius.gameserver.model.entity.GameEvent; import org.l2jmobius.gameserver.model.entity.GameEvent;
import org.l2jmobius.gameserver.model.entity.Siege; import org.l2jmobius.gameserver.model.entity.Siege;
import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder; import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.quest.Quest; import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect; import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.ConnectionState; import org.l2jmobius.gameserver.network.ConnectionState;
@@ -115,7 +120,9 @@ import org.l2jmobius.gameserver.util.BuilderUtil;
*/ */
public class EnterWorld implements IClientIncomingPacket public class EnterWorld implements IClientIncomingPacket
{ {
private final int[][] tracert = new int[5][4]; private static final Map<String, ClientHardwareInfoHolder> TRACE_HWINFO = new ConcurrentHashMap<>();
private final int[][] _tracert = new int[5][4];
@Override @Override
public boolean read(GameClient client, PacketReader packet) public boolean read(GameClient client, PacketReader packet)
@@ -124,7 +131,7 @@ public class EnterWorld implements IClientIncomingPacket
{ {
for (int o = 0; o < 4; o++) for (int o = 0; o < 4; o++)
{ {
tracert[i][o] = packet.readC(); _tracert[i][o] = packet.readC();
} }
} }
packet.readD(); // Unknown Value packet.readD(); // Unknown Value
@@ -152,11 +159,11 @@ public class EnterWorld implements IClientIncomingPacket
final String[] adress = new String[5]; final String[] adress = new String[5];
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; adress[i] = _tracert[i][0] + "." + _tracert[i][1] + "." + _tracert[i][2] + "." + _tracert[i][3];
} }
LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress); LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress);
client.setClientTracert(tracert); client.setClientTracert(_tracert);
player.broadcastUserInfo(); player.broadcastUserInfo();
@@ -664,10 +671,69 @@ public class EnterWorld implements IClientIncomingPacket
{ {
ThreadPool.schedule(() -> ThreadPool.schedule(() ->
{ {
if (client.getHardwareInfo() == null) // Generate trace string.
final StringBuilder sb = new StringBuilder();
for (int[] i : _tracert)
{ {
Disconnection.of(client).defaultSequence(false); for (int j : i)
return; {
sb.append(j);
sb.append(".");
}
}
final String trace = sb.toString();
// Get hardware info from client.
ClientHardwareInfoHolder hwInfo = client.getHardwareInfo();
if (hwInfo != null)
{
hwInfo.store(player);
TRACE_HWINFO.put(trace, hwInfo);
}
else
{
// Get hardware info from stored tracert map.
hwInfo = TRACE_HWINFO.get(trace);
if (hwInfo != null)
{
hwInfo.store(player);
client.setHardwareInfo(hwInfo);
}
// Get hardware info from account variables.
else
{
final String storedInfo = player.getAccountVariables().getString(AccountVariables.HWID, "");
if (!storedInfo.isEmpty())
{
hwInfo = new ClientHardwareInfoHolder(storedInfo);
TRACE_HWINFO.put(trace, hwInfo);
client.setHardwareInfo(hwInfo);
}
}
}
// Check max players.
if (Config.MAX_PLAYERS_PER_HWID > 0)
{
if (hwInfo == null)
{
Disconnection.of(client).defaultSequence(false);
}
else
{
int count = 0;
for (PlayerInstance plr : World.getInstance().getPlayers())
{
if ((plr.isOnlineInt() == 1) && (plr.getClient().getHardwareInfo().equals(hwInfo)))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
Disconnection.of(client).defaultSequence(false);
}
}
} }
}, 5000); }, 5000);
} }

View File

@@ -16,12 +16,8 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.GameClient; import org.l2jmobius.gameserver.network.GameClient;
/** /**
@@ -82,20 +78,5 @@ public class RequestHardWareInfo implements IClientIncomingPacket
public void run(GameClient client) public void run(GameClient client)
{ {
client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion)); client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion));
if (Config.HARDWARE_INFO_ENABLED && (Config.MAX_PLAYERS_PER_HWID > 0))
{
int count = 0;
for (PlayerInstance player : World.getInstance().getPlayers())
{
if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo())))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
Disconnection.of(client).defaultSequence(false);
}
}
} }
} }

View File

@@ -158,13 +158,12 @@ RestartOnDeadlock = False
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Player HWID settings (DO NOT USE) # Player HWID settings
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Check if hardware information is sent upon login. # Check if hardware information is sent upon login.
# Players without hardware information are kicked from the game. # Players without hardware information are kicked from the game.
# WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true. # WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true.
# WARNING: The file system\HardWare.ini must be deleted each time the player logins.(?)
# Default: False # Default: False
EnableHardwareInfo = False EnableHardwareInfo = False

View File

@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.model.holders; package org.l2jmobius.gameserver.model.holders;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
/** /**
* @author Mobius * @author Mobius
*/ */
@@ -64,6 +67,77 @@ public class ClientHardwareInfoHolder
_vgaDriverVersion = vgaDriverVersion; _vgaDriverVersion = vgaDriverVersion;
} }
public ClientHardwareInfoHolder(String info)
{
final String[] split = info.split(AccountVariables.HWIDSLIT_VAR);
_macAddress = split[0];
_windowsPlatformId = Integer.valueOf(split[1]);
_windowsMajorVersion = Integer.valueOf(split[2]);
_windowsMinorVersion = Integer.valueOf(split[3]);
_windowsBuildNumber = Integer.valueOf(split[4]);
_directxVersion = Integer.valueOf(split[5]);
_directxRevision = Integer.valueOf(split[6]);
_cpuName = split[7];
_cpuSpeed = Integer.valueOf(split[8]);
_cpuCoreCount = Integer.valueOf(split[9]);
_vgaCount = Integer.valueOf(split[10]);
_vgaPcxSpeed = Integer.valueOf(split[11]);
_physMemorySlot1 = Integer.valueOf(split[12]);
_physMemorySlot2 = Integer.valueOf(split[13]);
_physMemorySlot3 = Integer.valueOf(split[14]);
_videoMemory = Integer.valueOf(split[15]);
_vgaVersion = Integer.valueOf(split[16]);
_vgaName = split[17];
_vgaDriverVersion = split[18];
}
/**
* Save hardware info to account variables for later use.
* @param player The PlayerInstance related with this hardware info.
*/
public void store(PlayerInstance player)
{
final StringBuilder sb = new StringBuilder();
sb.append(_macAddress);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsPlatformId);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsMajorVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsMinorVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsBuildNumber);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_directxVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_directxRevision);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuName);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuSpeed);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuCoreCount);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaCount);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaPcxSpeed);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot1);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot2);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot3);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_videoMemory);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaName);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaDriverVersion);
player.getAccountVariables().set(AccountVariables.HWID, sb.toString());
}
/** /**
* @return the macAddress * @return the macAddress
*/ */
@@ -215,4 +289,36 @@ public class ClientHardwareInfoHolder
{ {
return _vgaDriverVersion; return _vgaDriverVersion;
} }
@Override
public boolean equals(Object obj)
{
if (obj instanceof ClientHardwareInfoHolder)
{
final ClientHardwareInfoHolder info = (ClientHardwareInfoHolder) obj;
if ((_macAddress.equals(info.getMacAddress())) && //
(_windowsPlatformId == info.getWindowsPlatformId()) && //
(_windowsMajorVersion == info.getWindowsMajorVersion()) && //
(_windowsMinorVersion == info.getWindowsMinorVersion()) && //
(_windowsBuildNumber == info.getWindowsBuildNumber()) && //
(_directxVersion == info.getDirectxVersion()) && //
(_directxRevision == info.getDirectxRevision()) && //
(_cpuName.equals(info.getCpuName())) && //
(_cpuSpeed == info.getCpuSpeed()) && //
(_cpuCoreCount == info.getCpuCoreCount()) && //
(_vgaCount == info.getVgaCount()) && //
(_vgaPcxSpeed == info.getVgaPcxSpeed()) && //
(_physMemorySlot1 == info.getPhysMemorySlot1()) && //
(_physMemorySlot2 == info.getPhysMemorySlot2()) && //
(_physMemorySlot3 == info.getPhysMemorySlot3()) && //
(_videoMemory == info.getVideoMemory()) && //
(_vgaVersion == info.getVgaVersion()) && //
(_vgaName.equals(info.getVgaName())) && //
(_vgaDriverVersion.equals(info.getVgaDriverVersion())))
{
return true;
}
}
return false;
}
} }

View File

@@ -38,6 +38,10 @@ public class AccountVariables extends AbstractVariables
private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?"; private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?";
private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)"; private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)";
// Public variable names
public static final String HWID = "HWID";
public static final String HWIDSLIT_VAR = " ";
private final String _accountName; private final String _accountName;
public AccountVariables(String accountName) public AccountVariables(String accountName)

View File

@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
@@ -51,10 +54,12 @@ import org.l2jmobius.gameserver.model.entity.FortSiege;
import org.l2jmobius.gameserver.model.entity.GameEvent; import org.l2jmobius.gameserver.model.entity.GameEvent;
import org.l2jmobius.gameserver.model.entity.Siege; import org.l2jmobius.gameserver.model.entity.Siege;
import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder; import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.quest.Quest; import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect; import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.ConnectionState; import org.l2jmobius.gameserver.network.ConnectionState;
@@ -113,7 +118,9 @@ import org.l2jmobius.gameserver.util.BuilderUtil;
*/ */
public class EnterWorld implements IClientIncomingPacket public class EnterWorld implements IClientIncomingPacket
{ {
private final int[][] tracert = new int[5][4]; private static final Map<String, ClientHardwareInfoHolder> TRACE_HWINFO = new ConcurrentHashMap<>();
private final int[][] _tracert = new int[5][4];
@Override @Override
public boolean read(GameClient client, PacketReader packet) public boolean read(GameClient client, PacketReader packet)
@@ -122,7 +129,7 @@ public class EnterWorld implements IClientIncomingPacket
{ {
for (int o = 0; o < 4; o++) for (int o = 0; o < 4; o++)
{ {
tracert[i][o] = packet.readC(); _tracert[i][o] = packet.readC();
} }
} }
packet.readD(); // Unknown Value packet.readD(); // Unknown Value
@@ -150,11 +157,11 @@ public class EnterWorld implements IClientIncomingPacket
final String[] adress = new String[5]; final String[] adress = new String[5];
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; adress[i] = _tracert[i][0] + "." + _tracert[i][1] + "." + _tracert[i][2] + "." + _tracert[i][3];
} }
LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress); LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress);
client.setClientTracert(tracert); client.setClientTracert(_tracert);
player.broadcastUserInfo(); player.broadcastUserInfo();
@@ -662,10 +669,69 @@ public class EnterWorld implements IClientIncomingPacket
{ {
ThreadPool.schedule(() -> ThreadPool.schedule(() ->
{ {
if (client.getHardwareInfo() == null) // Generate trace string.
final StringBuilder sb = new StringBuilder();
for (int[] i : _tracert)
{ {
Disconnection.of(client).defaultSequence(false); for (int j : i)
return; {
sb.append(j);
sb.append(".");
}
}
final String trace = sb.toString();
// Get hardware info from client.
ClientHardwareInfoHolder hwInfo = client.getHardwareInfo();
if (hwInfo != null)
{
hwInfo.store(player);
TRACE_HWINFO.put(trace, hwInfo);
}
else
{
// Get hardware info from stored tracert map.
hwInfo = TRACE_HWINFO.get(trace);
if (hwInfo != null)
{
hwInfo.store(player);
client.setHardwareInfo(hwInfo);
}
// Get hardware info from account variables.
else
{
final String storedInfo = player.getAccountVariables().getString(AccountVariables.HWID, "");
if (!storedInfo.isEmpty())
{
hwInfo = new ClientHardwareInfoHolder(storedInfo);
TRACE_HWINFO.put(trace, hwInfo);
client.setHardwareInfo(hwInfo);
}
}
}
// Check max players.
if (Config.MAX_PLAYERS_PER_HWID > 0)
{
if (hwInfo == null)
{
Disconnection.of(client).defaultSequence(false);
}
else
{
int count = 0;
for (PlayerInstance plr : World.getInstance().getPlayers())
{
if ((plr.isOnlineInt() == 1) && (plr.getClient().getHardwareInfo().equals(hwInfo)))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
Disconnection.of(client).defaultSequence(false);
}
}
} }
}, 5000); }, 5000);
} }

View File

@@ -16,12 +16,8 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.GameClient; import org.l2jmobius.gameserver.network.GameClient;
/** /**
@@ -82,20 +78,5 @@ public class RequestHardWareInfo implements IClientIncomingPacket
public void run(GameClient client) public void run(GameClient client)
{ {
client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion)); client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion));
if (Config.HARDWARE_INFO_ENABLED && (Config.MAX_PLAYERS_PER_HWID > 0))
{
int count = 0;
for (PlayerInstance player : World.getInstance().getPlayers())
{
if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo())))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
Disconnection.of(client).defaultSequence(false);
}
}
} }
} }

View File

@@ -158,13 +158,12 @@ RestartOnDeadlock = False
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Player HWID settings (DO NOT USE) # Player HWID settings
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Check if hardware information is sent upon login. # Check if hardware information is sent upon login.
# Players without hardware information are kicked from the game. # Players without hardware information are kicked from the game.
# WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true. # WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true.
# WARNING: The file system\HardWare.ini must be deleted each time the player logins.(?)
# Default: False # Default: False
EnableHardwareInfo = False EnableHardwareInfo = False

View File

@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.model.holders; package org.l2jmobius.gameserver.model.holders;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
/** /**
* @author Mobius * @author Mobius
*/ */
@@ -64,6 +67,77 @@ public class ClientHardwareInfoHolder
_vgaDriverVersion = vgaDriverVersion; _vgaDriverVersion = vgaDriverVersion;
} }
public ClientHardwareInfoHolder(String info)
{
final String[] split = info.split(AccountVariables.HWIDSLIT_VAR);
_macAddress = split[0];
_windowsPlatformId = Integer.valueOf(split[1]);
_windowsMajorVersion = Integer.valueOf(split[2]);
_windowsMinorVersion = Integer.valueOf(split[3]);
_windowsBuildNumber = Integer.valueOf(split[4]);
_directxVersion = Integer.valueOf(split[5]);
_directxRevision = Integer.valueOf(split[6]);
_cpuName = split[7];
_cpuSpeed = Integer.valueOf(split[8]);
_cpuCoreCount = Integer.valueOf(split[9]);
_vgaCount = Integer.valueOf(split[10]);
_vgaPcxSpeed = Integer.valueOf(split[11]);
_physMemorySlot1 = Integer.valueOf(split[12]);
_physMemorySlot2 = Integer.valueOf(split[13]);
_physMemorySlot3 = Integer.valueOf(split[14]);
_videoMemory = Integer.valueOf(split[15]);
_vgaVersion = Integer.valueOf(split[16]);
_vgaName = split[17];
_vgaDriverVersion = split[18];
}
/**
* Save hardware info to account variables for later use.
* @param player The PlayerInstance related with this hardware info.
*/
public void store(PlayerInstance player)
{
final StringBuilder sb = new StringBuilder();
sb.append(_macAddress);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsPlatformId);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsMajorVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsMinorVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsBuildNumber);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_directxVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_directxRevision);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuName);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuSpeed);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuCoreCount);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaCount);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaPcxSpeed);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot1);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot2);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot3);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_videoMemory);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaName);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaDriverVersion);
player.getAccountVariables().set(AccountVariables.HWID, sb.toString());
}
/** /**
* @return the macAddress * @return the macAddress
*/ */
@@ -215,4 +289,36 @@ public class ClientHardwareInfoHolder
{ {
return _vgaDriverVersion; return _vgaDriverVersion;
} }
@Override
public boolean equals(Object obj)
{
if (obj instanceof ClientHardwareInfoHolder)
{
final ClientHardwareInfoHolder info = (ClientHardwareInfoHolder) obj;
if ((_macAddress.equals(info.getMacAddress())) && //
(_windowsPlatformId == info.getWindowsPlatformId()) && //
(_windowsMajorVersion == info.getWindowsMajorVersion()) && //
(_windowsMinorVersion == info.getWindowsMinorVersion()) && //
(_windowsBuildNumber == info.getWindowsBuildNumber()) && //
(_directxVersion == info.getDirectxVersion()) && //
(_directxRevision == info.getDirectxRevision()) && //
(_cpuName.equals(info.getCpuName())) && //
(_cpuSpeed == info.getCpuSpeed()) && //
(_cpuCoreCount == info.getCpuCoreCount()) && //
(_vgaCount == info.getVgaCount()) && //
(_vgaPcxSpeed == info.getVgaPcxSpeed()) && //
(_physMemorySlot1 == info.getPhysMemorySlot1()) && //
(_physMemorySlot2 == info.getPhysMemorySlot2()) && //
(_physMemorySlot3 == info.getPhysMemorySlot3()) && //
(_videoMemory == info.getVideoMemory()) && //
(_vgaVersion == info.getVgaVersion()) && //
(_vgaName.equals(info.getVgaName())) && //
(_vgaDriverVersion.equals(info.getVgaDriverVersion())))
{
return true;
}
}
return false;
}
} }

View File

@@ -38,6 +38,10 @@ public class AccountVariables extends AbstractVariables
private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?"; private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?";
private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)"; private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)";
// Public variable names
public static final String HWID = "HWID";
public static final String HWIDSLIT_VAR = " ";
private final String _accountName; private final String _accountName;
public AccountVariables(String accountName) public AccountVariables(String accountName)

View File

@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
@@ -51,10 +54,12 @@ import org.l2jmobius.gameserver.model.entity.FortSiege;
import org.l2jmobius.gameserver.model.entity.GameEvent; import org.l2jmobius.gameserver.model.entity.GameEvent;
import org.l2jmobius.gameserver.model.entity.Siege; import org.l2jmobius.gameserver.model.entity.Siege;
import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder; import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.quest.Quest; import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect; import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.ConnectionState; import org.l2jmobius.gameserver.network.ConnectionState;
@@ -113,7 +118,9 @@ import org.l2jmobius.gameserver.util.BuilderUtil;
*/ */
public class EnterWorld implements IClientIncomingPacket public class EnterWorld implements IClientIncomingPacket
{ {
private final int[][] tracert = new int[5][4]; private static final Map<String, ClientHardwareInfoHolder> TRACE_HWINFO = new ConcurrentHashMap<>();
private final int[][] _tracert = new int[5][4];
@Override @Override
public boolean read(GameClient client, PacketReader packet) public boolean read(GameClient client, PacketReader packet)
@@ -122,7 +129,7 @@ public class EnterWorld implements IClientIncomingPacket
{ {
for (int o = 0; o < 4; o++) for (int o = 0; o < 4; o++)
{ {
tracert[i][o] = packet.readC(); _tracert[i][o] = packet.readC();
} }
} }
packet.readD(); // Unknown Value packet.readD(); // Unknown Value
@@ -150,11 +157,11 @@ public class EnterWorld implements IClientIncomingPacket
final String[] adress = new String[5]; final String[] adress = new String[5];
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; adress[i] = _tracert[i][0] + "." + _tracert[i][1] + "." + _tracert[i][2] + "." + _tracert[i][3];
} }
LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress); LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress);
client.setClientTracert(tracert); client.setClientTracert(_tracert);
player.broadcastUserInfo(); player.broadcastUserInfo();
@@ -662,10 +669,69 @@ public class EnterWorld implements IClientIncomingPacket
{ {
ThreadPool.schedule(() -> ThreadPool.schedule(() ->
{ {
if (client.getHardwareInfo() == null) // Generate trace string.
final StringBuilder sb = new StringBuilder();
for (int[] i : _tracert)
{ {
Disconnection.of(client).defaultSequence(false); for (int j : i)
return; {
sb.append(j);
sb.append(".");
}
}
final String trace = sb.toString();
// Get hardware info from client.
ClientHardwareInfoHolder hwInfo = client.getHardwareInfo();
if (hwInfo != null)
{
hwInfo.store(player);
TRACE_HWINFO.put(trace, hwInfo);
}
else
{
// Get hardware info from stored tracert map.
hwInfo = TRACE_HWINFO.get(trace);
if (hwInfo != null)
{
hwInfo.store(player);
client.setHardwareInfo(hwInfo);
}
// Get hardware info from account variables.
else
{
final String storedInfo = player.getAccountVariables().getString(AccountVariables.HWID, "");
if (!storedInfo.isEmpty())
{
hwInfo = new ClientHardwareInfoHolder(storedInfo);
TRACE_HWINFO.put(trace, hwInfo);
client.setHardwareInfo(hwInfo);
}
}
}
// Check max players.
if (Config.MAX_PLAYERS_PER_HWID > 0)
{
if (hwInfo == null)
{
Disconnection.of(client).defaultSequence(false);
}
else
{
int count = 0;
for (PlayerInstance plr : World.getInstance().getPlayers())
{
if ((plr.isOnlineInt() == 1) && (plr.getClient().getHardwareInfo().equals(hwInfo)))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
Disconnection.of(client).defaultSequence(false);
}
}
} }
}, 5000); }, 5000);
} }

View File

@@ -16,12 +16,8 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.GameClient; import org.l2jmobius.gameserver.network.GameClient;
/** /**
@@ -82,20 +78,5 @@ public class RequestHardWareInfo implements IClientIncomingPacket
public void run(GameClient client) public void run(GameClient client)
{ {
client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion)); client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion));
if (Config.HARDWARE_INFO_ENABLED && (Config.MAX_PLAYERS_PER_HWID > 0))
{
int count = 0;
for (PlayerInstance player : World.getInstance().getPlayers())
{
if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo())))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
Disconnection.of(client).defaultSequence(false);
}
}
} }
} }

View File

@@ -158,13 +158,12 @@ RestartOnDeadlock = False
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Player HWID settings (DO NOT USE) # Player HWID settings
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Check if hardware information is sent upon login. # Check if hardware information is sent upon login.
# Players without hardware information are kicked from the game. # Players without hardware information are kicked from the game.
# WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true. # WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true.
# WARNING: The file system\HardWare.ini must be deleted each time the player logins.(?)
# Default: False # Default: False
EnableHardwareInfo = False EnableHardwareInfo = False

View File

@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.model.holders; package org.l2jmobius.gameserver.model.holders;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
/** /**
* @author Mobius * @author Mobius
*/ */
@@ -64,6 +67,77 @@ public class ClientHardwareInfoHolder
_vgaDriverVersion = vgaDriverVersion; _vgaDriverVersion = vgaDriverVersion;
} }
public ClientHardwareInfoHolder(String info)
{
final String[] split = info.split(AccountVariables.HWIDSLIT_VAR);
_macAddress = split[0];
_windowsPlatformId = Integer.valueOf(split[1]);
_windowsMajorVersion = Integer.valueOf(split[2]);
_windowsMinorVersion = Integer.valueOf(split[3]);
_windowsBuildNumber = Integer.valueOf(split[4]);
_directxVersion = Integer.valueOf(split[5]);
_directxRevision = Integer.valueOf(split[6]);
_cpuName = split[7];
_cpuSpeed = Integer.valueOf(split[8]);
_cpuCoreCount = Integer.valueOf(split[9]);
_vgaCount = Integer.valueOf(split[10]);
_vgaPcxSpeed = Integer.valueOf(split[11]);
_physMemorySlot1 = Integer.valueOf(split[12]);
_physMemorySlot2 = Integer.valueOf(split[13]);
_physMemorySlot3 = Integer.valueOf(split[14]);
_videoMemory = Integer.valueOf(split[15]);
_vgaVersion = Integer.valueOf(split[16]);
_vgaName = split[17];
_vgaDriverVersion = split[18];
}
/**
* Save hardware info to account variables for later use.
* @param player The PlayerInstance related with this hardware info.
*/
public void store(PlayerInstance player)
{
final StringBuilder sb = new StringBuilder();
sb.append(_macAddress);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsPlatformId);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsMajorVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsMinorVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsBuildNumber);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_directxVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_directxRevision);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuName);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuSpeed);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuCoreCount);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaCount);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaPcxSpeed);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot1);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot2);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot3);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_videoMemory);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaName);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaDriverVersion);
player.getAccountVariables().set(AccountVariables.HWID, sb.toString());
}
/** /**
* @return the macAddress * @return the macAddress
*/ */
@@ -215,4 +289,36 @@ public class ClientHardwareInfoHolder
{ {
return _vgaDriverVersion; return _vgaDriverVersion;
} }
@Override
public boolean equals(Object obj)
{
if (obj instanceof ClientHardwareInfoHolder)
{
final ClientHardwareInfoHolder info = (ClientHardwareInfoHolder) obj;
if ((_macAddress.equals(info.getMacAddress())) && //
(_windowsPlatformId == info.getWindowsPlatformId()) && //
(_windowsMajorVersion == info.getWindowsMajorVersion()) && //
(_windowsMinorVersion == info.getWindowsMinorVersion()) && //
(_windowsBuildNumber == info.getWindowsBuildNumber()) && //
(_directxVersion == info.getDirectxVersion()) && //
(_directxRevision == info.getDirectxRevision()) && //
(_cpuName.equals(info.getCpuName())) && //
(_cpuSpeed == info.getCpuSpeed()) && //
(_cpuCoreCount == info.getCpuCoreCount()) && //
(_vgaCount == info.getVgaCount()) && //
(_vgaPcxSpeed == info.getVgaPcxSpeed()) && //
(_physMemorySlot1 == info.getPhysMemorySlot1()) && //
(_physMemorySlot2 == info.getPhysMemorySlot2()) && //
(_physMemorySlot3 == info.getPhysMemorySlot3()) && //
(_videoMemory == info.getVideoMemory()) && //
(_vgaVersion == info.getVgaVersion()) && //
(_vgaName.equals(info.getVgaName())) && //
(_vgaDriverVersion.equals(info.getVgaDriverVersion())))
{
return true;
}
}
return false;
}
} }

View File

@@ -38,6 +38,10 @@ public class AccountVariables extends AbstractVariables
private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?"; private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?";
private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)"; private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)";
// Public variable names
public static final String HWID = "HWID";
public static final String HWIDSLIT_VAR = " ";
private final String _accountName; private final String _accountName;
public AccountVariables(String accountName) public AccountVariables(String accountName)

View File

@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
@@ -51,10 +54,12 @@ import org.l2jmobius.gameserver.model.entity.FortSiege;
import org.l2jmobius.gameserver.model.entity.GameEvent; import org.l2jmobius.gameserver.model.entity.GameEvent;
import org.l2jmobius.gameserver.model.entity.Siege; import org.l2jmobius.gameserver.model.entity.Siege;
import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder; import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.quest.Quest; import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect; import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.ConnectionState; import org.l2jmobius.gameserver.network.ConnectionState;
@@ -113,7 +118,9 @@ import org.l2jmobius.gameserver.util.BuilderUtil;
*/ */
public class EnterWorld implements IClientIncomingPacket public class EnterWorld implements IClientIncomingPacket
{ {
private final int[][] tracert = new int[5][4]; private static final Map<String, ClientHardwareInfoHolder> TRACE_HWINFO = new ConcurrentHashMap<>();
private final int[][] _tracert = new int[5][4];
@Override @Override
public boolean read(GameClient client, PacketReader packet) public boolean read(GameClient client, PacketReader packet)
@@ -122,7 +129,7 @@ public class EnterWorld implements IClientIncomingPacket
{ {
for (int o = 0; o < 4; o++) for (int o = 0; o < 4; o++)
{ {
tracert[i][o] = packet.readC(); _tracert[i][o] = packet.readC();
} }
} }
packet.readD(); // Unknown Value packet.readD(); // Unknown Value
@@ -150,11 +157,11 @@ public class EnterWorld implements IClientIncomingPacket
final String[] adress = new String[5]; final String[] adress = new String[5];
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; adress[i] = _tracert[i][0] + "." + _tracert[i][1] + "." + _tracert[i][2] + "." + _tracert[i][3];
} }
LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress); LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress);
client.setClientTracert(tracert); client.setClientTracert(_tracert);
player.broadcastUserInfo(); player.broadcastUserInfo();
@@ -662,10 +669,69 @@ public class EnterWorld implements IClientIncomingPacket
{ {
ThreadPool.schedule(() -> ThreadPool.schedule(() ->
{ {
if (client.getHardwareInfo() == null) // Generate trace string.
final StringBuilder sb = new StringBuilder();
for (int[] i : _tracert)
{ {
Disconnection.of(client).defaultSequence(false); for (int j : i)
return; {
sb.append(j);
sb.append(".");
}
}
final String trace = sb.toString();
// Get hardware info from client.
ClientHardwareInfoHolder hwInfo = client.getHardwareInfo();
if (hwInfo != null)
{
hwInfo.store(player);
TRACE_HWINFO.put(trace, hwInfo);
}
else
{
// Get hardware info from stored tracert map.
hwInfo = TRACE_HWINFO.get(trace);
if (hwInfo != null)
{
hwInfo.store(player);
client.setHardwareInfo(hwInfo);
}
// Get hardware info from account variables.
else
{
final String storedInfo = player.getAccountVariables().getString(AccountVariables.HWID, "");
if (!storedInfo.isEmpty())
{
hwInfo = new ClientHardwareInfoHolder(storedInfo);
TRACE_HWINFO.put(trace, hwInfo);
client.setHardwareInfo(hwInfo);
}
}
}
// Check max players.
if (Config.MAX_PLAYERS_PER_HWID > 0)
{
if (hwInfo == null)
{
Disconnection.of(client).defaultSequence(false);
}
else
{
int count = 0;
for (PlayerInstance plr : World.getInstance().getPlayers())
{
if ((plr.isOnlineInt() == 1) && (plr.getClient().getHardwareInfo().equals(hwInfo)))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
Disconnection.of(client).defaultSequence(false);
}
}
} }
}, 5000); }, 5000);
} }

View File

@@ -16,12 +16,8 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.GameClient; import org.l2jmobius.gameserver.network.GameClient;
/** /**
@@ -82,20 +78,5 @@ public class RequestHardWareInfo implements IClientIncomingPacket
public void run(GameClient client) public void run(GameClient client)
{ {
client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion)); client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion));
if (Config.HARDWARE_INFO_ENABLED && (Config.MAX_PLAYERS_PER_HWID > 0))
{
int count = 0;
for (PlayerInstance player : World.getInstance().getPlayers())
{
if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo())))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
Disconnection.of(client).defaultSequence(false);
}
}
} }
} }

View File

@@ -158,13 +158,12 @@ RestartOnDeadlock = False
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Player HWID settings (DO NOT USE) # Player HWID settings
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Check if hardware information is sent upon login. # Check if hardware information is sent upon login.
# Players without hardware information are kicked from the game. # Players without hardware information are kicked from the game.
# WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true. # WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true.
# WARNING: The file system\HardWare.ini must be deleted each time the player logins.(?)
# Default: False # Default: False
EnableHardwareInfo = False EnableHardwareInfo = False

View File

@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.model.holders; package org.l2jmobius.gameserver.model.holders;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
/** /**
* @author Mobius * @author Mobius
*/ */
@@ -64,6 +67,77 @@ public class ClientHardwareInfoHolder
_vgaDriverVersion = vgaDriverVersion; _vgaDriverVersion = vgaDriverVersion;
} }
public ClientHardwareInfoHolder(String info)
{
final String[] split = info.split(AccountVariables.HWIDSLIT_VAR);
_macAddress = split[0];
_windowsPlatformId = Integer.valueOf(split[1]);
_windowsMajorVersion = Integer.valueOf(split[2]);
_windowsMinorVersion = Integer.valueOf(split[3]);
_windowsBuildNumber = Integer.valueOf(split[4]);
_directxVersion = Integer.valueOf(split[5]);
_directxRevision = Integer.valueOf(split[6]);
_cpuName = split[7];
_cpuSpeed = Integer.valueOf(split[8]);
_cpuCoreCount = Integer.valueOf(split[9]);
_vgaCount = Integer.valueOf(split[10]);
_vgaPcxSpeed = Integer.valueOf(split[11]);
_physMemorySlot1 = Integer.valueOf(split[12]);
_physMemorySlot2 = Integer.valueOf(split[13]);
_physMemorySlot3 = Integer.valueOf(split[14]);
_videoMemory = Integer.valueOf(split[15]);
_vgaVersion = Integer.valueOf(split[16]);
_vgaName = split[17];
_vgaDriverVersion = split[18];
}
/**
* Save hardware info to account variables for later use.
* @param player The PlayerInstance related with this hardware info.
*/
public void store(PlayerInstance player)
{
final StringBuilder sb = new StringBuilder();
sb.append(_macAddress);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsPlatformId);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsMajorVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsMinorVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsBuildNumber);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_directxVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_directxRevision);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuName);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuSpeed);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuCoreCount);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaCount);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaPcxSpeed);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot1);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot2);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot3);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_videoMemory);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaName);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaDriverVersion);
player.getAccountVariables().set(AccountVariables.HWID, sb.toString());
}
/** /**
* @return the macAddress * @return the macAddress
*/ */
@@ -215,4 +289,36 @@ public class ClientHardwareInfoHolder
{ {
return _vgaDriverVersion; return _vgaDriverVersion;
} }
@Override
public boolean equals(Object obj)
{
if (obj instanceof ClientHardwareInfoHolder)
{
final ClientHardwareInfoHolder info = (ClientHardwareInfoHolder) obj;
if ((_macAddress.equals(info.getMacAddress())) && //
(_windowsPlatformId == info.getWindowsPlatformId()) && //
(_windowsMajorVersion == info.getWindowsMajorVersion()) && //
(_windowsMinorVersion == info.getWindowsMinorVersion()) && //
(_windowsBuildNumber == info.getWindowsBuildNumber()) && //
(_directxVersion == info.getDirectxVersion()) && //
(_directxRevision == info.getDirectxRevision()) && //
(_cpuName.equals(info.getCpuName())) && //
(_cpuSpeed == info.getCpuSpeed()) && //
(_cpuCoreCount == info.getCpuCoreCount()) && //
(_vgaCount == info.getVgaCount()) && //
(_vgaPcxSpeed == info.getVgaPcxSpeed()) && //
(_physMemorySlot1 == info.getPhysMemorySlot1()) && //
(_physMemorySlot2 == info.getPhysMemorySlot2()) && //
(_physMemorySlot3 == info.getPhysMemorySlot3()) && //
(_videoMemory == info.getVideoMemory()) && //
(_vgaVersion == info.getVgaVersion()) && //
(_vgaName.equals(info.getVgaName())) && //
(_vgaDriverVersion.equals(info.getVgaDriverVersion())))
{
return true;
}
}
return false;
}
} }

View File

@@ -38,6 +38,10 @@ public class AccountVariables extends AbstractVariables
private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?"; private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?";
private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)"; private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)";
// Public variable names
public static final String HWID = "HWID";
public static final String HWIDSLIT_VAR = " ";
private final String _accountName; private final String _accountName;
public AccountVariables(String accountName) public AccountVariables(String accountName)

View File

@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
@@ -52,10 +55,12 @@ import org.l2jmobius.gameserver.model.entity.FortSiege;
import org.l2jmobius.gameserver.model.entity.GameEvent; import org.l2jmobius.gameserver.model.entity.GameEvent;
import org.l2jmobius.gameserver.model.entity.Siege; import org.l2jmobius.gameserver.model.entity.Siege;
import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder; import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.quest.Quest; import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect; import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.ConnectionState; import org.l2jmobius.gameserver.network.ConnectionState;
@@ -115,7 +120,9 @@ import org.l2jmobius.gameserver.util.BuilderUtil;
*/ */
public class EnterWorld implements IClientIncomingPacket public class EnterWorld implements IClientIncomingPacket
{ {
private final int[][] tracert = new int[5][4]; private static final Map<String, ClientHardwareInfoHolder> TRACE_HWINFO = new ConcurrentHashMap<>();
private final int[][] _tracert = new int[5][4];
@Override @Override
public boolean read(GameClient client, PacketReader packet) public boolean read(GameClient client, PacketReader packet)
@@ -124,7 +131,7 @@ public class EnterWorld implements IClientIncomingPacket
{ {
for (int o = 0; o < 4; o++) for (int o = 0; o < 4; o++)
{ {
tracert[i][o] = packet.readC(); _tracert[i][o] = packet.readC();
} }
} }
packet.readD(); // Unknown Value packet.readD(); // Unknown Value
@@ -152,11 +159,11 @@ public class EnterWorld implements IClientIncomingPacket
final String[] adress = new String[5]; final String[] adress = new String[5];
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; adress[i] = _tracert[i][0] + "." + _tracert[i][1] + "." + _tracert[i][2] + "." + _tracert[i][3];
} }
LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress); LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress);
client.setClientTracert(tracert); client.setClientTracert(_tracert);
player.broadcastUserInfo(); player.broadcastUserInfo();
@@ -689,10 +696,69 @@ public class EnterWorld implements IClientIncomingPacket
{ {
ThreadPool.schedule(() -> ThreadPool.schedule(() ->
{ {
if (client.getHardwareInfo() == null) // Generate trace string.
final StringBuilder sb = new StringBuilder();
for (int[] i : _tracert)
{ {
Disconnection.of(client).defaultSequence(false); for (int j : i)
return; {
sb.append(j);
sb.append(".");
}
}
final String trace = sb.toString();
// Get hardware info from client.
ClientHardwareInfoHolder hwInfo = client.getHardwareInfo();
if (hwInfo != null)
{
hwInfo.store(player);
TRACE_HWINFO.put(trace, hwInfo);
}
else
{
// Get hardware info from stored tracert map.
hwInfo = TRACE_HWINFO.get(trace);
if (hwInfo != null)
{
hwInfo.store(player);
client.setHardwareInfo(hwInfo);
}
// Get hardware info from account variables.
else
{
final String storedInfo = player.getAccountVariables().getString(AccountVariables.HWID, "");
if (!storedInfo.isEmpty())
{
hwInfo = new ClientHardwareInfoHolder(storedInfo);
TRACE_HWINFO.put(trace, hwInfo);
client.setHardwareInfo(hwInfo);
}
}
}
// Check max players.
if (Config.MAX_PLAYERS_PER_HWID > 0)
{
if (hwInfo == null)
{
Disconnection.of(client).defaultSequence(false);
}
else
{
int count = 0;
for (PlayerInstance plr : World.getInstance().getPlayers())
{
if ((plr.isOnlineInt() == 1) && (plr.getClient().getHardwareInfo().equals(hwInfo)))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
Disconnection.of(client).defaultSequence(false);
}
}
} }
}, 5000); }, 5000);
} }

View File

@@ -16,12 +16,8 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.GameClient; import org.l2jmobius.gameserver.network.GameClient;
/** /**
@@ -82,20 +78,5 @@ public class RequestHardWareInfo implements IClientIncomingPacket
public void run(GameClient client) public void run(GameClient client)
{ {
client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion)); client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion));
if (Config.HARDWARE_INFO_ENABLED && (Config.MAX_PLAYERS_PER_HWID > 0))
{
int count = 0;
for (PlayerInstance player : World.getInstance().getPlayers())
{
if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo())))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
Disconnection.of(client).defaultSequence(false);
}
}
} }
} }

View File

@@ -158,13 +158,12 @@ RestartOnDeadlock = False
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Player HWID settings (DO NOT USE) # Player HWID settings
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Check if hardware information is sent upon login. # Check if hardware information is sent upon login.
# Players without hardware information are kicked from the game. # Players without hardware information are kicked from the game.
# WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true. # WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true.
# WARNING: The file system\HardWare.ini must be deleted each time the player logins.(?)
# Default: False # Default: False
EnableHardwareInfo = False EnableHardwareInfo = False

View File

@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.model.holders; package org.l2jmobius.gameserver.model.holders;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
/** /**
* @author Mobius * @author Mobius
*/ */
@@ -64,6 +67,77 @@ public class ClientHardwareInfoHolder
_vgaDriverVersion = vgaDriverVersion; _vgaDriverVersion = vgaDriverVersion;
} }
public ClientHardwareInfoHolder(String info)
{
final String[] split = info.split(AccountVariables.HWIDSLIT_VAR);
_macAddress = split[0];
_windowsPlatformId = Integer.valueOf(split[1]);
_windowsMajorVersion = Integer.valueOf(split[2]);
_windowsMinorVersion = Integer.valueOf(split[3]);
_windowsBuildNumber = Integer.valueOf(split[4]);
_directxVersion = Integer.valueOf(split[5]);
_directxRevision = Integer.valueOf(split[6]);
_cpuName = split[7];
_cpuSpeed = Integer.valueOf(split[8]);
_cpuCoreCount = Integer.valueOf(split[9]);
_vgaCount = Integer.valueOf(split[10]);
_vgaPcxSpeed = Integer.valueOf(split[11]);
_physMemorySlot1 = Integer.valueOf(split[12]);
_physMemorySlot2 = Integer.valueOf(split[13]);
_physMemorySlot3 = Integer.valueOf(split[14]);
_videoMemory = Integer.valueOf(split[15]);
_vgaVersion = Integer.valueOf(split[16]);
_vgaName = split[17];
_vgaDriverVersion = split[18];
}
/**
* Save hardware info to account variables for later use.
* @param player The PlayerInstance related with this hardware info.
*/
public void store(PlayerInstance player)
{
final StringBuilder sb = new StringBuilder();
sb.append(_macAddress);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsPlatformId);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsMajorVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsMinorVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsBuildNumber);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_directxVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_directxRevision);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuName);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuSpeed);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuCoreCount);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaCount);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaPcxSpeed);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot1);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot2);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot3);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_videoMemory);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaName);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaDriverVersion);
player.getAccountVariables().set(AccountVariables.HWID, sb.toString());
}
/** /**
* @return the macAddress * @return the macAddress
*/ */
@@ -215,4 +289,36 @@ public class ClientHardwareInfoHolder
{ {
return _vgaDriverVersion; return _vgaDriverVersion;
} }
@Override
public boolean equals(Object obj)
{
if (obj instanceof ClientHardwareInfoHolder)
{
final ClientHardwareInfoHolder info = (ClientHardwareInfoHolder) obj;
if ((_macAddress.equals(info.getMacAddress())) && //
(_windowsPlatformId == info.getWindowsPlatformId()) && //
(_windowsMajorVersion == info.getWindowsMajorVersion()) && //
(_windowsMinorVersion == info.getWindowsMinorVersion()) && //
(_windowsBuildNumber == info.getWindowsBuildNumber()) && //
(_directxVersion == info.getDirectxVersion()) && //
(_directxRevision == info.getDirectxRevision()) && //
(_cpuName.equals(info.getCpuName())) && //
(_cpuSpeed == info.getCpuSpeed()) && //
(_cpuCoreCount == info.getCpuCoreCount()) && //
(_vgaCount == info.getVgaCount()) && //
(_vgaPcxSpeed == info.getVgaPcxSpeed()) && //
(_physMemorySlot1 == info.getPhysMemorySlot1()) && //
(_physMemorySlot2 == info.getPhysMemorySlot2()) && //
(_physMemorySlot3 == info.getPhysMemorySlot3()) && //
(_videoMemory == info.getVideoMemory()) && //
(_vgaVersion == info.getVgaVersion()) && //
(_vgaName.equals(info.getVgaName())) && //
(_vgaDriverVersion.equals(info.getVgaDriverVersion())))
{
return true;
}
}
return false;
}
} }

View File

@@ -38,6 +38,10 @@ public class AccountVariables extends AbstractVariables
private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?"; private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?";
private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)"; private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)";
// Public variable names
public static final String HWID = "HWID";
public static final String HWIDSLIT_VAR = " ";
private final String _accountName; private final String _accountName;
public AccountVariables(String accountName) public AccountVariables(String accountName)

View File

@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
@@ -50,10 +53,12 @@ import org.l2jmobius.gameserver.model.entity.FortSiege;
import org.l2jmobius.gameserver.model.entity.GameEvent; import org.l2jmobius.gameserver.model.entity.GameEvent;
import org.l2jmobius.gameserver.model.entity.Siege; import org.l2jmobius.gameserver.model.entity.Siege;
import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder; import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.quest.Quest; import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect; import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.ConnectionState; import org.l2jmobius.gameserver.network.ConnectionState;
@@ -112,7 +117,9 @@ import org.l2jmobius.gameserver.util.BuilderUtil;
*/ */
public class EnterWorld implements IClientIncomingPacket public class EnterWorld implements IClientIncomingPacket
{ {
private final int[][] tracert = new int[5][4]; private static final Map<String, ClientHardwareInfoHolder> TRACE_HWINFO = new ConcurrentHashMap<>();
private final int[][] _tracert = new int[5][4];
@Override @Override
public boolean read(GameClient client, PacketReader packet) public boolean read(GameClient client, PacketReader packet)
@@ -121,7 +128,7 @@ public class EnterWorld implements IClientIncomingPacket
{ {
for (int o = 0; o < 4; o++) for (int o = 0; o < 4; o++)
{ {
tracert[i][o] = packet.readC(); _tracert[i][o] = packet.readC();
} }
} }
packet.readD(); // Unknown Value packet.readD(); // Unknown Value
@@ -149,11 +156,11 @@ public class EnterWorld implements IClientIncomingPacket
final String[] adress = new String[5]; final String[] adress = new String[5];
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; adress[i] = _tracert[i][0] + "." + _tracert[i][1] + "." + _tracert[i][2] + "." + _tracert[i][3];
} }
LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress); LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress);
client.setClientTracert(tracert); client.setClientTracert(_tracert);
player.broadcastUserInfo(); player.broadcastUserInfo();
@@ -647,10 +654,69 @@ public class EnterWorld implements IClientIncomingPacket
{ {
ThreadPool.schedule(() -> ThreadPool.schedule(() ->
{ {
if (client.getHardwareInfo() == null) // Generate trace string.
final StringBuilder sb = new StringBuilder();
for (int[] i : _tracert)
{ {
Disconnection.of(client).defaultSequence(false); for (int j : i)
return; {
sb.append(j);
sb.append(".");
}
}
final String trace = sb.toString();
// Get hardware info from client.
ClientHardwareInfoHolder hwInfo = client.getHardwareInfo();
if (hwInfo != null)
{
hwInfo.store(player);
TRACE_HWINFO.put(trace, hwInfo);
}
else
{
// Get hardware info from stored tracert map.
hwInfo = TRACE_HWINFO.get(trace);
if (hwInfo != null)
{
hwInfo.store(player);
client.setHardwareInfo(hwInfo);
}
// Get hardware info from account variables.
else
{
final String storedInfo = player.getAccountVariables().getString(AccountVariables.HWID, "");
if (!storedInfo.isEmpty())
{
hwInfo = new ClientHardwareInfoHolder(storedInfo);
TRACE_HWINFO.put(trace, hwInfo);
client.setHardwareInfo(hwInfo);
}
}
}
// Check max players.
if (Config.MAX_PLAYERS_PER_HWID > 0)
{
if (hwInfo == null)
{
Disconnection.of(client).defaultSequence(false);
}
else
{
int count = 0;
for (PlayerInstance plr : World.getInstance().getPlayers())
{
if ((plr.isOnlineInt() == 1) && (plr.getClient().getHardwareInfo().equals(hwInfo)))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
Disconnection.of(client).defaultSequence(false);
}
}
} }
}, 5000); }, 5000);
} }

View File

@@ -16,12 +16,8 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.GameClient; import org.l2jmobius.gameserver.network.GameClient;
/** /**
@@ -82,20 +78,5 @@ public class RequestHardWareInfo implements IClientIncomingPacket
public void run(GameClient client) public void run(GameClient client)
{ {
client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion)); client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion));
if (Config.HARDWARE_INFO_ENABLED && (Config.MAX_PLAYERS_PER_HWID > 0))
{
int count = 0;
for (PlayerInstance player : World.getInstance().getPlayers())
{
if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo())))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
Disconnection.of(client).defaultSequence(false);
}
}
} }
} }

View File

@@ -158,13 +158,12 @@ RestartOnDeadlock = False
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Player HWID settings (DO NOT USE) # Player HWID settings
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Check if hardware information is sent upon login. # Check if hardware information is sent upon login.
# Players without hardware information are kicked from the game. # Players without hardware information are kicked from the game.
# WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true. # WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true.
# WARNING: The file system\HardWare.ini must be deleted each time the player logins.(?)
# Default: False # Default: False
EnableHardwareInfo = False EnableHardwareInfo = False

View File

@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.model.holders; package org.l2jmobius.gameserver.model.holders;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
/** /**
* @author Mobius * @author Mobius
*/ */
@@ -64,6 +67,77 @@ public class ClientHardwareInfoHolder
_vgaDriverVersion = vgaDriverVersion; _vgaDriverVersion = vgaDriverVersion;
} }
public ClientHardwareInfoHolder(String info)
{
final String[] split = info.split(AccountVariables.HWIDSLIT_VAR);
_macAddress = split[0];
_windowsPlatformId = Integer.valueOf(split[1]);
_windowsMajorVersion = Integer.valueOf(split[2]);
_windowsMinorVersion = Integer.valueOf(split[3]);
_windowsBuildNumber = Integer.valueOf(split[4]);
_directxVersion = Integer.valueOf(split[5]);
_directxRevision = Integer.valueOf(split[6]);
_cpuName = split[7];
_cpuSpeed = Integer.valueOf(split[8]);
_cpuCoreCount = Integer.valueOf(split[9]);
_vgaCount = Integer.valueOf(split[10]);
_vgaPcxSpeed = Integer.valueOf(split[11]);
_physMemorySlot1 = Integer.valueOf(split[12]);
_physMemorySlot2 = Integer.valueOf(split[13]);
_physMemorySlot3 = Integer.valueOf(split[14]);
_videoMemory = Integer.valueOf(split[15]);
_vgaVersion = Integer.valueOf(split[16]);
_vgaName = split[17];
_vgaDriverVersion = split[18];
}
/**
* Save hardware info to account variables for later use.
* @param player The PlayerInstance related with this hardware info.
*/
public void store(PlayerInstance player)
{
final StringBuilder sb = new StringBuilder();
sb.append(_macAddress);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsPlatformId);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsMajorVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsMinorVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsBuildNumber);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_directxVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_directxRevision);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuName);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuSpeed);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuCoreCount);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaCount);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaPcxSpeed);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot1);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot2);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot3);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_videoMemory);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaName);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaDriverVersion);
player.getAccountVariables().set(AccountVariables.HWID, sb.toString());
}
/** /**
* @return the macAddress * @return the macAddress
*/ */
@@ -215,4 +289,36 @@ public class ClientHardwareInfoHolder
{ {
return _vgaDriverVersion; return _vgaDriverVersion;
} }
@Override
public boolean equals(Object obj)
{
if (obj instanceof ClientHardwareInfoHolder)
{
final ClientHardwareInfoHolder info = (ClientHardwareInfoHolder) obj;
if ((_macAddress.equals(info.getMacAddress())) && //
(_windowsPlatformId == info.getWindowsPlatformId()) && //
(_windowsMajorVersion == info.getWindowsMajorVersion()) && //
(_windowsMinorVersion == info.getWindowsMinorVersion()) && //
(_windowsBuildNumber == info.getWindowsBuildNumber()) && //
(_directxVersion == info.getDirectxVersion()) && //
(_directxRevision == info.getDirectxRevision()) && //
(_cpuName.equals(info.getCpuName())) && //
(_cpuSpeed == info.getCpuSpeed()) && //
(_cpuCoreCount == info.getCpuCoreCount()) && //
(_vgaCount == info.getVgaCount()) && //
(_vgaPcxSpeed == info.getVgaPcxSpeed()) && //
(_physMemorySlot1 == info.getPhysMemorySlot1()) && //
(_physMemorySlot2 == info.getPhysMemorySlot2()) && //
(_physMemorySlot3 == info.getPhysMemorySlot3()) && //
(_videoMemory == info.getVideoMemory()) && //
(_vgaVersion == info.getVgaVersion()) && //
(_vgaName.equals(info.getVgaName())) && //
(_vgaDriverVersion.equals(info.getVgaDriverVersion())))
{
return true;
}
}
return false;
}
} }

View File

@@ -38,6 +38,10 @@ public class AccountVariables extends AbstractVariables
private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?"; private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?";
private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)"; private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)";
// Public variable names
public static final String HWID = "HWID";
public static final String HWIDSLIT_VAR = " ";
private final String _accountName; private final String _accountName;
public AccountVariables(String accountName) public AccountVariables(String accountName)

View File

@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
@@ -50,10 +53,12 @@ import org.l2jmobius.gameserver.model.entity.FortSiege;
import org.l2jmobius.gameserver.model.entity.GameEvent; import org.l2jmobius.gameserver.model.entity.GameEvent;
import org.l2jmobius.gameserver.model.entity.Siege; import org.l2jmobius.gameserver.model.entity.Siege;
import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder; import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.quest.Quest; import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect; import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.ConnectionState; import org.l2jmobius.gameserver.network.ConnectionState;
@@ -112,7 +117,9 @@ import org.l2jmobius.gameserver.util.BuilderUtil;
*/ */
public class EnterWorld implements IClientIncomingPacket public class EnterWorld implements IClientIncomingPacket
{ {
private final int[][] tracert = new int[5][4]; private static final Map<String, ClientHardwareInfoHolder> TRACE_HWINFO = new ConcurrentHashMap<>();
private final int[][] _tracert = new int[5][4];
@Override @Override
public boolean read(GameClient client, PacketReader packet) public boolean read(GameClient client, PacketReader packet)
@@ -121,7 +128,7 @@ public class EnterWorld implements IClientIncomingPacket
{ {
for (int o = 0; o < 4; o++) for (int o = 0; o < 4; o++)
{ {
tracert[i][o] = packet.readC(); _tracert[i][o] = packet.readC();
} }
} }
packet.readD(); // Unknown Value packet.readD(); // Unknown Value
@@ -149,11 +156,11 @@ public class EnterWorld implements IClientIncomingPacket
final String[] adress = new String[5]; final String[] adress = new String[5];
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; adress[i] = _tracert[i][0] + "." + _tracert[i][1] + "." + _tracert[i][2] + "." + _tracert[i][3];
} }
LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress); LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress);
client.setClientTracert(tracert); client.setClientTracert(_tracert);
player.broadcastUserInfo(); player.broadcastUserInfo();
@@ -647,10 +654,69 @@ public class EnterWorld implements IClientIncomingPacket
{ {
ThreadPool.schedule(() -> ThreadPool.schedule(() ->
{ {
if (client.getHardwareInfo() == null) // Generate trace string.
final StringBuilder sb = new StringBuilder();
for (int[] i : _tracert)
{ {
Disconnection.of(client).defaultSequence(false); for (int j : i)
return; {
sb.append(j);
sb.append(".");
}
}
final String trace = sb.toString();
// Get hardware info from client.
ClientHardwareInfoHolder hwInfo = client.getHardwareInfo();
if (hwInfo != null)
{
hwInfo.store(player);
TRACE_HWINFO.put(trace, hwInfo);
}
else
{
// Get hardware info from stored tracert map.
hwInfo = TRACE_HWINFO.get(trace);
if (hwInfo != null)
{
hwInfo.store(player);
client.setHardwareInfo(hwInfo);
}
// Get hardware info from account variables.
else
{
final String storedInfo = player.getAccountVariables().getString(AccountVariables.HWID, "");
if (!storedInfo.isEmpty())
{
hwInfo = new ClientHardwareInfoHolder(storedInfo);
TRACE_HWINFO.put(trace, hwInfo);
client.setHardwareInfo(hwInfo);
}
}
}
// Check max players.
if (Config.MAX_PLAYERS_PER_HWID > 0)
{
if (hwInfo == null)
{
Disconnection.of(client).defaultSequence(false);
}
else
{
int count = 0;
for (PlayerInstance plr : World.getInstance().getPlayers())
{
if ((plr.isOnlineInt() == 1) && (plr.getClient().getHardwareInfo().equals(hwInfo)))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
Disconnection.of(client).defaultSequence(false);
}
}
} }
}, 5000); }, 5000);
} }

View File

@@ -16,12 +16,8 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.GameClient; import org.l2jmobius.gameserver.network.GameClient;
/** /**
@@ -82,20 +78,5 @@ public class RequestHardWareInfo implements IClientIncomingPacket
public void run(GameClient client) public void run(GameClient client)
{ {
client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion)); client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion));
if (Config.HARDWARE_INFO_ENABLED && (Config.MAX_PLAYERS_PER_HWID > 0))
{
int count = 0;
for (PlayerInstance player : World.getInstance().getPlayers())
{
if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo())))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
Disconnection.of(client).defaultSequence(false);
}
}
} }
} }

View File

@@ -158,13 +158,12 @@ RestartOnDeadlock = False
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Player HWID settings (DO NOT USE) # Player HWID settings
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Check if hardware information is sent upon login. # Check if hardware information is sent upon login.
# Players without hardware information are kicked from the game. # Players without hardware information are kicked from the game.
# WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true. # WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true.
# WARNING: The file system\HardWare.ini must be deleted each time the player logins.(?)
# Default: False # Default: False
EnableHardwareInfo = False EnableHardwareInfo = False

View File

@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.model.holders; package org.l2jmobius.gameserver.model.holders;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
/** /**
* @author Mobius * @author Mobius
*/ */
@@ -64,6 +67,77 @@ public class ClientHardwareInfoHolder
_vgaDriverVersion = vgaDriverVersion; _vgaDriverVersion = vgaDriverVersion;
} }
public ClientHardwareInfoHolder(String info)
{
final String[] split = info.split(AccountVariables.HWIDSLIT_VAR);
_macAddress = split[0];
_windowsPlatformId = Integer.valueOf(split[1]);
_windowsMajorVersion = Integer.valueOf(split[2]);
_windowsMinorVersion = Integer.valueOf(split[3]);
_windowsBuildNumber = Integer.valueOf(split[4]);
_directxVersion = Integer.valueOf(split[5]);
_directxRevision = Integer.valueOf(split[6]);
_cpuName = split[7];
_cpuSpeed = Integer.valueOf(split[8]);
_cpuCoreCount = Integer.valueOf(split[9]);
_vgaCount = Integer.valueOf(split[10]);
_vgaPcxSpeed = Integer.valueOf(split[11]);
_physMemorySlot1 = Integer.valueOf(split[12]);
_physMemorySlot2 = Integer.valueOf(split[13]);
_physMemorySlot3 = Integer.valueOf(split[14]);
_videoMemory = Integer.valueOf(split[15]);
_vgaVersion = Integer.valueOf(split[16]);
_vgaName = split[17];
_vgaDriverVersion = split[18];
}
/**
* Save hardware info to account variables for later use.
* @param player The PlayerInstance related with this hardware info.
*/
public void store(PlayerInstance player)
{
final StringBuilder sb = new StringBuilder();
sb.append(_macAddress);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsPlatformId);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsMajorVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsMinorVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsBuildNumber);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_directxVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_directxRevision);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuName);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuSpeed);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuCoreCount);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaCount);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaPcxSpeed);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot1);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot2);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot3);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_videoMemory);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaName);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaDriverVersion);
player.getAccountVariables().set(AccountVariables.HWID, sb.toString());
}
/** /**
* @return the macAddress * @return the macAddress
*/ */
@@ -215,4 +289,36 @@ public class ClientHardwareInfoHolder
{ {
return _vgaDriverVersion; return _vgaDriverVersion;
} }
@Override
public boolean equals(Object obj)
{
if (obj instanceof ClientHardwareInfoHolder)
{
final ClientHardwareInfoHolder info = (ClientHardwareInfoHolder) obj;
if ((_macAddress.equals(info.getMacAddress())) && //
(_windowsPlatformId == info.getWindowsPlatformId()) && //
(_windowsMajorVersion == info.getWindowsMajorVersion()) && //
(_windowsMinorVersion == info.getWindowsMinorVersion()) && //
(_windowsBuildNumber == info.getWindowsBuildNumber()) && //
(_directxVersion == info.getDirectxVersion()) && //
(_directxRevision == info.getDirectxRevision()) && //
(_cpuName.equals(info.getCpuName())) && //
(_cpuSpeed == info.getCpuSpeed()) && //
(_cpuCoreCount == info.getCpuCoreCount()) && //
(_vgaCount == info.getVgaCount()) && //
(_vgaPcxSpeed == info.getVgaPcxSpeed()) && //
(_physMemorySlot1 == info.getPhysMemorySlot1()) && //
(_physMemorySlot2 == info.getPhysMemorySlot2()) && //
(_physMemorySlot3 == info.getPhysMemorySlot3()) && //
(_videoMemory == info.getVideoMemory()) && //
(_vgaVersion == info.getVgaVersion()) && //
(_vgaName.equals(info.getVgaName())) && //
(_vgaDriverVersion.equals(info.getVgaDriverVersion())))
{
return true;
}
}
return false;
}
} }

View File

@@ -38,6 +38,10 @@ public class AccountVariables extends AbstractVariables
private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?"; private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?";
private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)"; private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)";
// Public variable names
public static final String HWID = "HWID";
public static final String HWIDSLIT_VAR = " ";
private final String _accountName; private final String _accountName;
public AccountVariables(String accountName) public AccountVariables(String accountName)

View File

@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
@@ -50,10 +53,12 @@ import org.l2jmobius.gameserver.model.entity.FortSiege;
import org.l2jmobius.gameserver.model.entity.GameEvent; import org.l2jmobius.gameserver.model.entity.GameEvent;
import org.l2jmobius.gameserver.model.entity.Siege; import org.l2jmobius.gameserver.model.entity.Siege;
import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder; import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.quest.Quest; import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect; import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.ConnectionState; import org.l2jmobius.gameserver.network.ConnectionState;
@@ -112,7 +117,9 @@ import org.l2jmobius.gameserver.util.BuilderUtil;
*/ */
public class EnterWorld implements IClientIncomingPacket public class EnterWorld implements IClientIncomingPacket
{ {
private final int[][] tracert = new int[5][4]; private static final Map<String, ClientHardwareInfoHolder> TRACE_HWINFO = new ConcurrentHashMap<>();
private final int[][] _tracert = new int[5][4];
@Override @Override
public boolean read(GameClient client, PacketReader packet) public boolean read(GameClient client, PacketReader packet)
@@ -121,7 +128,7 @@ public class EnterWorld implements IClientIncomingPacket
{ {
for (int o = 0; o < 4; o++) for (int o = 0; o < 4; o++)
{ {
tracert[i][o] = packet.readC(); _tracert[i][o] = packet.readC();
} }
} }
packet.readD(); // Unknown Value packet.readD(); // Unknown Value
@@ -149,11 +156,11 @@ public class EnterWorld implements IClientIncomingPacket
final String[] adress = new String[5]; final String[] adress = new String[5];
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; adress[i] = _tracert[i][0] + "." + _tracert[i][1] + "." + _tracert[i][2] + "." + _tracert[i][3];
} }
LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress); LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress);
client.setClientTracert(tracert); client.setClientTracert(_tracert);
player.broadcastUserInfo(); player.broadcastUserInfo();
@@ -649,10 +656,69 @@ public class EnterWorld implements IClientIncomingPacket
{ {
ThreadPool.schedule(() -> ThreadPool.schedule(() ->
{ {
if (client.getHardwareInfo() == null) // Generate trace string.
final StringBuilder sb = new StringBuilder();
for (int[] i : _tracert)
{ {
Disconnection.of(client).defaultSequence(false); for (int j : i)
return; {
sb.append(j);
sb.append(".");
}
}
final String trace = sb.toString();
// Get hardware info from client.
ClientHardwareInfoHolder hwInfo = client.getHardwareInfo();
if (hwInfo != null)
{
hwInfo.store(player);
TRACE_HWINFO.put(trace, hwInfo);
}
else
{
// Get hardware info from stored tracert map.
hwInfo = TRACE_HWINFO.get(trace);
if (hwInfo != null)
{
hwInfo.store(player);
client.setHardwareInfo(hwInfo);
}
// Get hardware info from account variables.
else
{
final String storedInfo = player.getAccountVariables().getString(AccountVariables.HWID, "");
if (!storedInfo.isEmpty())
{
hwInfo = new ClientHardwareInfoHolder(storedInfo);
TRACE_HWINFO.put(trace, hwInfo);
client.setHardwareInfo(hwInfo);
}
}
}
// Check max players.
if (Config.MAX_PLAYERS_PER_HWID > 0)
{
if (hwInfo == null)
{
Disconnection.of(client).defaultSequence(false);
}
else
{
int count = 0;
for (PlayerInstance plr : World.getInstance().getPlayers())
{
if ((plr.isOnlineInt() == 1) && (plr.getClient().getHardwareInfo().equals(hwInfo)))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
Disconnection.of(client).defaultSequence(false);
}
}
} }
}, 5000); }, 5000);
} }

View File

@@ -16,12 +16,8 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.GameClient; import org.l2jmobius.gameserver.network.GameClient;
/** /**
@@ -82,20 +78,5 @@ public class RequestHardWareInfo implements IClientIncomingPacket
public void run(GameClient client) public void run(GameClient client)
{ {
client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion)); client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion));
if (Config.HARDWARE_INFO_ENABLED && (Config.MAX_PLAYERS_PER_HWID > 0))
{
int count = 0;
for (PlayerInstance player : World.getInstance().getPlayers())
{
if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo())))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
Disconnection.of(client).defaultSequence(false);
}
}
} }
} }

View File

@@ -158,13 +158,12 @@ RestartOnDeadlock = False
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Player HWID settings (DO NOT USE) # Player HWID settings
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Check if hardware information is sent upon login. # Check if hardware information is sent upon login.
# Players without hardware information are kicked from the game. # Players without hardware information are kicked from the game.
# WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true. # WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true.
# WARNING: The file system\HardWare.ini must be deleted each time the player logins.(?)
# Default: False # Default: False
EnableHardwareInfo = False EnableHardwareInfo = False

View File

@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.model.holders; package org.l2jmobius.gameserver.model.holders;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
/** /**
* @author Mobius * @author Mobius
*/ */
@@ -64,6 +67,77 @@ public class ClientHardwareInfoHolder
_vgaDriverVersion = vgaDriverVersion; _vgaDriverVersion = vgaDriverVersion;
} }
public ClientHardwareInfoHolder(String info)
{
final String[] split = info.split(AccountVariables.HWIDSLIT_VAR);
_macAddress = split[0];
_windowsPlatformId = Integer.valueOf(split[1]);
_windowsMajorVersion = Integer.valueOf(split[2]);
_windowsMinorVersion = Integer.valueOf(split[3]);
_windowsBuildNumber = Integer.valueOf(split[4]);
_directxVersion = Integer.valueOf(split[5]);
_directxRevision = Integer.valueOf(split[6]);
_cpuName = split[7];
_cpuSpeed = Integer.valueOf(split[8]);
_cpuCoreCount = Integer.valueOf(split[9]);
_vgaCount = Integer.valueOf(split[10]);
_vgaPcxSpeed = Integer.valueOf(split[11]);
_physMemorySlot1 = Integer.valueOf(split[12]);
_physMemorySlot2 = Integer.valueOf(split[13]);
_physMemorySlot3 = Integer.valueOf(split[14]);
_videoMemory = Integer.valueOf(split[15]);
_vgaVersion = Integer.valueOf(split[16]);
_vgaName = split[17];
_vgaDriverVersion = split[18];
}
/**
* Save hardware info to account variables for later use.
* @param player The PlayerInstance related with this hardware info.
*/
public void store(PlayerInstance player)
{
final StringBuilder sb = new StringBuilder();
sb.append(_macAddress);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsPlatformId);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsMajorVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsMinorVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsBuildNumber);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_directxVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_directxRevision);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuName);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuSpeed);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuCoreCount);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaCount);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaPcxSpeed);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot1);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot2);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot3);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_videoMemory);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaName);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaDriverVersion);
player.getAccountVariables().set(AccountVariables.HWID, sb.toString());
}
/** /**
* @return the macAddress * @return the macAddress
*/ */
@@ -215,4 +289,36 @@ public class ClientHardwareInfoHolder
{ {
return _vgaDriverVersion; return _vgaDriverVersion;
} }
@Override
public boolean equals(Object obj)
{
if (obj instanceof ClientHardwareInfoHolder)
{
final ClientHardwareInfoHolder info = (ClientHardwareInfoHolder) obj;
if ((_macAddress.equals(info.getMacAddress())) && //
(_windowsPlatformId == info.getWindowsPlatformId()) && //
(_windowsMajorVersion == info.getWindowsMajorVersion()) && //
(_windowsMinorVersion == info.getWindowsMinorVersion()) && //
(_windowsBuildNumber == info.getWindowsBuildNumber()) && //
(_directxVersion == info.getDirectxVersion()) && //
(_directxRevision == info.getDirectxRevision()) && //
(_cpuName.equals(info.getCpuName())) && //
(_cpuSpeed == info.getCpuSpeed()) && //
(_cpuCoreCount == info.getCpuCoreCount()) && //
(_vgaCount == info.getVgaCount()) && //
(_vgaPcxSpeed == info.getVgaPcxSpeed()) && //
(_physMemorySlot1 == info.getPhysMemorySlot1()) && //
(_physMemorySlot2 == info.getPhysMemorySlot2()) && //
(_physMemorySlot3 == info.getPhysMemorySlot3()) && //
(_videoMemory == info.getVideoMemory()) && //
(_vgaVersion == info.getVgaVersion()) && //
(_vgaName.equals(info.getVgaName())) && //
(_vgaDriverVersion.equals(info.getVgaDriverVersion())))
{
return true;
}
}
return false;
}
} }

View File

@@ -38,6 +38,10 @@ public class AccountVariables extends AbstractVariables
private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?"; private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?";
private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)"; private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)";
// Public variable names
public static final String HWID = "HWID";
public static final String HWIDSLIT_VAR = " ";
private final String _accountName; private final String _accountName;
public AccountVariables(String accountName) public AccountVariables(String accountName)

View File

@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
@@ -50,10 +53,12 @@ import org.l2jmobius.gameserver.model.entity.FortSiege;
import org.l2jmobius.gameserver.model.entity.GameEvent; import org.l2jmobius.gameserver.model.entity.GameEvent;
import org.l2jmobius.gameserver.model.entity.Siege; import org.l2jmobius.gameserver.model.entity.Siege;
import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder; import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.quest.Quest; import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect; import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.ConnectionState; import org.l2jmobius.gameserver.network.ConnectionState;
@@ -112,7 +117,9 @@ import org.l2jmobius.gameserver.util.BuilderUtil;
*/ */
public class EnterWorld implements IClientIncomingPacket public class EnterWorld implements IClientIncomingPacket
{ {
private final int[][] tracert = new int[5][4]; private static final Map<String, ClientHardwareInfoHolder> TRACE_HWINFO = new ConcurrentHashMap<>();
private final int[][] _tracert = new int[5][4];
@Override @Override
public boolean read(GameClient client, PacketReader packet) public boolean read(GameClient client, PacketReader packet)
@@ -121,7 +128,7 @@ public class EnterWorld implements IClientIncomingPacket
{ {
for (int o = 0; o < 4; o++) for (int o = 0; o < 4; o++)
{ {
tracert[i][o] = packet.readC(); _tracert[i][o] = packet.readC();
} }
} }
packet.readD(); // Unknown Value packet.readD(); // Unknown Value
@@ -149,11 +156,11 @@ public class EnterWorld implements IClientIncomingPacket
final String[] adress = new String[5]; final String[] adress = new String[5];
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; adress[i] = _tracert[i][0] + "." + _tracert[i][1] + "." + _tracert[i][2] + "." + _tracert[i][3];
} }
LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress); LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress);
client.setClientTracert(tracert); client.setClientTracert(_tracert);
player.broadcastUserInfo(); player.broadcastUserInfo();
@@ -649,10 +656,69 @@ public class EnterWorld implements IClientIncomingPacket
{ {
ThreadPool.schedule(() -> ThreadPool.schedule(() ->
{ {
if (client.getHardwareInfo() == null) // Generate trace string.
final StringBuilder sb = new StringBuilder();
for (int[] i : _tracert)
{ {
Disconnection.of(client).defaultSequence(false); for (int j : i)
return; {
sb.append(j);
sb.append(".");
}
}
final String trace = sb.toString();
// Get hardware info from client.
ClientHardwareInfoHolder hwInfo = client.getHardwareInfo();
if (hwInfo != null)
{
hwInfo.store(player);
TRACE_HWINFO.put(trace, hwInfo);
}
else
{
// Get hardware info from stored tracert map.
hwInfo = TRACE_HWINFO.get(trace);
if (hwInfo != null)
{
hwInfo.store(player);
client.setHardwareInfo(hwInfo);
}
// Get hardware info from account variables.
else
{
final String storedInfo = player.getAccountVariables().getString(AccountVariables.HWID, "");
if (!storedInfo.isEmpty())
{
hwInfo = new ClientHardwareInfoHolder(storedInfo);
TRACE_HWINFO.put(trace, hwInfo);
client.setHardwareInfo(hwInfo);
}
}
}
// Check max players.
if (Config.MAX_PLAYERS_PER_HWID > 0)
{
if (hwInfo == null)
{
Disconnection.of(client).defaultSequence(false);
}
else
{
int count = 0;
for (PlayerInstance plr : World.getInstance().getPlayers())
{
if ((plr.isOnlineInt() == 1) && (plr.getClient().getHardwareInfo().equals(hwInfo)))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
Disconnection.of(client).defaultSequence(false);
}
}
} }
}, 5000); }, 5000);
} }

View File

@@ -16,12 +16,8 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.GameClient; import org.l2jmobius.gameserver.network.GameClient;
/** /**
@@ -82,20 +78,5 @@ public class RequestHardWareInfo implements IClientIncomingPacket
public void run(GameClient client) public void run(GameClient client)
{ {
client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion)); client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion));
if (Config.HARDWARE_INFO_ENABLED && (Config.MAX_PLAYERS_PER_HWID > 0))
{
int count = 0;
for (PlayerInstance player : World.getInstance().getPlayers())
{
if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo())))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
Disconnection.of(client).defaultSequence(false);
}
}
} }
} }

View File

@@ -158,13 +158,12 @@ RestartOnDeadlock = False
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Player HWID settings (DO NOT USE) # Player HWID settings
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Check if hardware information is sent upon login. # Check if hardware information is sent upon login.
# Players without hardware information are kicked from the game. # Players without hardware information are kicked from the game.
# WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true. # WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true.
# WARNING: The file system\HardWare.ini must be deleted each time the player logins.(?)
# Default: False # Default: False
EnableHardwareInfo = False EnableHardwareInfo = False

View File

@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.model.holders; package org.l2jmobius.gameserver.model.holders;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
/** /**
* @author Mobius * @author Mobius
*/ */
@@ -64,6 +67,77 @@ public class ClientHardwareInfoHolder
_vgaDriverVersion = vgaDriverVersion; _vgaDriverVersion = vgaDriverVersion;
} }
public ClientHardwareInfoHolder(String info)
{
final String[] split = info.split(AccountVariables.HWIDSLIT_VAR);
_macAddress = split[0];
_windowsPlatformId = Integer.valueOf(split[1]);
_windowsMajorVersion = Integer.valueOf(split[2]);
_windowsMinorVersion = Integer.valueOf(split[3]);
_windowsBuildNumber = Integer.valueOf(split[4]);
_directxVersion = Integer.valueOf(split[5]);
_directxRevision = Integer.valueOf(split[6]);
_cpuName = split[7];
_cpuSpeed = Integer.valueOf(split[8]);
_cpuCoreCount = Integer.valueOf(split[9]);
_vgaCount = Integer.valueOf(split[10]);
_vgaPcxSpeed = Integer.valueOf(split[11]);
_physMemorySlot1 = Integer.valueOf(split[12]);
_physMemorySlot2 = Integer.valueOf(split[13]);
_physMemorySlot3 = Integer.valueOf(split[14]);
_videoMemory = Integer.valueOf(split[15]);
_vgaVersion = Integer.valueOf(split[16]);
_vgaName = split[17];
_vgaDriverVersion = split[18];
}
/**
* Save hardware info to account variables for later use.
* @param player The PlayerInstance related with this hardware info.
*/
public void store(PlayerInstance player)
{
final StringBuilder sb = new StringBuilder();
sb.append(_macAddress);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsPlatformId);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsMajorVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsMinorVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsBuildNumber);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_directxVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_directxRevision);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuName);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuSpeed);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuCoreCount);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaCount);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaPcxSpeed);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot1);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot2);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot3);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_videoMemory);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaName);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaDriverVersion);
player.getAccountVariables().set(AccountVariables.HWID, sb.toString());
}
/** /**
* @return the macAddress * @return the macAddress
*/ */
@@ -215,4 +289,36 @@ public class ClientHardwareInfoHolder
{ {
return _vgaDriverVersion; return _vgaDriverVersion;
} }
@Override
public boolean equals(Object obj)
{
if (obj instanceof ClientHardwareInfoHolder)
{
final ClientHardwareInfoHolder info = (ClientHardwareInfoHolder) obj;
if ((_macAddress.equals(info.getMacAddress())) && //
(_windowsPlatformId == info.getWindowsPlatformId()) && //
(_windowsMajorVersion == info.getWindowsMajorVersion()) && //
(_windowsMinorVersion == info.getWindowsMinorVersion()) && //
(_windowsBuildNumber == info.getWindowsBuildNumber()) && //
(_directxVersion == info.getDirectxVersion()) && //
(_directxRevision == info.getDirectxRevision()) && //
(_cpuName.equals(info.getCpuName())) && //
(_cpuSpeed == info.getCpuSpeed()) && //
(_cpuCoreCount == info.getCpuCoreCount()) && //
(_vgaCount == info.getVgaCount()) && //
(_vgaPcxSpeed == info.getVgaPcxSpeed()) && //
(_physMemorySlot1 == info.getPhysMemorySlot1()) && //
(_physMemorySlot2 == info.getPhysMemorySlot2()) && //
(_physMemorySlot3 == info.getPhysMemorySlot3()) && //
(_videoMemory == info.getVideoMemory()) && //
(_vgaVersion == info.getVgaVersion()) && //
(_vgaName.equals(info.getVgaName())) && //
(_vgaDriverVersion.equals(info.getVgaDriverVersion())))
{
return true;
}
}
return false;
}
} }

View File

@@ -38,6 +38,10 @@ public class AccountVariables extends AbstractVariables
private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?"; private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?";
private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)"; private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)";
// Public variable names
public static final String HWID = "HWID";
public static final String HWIDSLIT_VAR = " ";
private final String _accountName; private final String _accountName;
public AccountVariables(String accountName) public AccountVariables(String accountName)

View File

@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
@@ -50,10 +53,12 @@ import org.l2jmobius.gameserver.model.entity.FortSiege;
import org.l2jmobius.gameserver.model.entity.GameEvent; import org.l2jmobius.gameserver.model.entity.GameEvent;
import org.l2jmobius.gameserver.model.entity.Siege; import org.l2jmobius.gameserver.model.entity.Siege;
import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder; import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.quest.Quest; import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect; import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.ConnectionState; import org.l2jmobius.gameserver.network.ConnectionState;
@@ -112,7 +117,9 @@ import org.l2jmobius.gameserver.util.BuilderUtil;
*/ */
public class EnterWorld implements IClientIncomingPacket public class EnterWorld implements IClientIncomingPacket
{ {
private final int[][] tracert = new int[5][4]; private static final Map<String, ClientHardwareInfoHolder> TRACE_HWINFO = new ConcurrentHashMap<>();
private final int[][] _tracert = new int[5][4];
@Override @Override
public boolean read(GameClient client, PacketReader packet) public boolean read(GameClient client, PacketReader packet)
@@ -121,7 +128,7 @@ public class EnterWorld implements IClientIncomingPacket
{ {
for (int o = 0; o < 4; o++) for (int o = 0; o < 4; o++)
{ {
tracert[i][o] = packet.readC(); _tracert[i][o] = packet.readC();
} }
} }
packet.readD(); // Unknown Value packet.readD(); // Unknown Value
@@ -149,11 +156,11 @@ public class EnterWorld implements IClientIncomingPacket
final String[] adress = new String[5]; final String[] adress = new String[5];
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; adress[i] = _tracert[i][0] + "." + _tracert[i][1] + "." + _tracert[i][2] + "." + _tracert[i][3];
} }
LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress); LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress);
client.setClientTracert(tracert); client.setClientTracert(_tracert);
player.broadcastUserInfo(); player.broadcastUserInfo();
@@ -649,10 +656,69 @@ public class EnterWorld implements IClientIncomingPacket
{ {
ThreadPool.schedule(() -> ThreadPool.schedule(() ->
{ {
if (client.getHardwareInfo() == null) // Generate trace string.
final StringBuilder sb = new StringBuilder();
for (int[] i : _tracert)
{ {
Disconnection.of(client).defaultSequence(false); for (int j : i)
return; {
sb.append(j);
sb.append(".");
}
}
final String trace = sb.toString();
// Get hardware info from client.
ClientHardwareInfoHolder hwInfo = client.getHardwareInfo();
if (hwInfo != null)
{
hwInfo.store(player);
TRACE_HWINFO.put(trace, hwInfo);
}
else
{
// Get hardware info from stored tracert map.
hwInfo = TRACE_HWINFO.get(trace);
if (hwInfo != null)
{
hwInfo.store(player);
client.setHardwareInfo(hwInfo);
}
// Get hardware info from account variables.
else
{
final String storedInfo = player.getAccountVariables().getString(AccountVariables.HWID, "");
if (!storedInfo.isEmpty())
{
hwInfo = new ClientHardwareInfoHolder(storedInfo);
TRACE_HWINFO.put(trace, hwInfo);
client.setHardwareInfo(hwInfo);
}
}
}
// Check max players.
if (Config.MAX_PLAYERS_PER_HWID > 0)
{
if (hwInfo == null)
{
Disconnection.of(client).defaultSequence(false);
}
else
{
int count = 0;
for (PlayerInstance plr : World.getInstance().getPlayers())
{
if ((plr.isOnlineInt() == 1) && (plr.getClient().getHardwareInfo().equals(hwInfo)))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
Disconnection.of(client).defaultSequence(false);
}
}
} }
}, 5000); }, 5000);
} }

View File

@@ -16,12 +16,8 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.GameClient; import org.l2jmobius.gameserver.network.GameClient;
/** /**
@@ -82,20 +78,5 @@ public class RequestHardWareInfo implements IClientIncomingPacket
public void run(GameClient client) public void run(GameClient client)
{ {
client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion)); client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion));
if (Config.HARDWARE_INFO_ENABLED && (Config.MAX_PLAYERS_PER_HWID > 0))
{
int count = 0;
for (PlayerInstance player : World.getInstance().getPlayers())
{
if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo())))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
Disconnection.of(client).defaultSequence(false);
}
}
} }
} }

View File

@@ -158,13 +158,12 @@ RestartOnDeadlock = False
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Player HWID settings (DO NOT USE) # Player HWID settings
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Check if hardware information is sent upon login. # Check if hardware information is sent upon login.
# Players without hardware information are kicked from the game. # Players without hardware information are kicked from the game.
# WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true. # WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true.
# WARNING: The file system\HardWare.ini must be deleted each time the player logins.(?)
# Default: False # Default: False
EnableHardwareInfo = False EnableHardwareInfo = False

View File

@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.model.holders; package org.l2jmobius.gameserver.model.holders;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
/** /**
* @author Mobius * @author Mobius
*/ */
@@ -64,6 +67,77 @@ public class ClientHardwareInfoHolder
_vgaDriverVersion = vgaDriverVersion; _vgaDriverVersion = vgaDriverVersion;
} }
public ClientHardwareInfoHolder(String info)
{
final String[] split = info.split(AccountVariables.HWIDSLIT_VAR);
_macAddress = split[0];
_windowsPlatformId = Integer.valueOf(split[1]);
_windowsMajorVersion = Integer.valueOf(split[2]);
_windowsMinorVersion = Integer.valueOf(split[3]);
_windowsBuildNumber = Integer.valueOf(split[4]);
_directxVersion = Integer.valueOf(split[5]);
_directxRevision = Integer.valueOf(split[6]);
_cpuName = split[7];
_cpuSpeed = Integer.valueOf(split[8]);
_cpuCoreCount = Integer.valueOf(split[9]);
_vgaCount = Integer.valueOf(split[10]);
_vgaPcxSpeed = Integer.valueOf(split[11]);
_physMemorySlot1 = Integer.valueOf(split[12]);
_physMemorySlot2 = Integer.valueOf(split[13]);
_physMemorySlot3 = Integer.valueOf(split[14]);
_videoMemory = Integer.valueOf(split[15]);
_vgaVersion = Integer.valueOf(split[16]);
_vgaName = split[17];
_vgaDriverVersion = split[18];
}
/**
* Save hardware info to account variables for later use.
* @param player The PlayerInstance related with this hardware info.
*/
public void store(PlayerInstance player)
{
final StringBuilder sb = new StringBuilder();
sb.append(_macAddress);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsPlatformId);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsMajorVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsMinorVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsBuildNumber);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_directxVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_directxRevision);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuName);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuSpeed);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuCoreCount);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaCount);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaPcxSpeed);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot1);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot2);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot3);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_videoMemory);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaName);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaDriverVersion);
player.getAccountVariables().set(AccountVariables.HWID, sb.toString());
}
/** /**
* @return the macAddress * @return the macAddress
*/ */
@@ -215,4 +289,36 @@ public class ClientHardwareInfoHolder
{ {
return _vgaDriverVersion; return _vgaDriverVersion;
} }
@Override
public boolean equals(Object obj)
{
if (obj instanceof ClientHardwareInfoHolder)
{
final ClientHardwareInfoHolder info = (ClientHardwareInfoHolder) obj;
if ((_macAddress.equals(info.getMacAddress())) && //
(_windowsPlatformId == info.getWindowsPlatformId()) && //
(_windowsMajorVersion == info.getWindowsMajorVersion()) && //
(_windowsMinorVersion == info.getWindowsMinorVersion()) && //
(_windowsBuildNumber == info.getWindowsBuildNumber()) && //
(_directxVersion == info.getDirectxVersion()) && //
(_directxRevision == info.getDirectxRevision()) && //
(_cpuName.equals(info.getCpuName())) && //
(_cpuSpeed == info.getCpuSpeed()) && //
(_cpuCoreCount == info.getCpuCoreCount()) && //
(_vgaCount == info.getVgaCount()) && //
(_vgaPcxSpeed == info.getVgaPcxSpeed()) && //
(_physMemorySlot1 == info.getPhysMemorySlot1()) && //
(_physMemorySlot2 == info.getPhysMemorySlot2()) && //
(_physMemorySlot3 == info.getPhysMemorySlot3()) && //
(_videoMemory == info.getVideoMemory()) && //
(_vgaVersion == info.getVgaVersion()) && //
(_vgaName.equals(info.getVgaName())) && //
(_vgaDriverVersion.equals(info.getVgaDriverVersion())))
{
return true;
}
}
return false;
}
} }

View File

@@ -38,6 +38,10 @@ public class AccountVariables extends AbstractVariables
private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?"; private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?";
private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)"; private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)";
// Public variable names
public static final String HWID = "HWID";
public static final String HWIDSLIT_VAR = " ";
private final String _accountName; private final String _accountName;
public AccountVariables(String accountName) public AccountVariables(String accountName)

View File

@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
@@ -51,10 +54,12 @@ import org.l2jmobius.gameserver.model.entity.FortSiege;
import org.l2jmobius.gameserver.model.entity.GameEvent; import org.l2jmobius.gameserver.model.entity.GameEvent;
import org.l2jmobius.gameserver.model.entity.Siege; import org.l2jmobius.gameserver.model.entity.Siege;
import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder; import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.quest.Quest; import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect; import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.ConnectionState; import org.l2jmobius.gameserver.network.ConnectionState;
@@ -114,7 +119,9 @@ import org.l2jmobius.gameserver.util.BuilderUtil;
*/ */
public class EnterWorld implements IClientIncomingPacket public class EnterWorld implements IClientIncomingPacket
{ {
private final int[][] tracert = new int[5][4]; private static final Map<String, ClientHardwareInfoHolder> TRACE_HWINFO = new ConcurrentHashMap<>();
private final int[][] _tracert = new int[5][4];
@Override @Override
public boolean read(GameClient client, PacketReader packet) public boolean read(GameClient client, PacketReader packet)
@@ -123,7 +130,7 @@ public class EnterWorld implements IClientIncomingPacket
{ {
for (int o = 0; o < 4; o++) for (int o = 0; o < 4; o++)
{ {
tracert[i][o] = packet.readC(); _tracert[i][o] = packet.readC();
} }
} }
packet.readD(); // Unknown Value packet.readD(); // Unknown Value
@@ -151,11 +158,11 @@ public class EnterWorld implements IClientIncomingPacket
final String[] adress = new String[5]; final String[] adress = new String[5];
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; adress[i] = _tracert[i][0] + "." + _tracert[i][1] + "." + _tracert[i][2] + "." + _tracert[i][3];
} }
LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress); LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress);
client.setClientTracert(tracert); client.setClientTracert(_tracert);
player.broadcastUserInfo(); player.broadcastUserInfo();
@@ -669,10 +676,69 @@ public class EnterWorld implements IClientIncomingPacket
{ {
ThreadPool.schedule(() -> ThreadPool.schedule(() ->
{ {
if (client.getHardwareInfo() == null) // Generate trace string.
final StringBuilder sb = new StringBuilder();
for (int[] i : _tracert)
{ {
Disconnection.of(client).defaultSequence(false); for (int j : i)
return; {
sb.append(j);
sb.append(".");
}
}
final String trace = sb.toString();
// Get hardware info from client.
ClientHardwareInfoHolder hwInfo = client.getHardwareInfo();
if (hwInfo != null)
{
hwInfo.store(player);
TRACE_HWINFO.put(trace, hwInfo);
}
else
{
// Get hardware info from stored tracert map.
hwInfo = TRACE_HWINFO.get(trace);
if (hwInfo != null)
{
hwInfo.store(player);
client.setHardwareInfo(hwInfo);
}
// Get hardware info from account variables.
else
{
final String storedInfo = player.getAccountVariables().getString(AccountVariables.HWID, "");
if (!storedInfo.isEmpty())
{
hwInfo = new ClientHardwareInfoHolder(storedInfo);
TRACE_HWINFO.put(trace, hwInfo);
client.setHardwareInfo(hwInfo);
}
}
}
// Check max players.
if (Config.MAX_PLAYERS_PER_HWID > 0)
{
if (hwInfo == null)
{
Disconnection.of(client).defaultSequence(false);
}
else
{
int count = 0;
for (PlayerInstance plr : World.getInstance().getPlayers())
{
if ((plr.isOnlineInt() == 1) && (plr.getClient().getHardwareInfo().equals(hwInfo)))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
Disconnection.of(client).defaultSequence(false);
}
}
} }
}, 5000); }, 5000);
} }

View File

@@ -16,12 +16,8 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.GameClient; import org.l2jmobius.gameserver.network.GameClient;
/** /**
@@ -82,20 +78,5 @@ public class RequestHardWareInfo implements IClientIncomingPacket
public void run(GameClient client) public void run(GameClient client)
{ {
client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion)); client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion));
if (Config.HARDWARE_INFO_ENABLED && (Config.MAX_PLAYERS_PER_HWID > 0))
{
int count = 0;
for (PlayerInstance player : World.getInstance().getPlayers())
{
if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo())))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
Disconnection.of(client).defaultSequence(false);
}
}
} }
} }

View File

@@ -158,13 +158,12 @@ RestartOnDeadlock = False
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Player HWID settings (DO NOT USE) # Player HWID settings
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Check if hardware information is sent upon login. # Check if hardware information is sent upon login.
# Players without hardware information are kicked from the game. # Players without hardware information are kicked from the game.
# WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true. # WARNING: To receive hardware information from client, l2.ini NetSendHardWare must be set to true.
# WARNING: The file system\HardWare.ini must be deleted each time the player logins.(?)
# Default: False # Default: False
EnableHardwareInfo = False EnableHardwareInfo = False

View File

@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.model.holders; package org.l2jmobius.gameserver.model.holders;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
/** /**
* @author Mobius * @author Mobius
*/ */
@@ -64,6 +67,77 @@ public class ClientHardwareInfoHolder
_vgaDriverVersion = vgaDriverVersion; _vgaDriverVersion = vgaDriverVersion;
} }
public ClientHardwareInfoHolder(String info)
{
final String[] split = info.split(AccountVariables.HWIDSLIT_VAR);
_macAddress = split[0];
_windowsPlatformId = Integer.valueOf(split[1]);
_windowsMajorVersion = Integer.valueOf(split[2]);
_windowsMinorVersion = Integer.valueOf(split[3]);
_windowsBuildNumber = Integer.valueOf(split[4]);
_directxVersion = Integer.valueOf(split[5]);
_directxRevision = Integer.valueOf(split[6]);
_cpuName = split[7];
_cpuSpeed = Integer.valueOf(split[8]);
_cpuCoreCount = Integer.valueOf(split[9]);
_vgaCount = Integer.valueOf(split[10]);
_vgaPcxSpeed = Integer.valueOf(split[11]);
_physMemorySlot1 = Integer.valueOf(split[12]);
_physMemorySlot2 = Integer.valueOf(split[13]);
_physMemorySlot3 = Integer.valueOf(split[14]);
_videoMemory = Integer.valueOf(split[15]);
_vgaVersion = Integer.valueOf(split[16]);
_vgaName = split[17];
_vgaDriverVersion = split[18];
}
/**
* Save hardware info to account variables for later use.
* @param player The PlayerInstance related with this hardware info.
*/
public void store(PlayerInstance player)
{
final StringBuilder sb = new StringBuilder();
sb.append(_macAddress);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsPlatformId);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsMajorVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsMinorVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_windowsBuildNumber);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_directxVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_directxRevision);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuName);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuSpeed);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_cpuCoreCount);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaCount);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaPcxSpeed);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot1);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot2);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_physMemorySlot3);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_videoMemory);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaVersion);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaName);
sb.append(AccountVariables.HWIDSLIT_VAR);
sb.append(_vgaDriverVersion);
player.getAccountVariables().set(AccountVariables.HWID, sb.toString());
}
/** /**
* @return the macAddress * @return the macAddress
*/ */
@@ -215,4 +289,36 @@ public class ClientHardwareInfoHolder
{ {
return _vgaDriverVersion; return _vgaDriverVersion;
} }
@Override
public boolean equals(Object obj)
{
if (obj instanceof ClientHardwareInfoHolder)
{
final ClientHardwareInfoHolder info = (ClientHardwareInfoHolder) obj;
if ((_macAddress.equals(info.getMacAddress())) && //
(_windowsPlatformId == info.getWindowsPlatformId()) && //
(_windowsMajorVersion == info.getWindowsMajorVersion()) && //
(_windowsMinorVersion == info.getWindowsMinorVersion()) && //
(_windowsBuildNumber == info.getWindowsBuildNumber()) && //
(_directxVersion == info.getDirectxVersion()) && //
(_directxRevision == info.getDirectxRevision()) && //
(_cpuName.equals(info.getCpuName())) && //
(_cpuSpeed == info.getCpuSpeed()) && //
(_cpuCoreCount == info.getCpuCoreCount()) && //
(_vgaCount == info.getVgaCount()) && //
(_vgaPcxSpeed == info.getVgaPcxSpeed()) && //
(_physMemorySlot1 == info.getPhysMemorySlot1()) && //
(_physMemorySlot2 == info.getPhysMemorySlot2()) && //
(_physMemorySlot3 == info.getPhysMemorySlot3()) && //
(_videoMemory == info.getVideoMemory()) && //
(_vgaVersion == info.getVgaVersion()) && //
(_vgaName.equals(info.getVgaName())) && //
(_vgaDriverVersion.equals(info.getVgaDriverVersion())))
{
return true;
}
}
return false;
}
} }

View File

@@ -38,6 +38,10 @@ public class AccountVariables extends AbstractVariables
private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?"; private static final String DELETE_QUERY = "DELETE FROM account_gsdata WHERE account_name = ?";
private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)"; private static final String INSERT_QUERY = "INSERT INTO account_gsdata (account_name, var, value) VALUES (?, ?, ?)";
// Public variable names
public static final String HWID = "HWID";
public static final String HWIDSLIT_VAR = " ";
private final String _accountName; private final String _accountName;
public AccountVariables(String accountName) public AccountVariables(String accountName)

View File

@@ -16,6 +16,9 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
@@ -50,10 +53,12 @@ import org.l2jmobius.gameserver.model.entity.FortSiege;
import org.l2jmobius.gameserver.model.entity.GameEvent; import org.l2jmobius.gameserver.model.entity.GameEvent;
import org.l2jmobius.gameserver.model.entity.Siege; import org.l2jmobius.gameserver.model.entity.Siege;
import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder; import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.quest.Quest; import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect; import org.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
import org.l2jmobius.gameserver.model.variables.AccountVariables;
import org.l2jmobius.gameserver.model.variables.PlayerVariables; import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.ConnectionState; import org.l2jmobius.gameserver.network.ConnectionState;
@@ -111,7 +116,9 @@ import org.l2jmobius.gameserver.util.BuilderUtil;
*/ */
public class EnterWorld implements IClientIncomingPacket public class EnterWorld implements IClientIncomingPacket
{ {
private final int[][] tracert = new int[5][4]; private static final Map<String, ClientHardwareInfoHolder> TRACE_HWINFO = new ConcurrentHashMap<>();
private final int[][] _tracert = new int[5][4];
@Override @Override
public boolean read(GameClient client, PacketReader packet) public boolean read(GameClient client, PacketReader packet)
@@ -120,7 +127,7 @@ public class EnterWorld implements IClientIncomingPacket
{ {
for (int o = 0; o < 4; o++) for (int o = 0; o < 4; o++)
{ {
tracert[i][o] = packet.readC(); _tracert[i][o] = packet.readC();
} }
} }
packet.readD(); // Unknown Value packet.readD(); // Unknown Value
@@ -148,11 +155,11 @@ public class EnterWorld implements IClientIncomingPacket
final String[] adress = new String[5]; final String[] adress = new String[5];
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
adress[i] = tracert[i][0] + "." + tracert[i][1] + "." + tracert[i][2] + "." + tracert[i][3]; adress[i] = _tracert[i][0] + "." + _tracert[i][1] + "." + _tracert[i][2] + "." + _tracert[i][3];
} }
LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress); LoginServerThread.getInstance().sendClientTracert(player.getAccountName(), adress);
client.setClientTracert(tracert); client.setClientTracert(_tracert);
player.broadcastUserInfo(); player.broadcastUserInfo();
@@ -647,10 +654,69 @@ public class EnterWorld implements IClientIncomingPacket
{ {
ThreadPool.schedule(() -> ThreadPool.schedule(() ->
{ {
if (client.getHardwareInfo() == null) // Generate trace string.
final StringBuilder sb = new StringBuilder();
for (int[] i : _tracert)
{ {
Disconnection.of(client).defaultSequence(false); for (int j : i)
return; {
sb.append(j);
sb.append(".");
}
}
final String trace = sb.toString();
// Get hardware info from client.
ClientHardwareInfoHolder hwInfo = client.getHardwareInfo();
if (hwInfo != null)
{
hwInfo.store(player);
TRACE_HWINFO.put(trace, hwInfo);
}
else
{
// Get hardware info from stored tracert map.
hwInfo = TRACE_HWINFO.get(trace);
if (hwInfo != null)
{
hwInfo.store(player);
client.setHardwareInfo(hwInfo);
}
// Get hardware info from account variables.
else
{
final String storedInfo = player.getAccountVariables().getString(AccountVariables.HWID, "");
if (!storedInfo.isEmpty())
{
hwInfo = new ClientHardwareInfoHolder(storedInfo);
TRACE_HWINFO.put(trace, hwInfo);
client.setHardwareInfo(hwInfo);
}
}
}
// Check max players.
if (Config.MAX_PLAYERS_PER_HWID > 0)
{
if (hwInfo == null)
{
Disconnection.of(client).defaultSequence(false);
}
else
{
int count = 0;
for (PlayerInstance plr : World.getInstance().getPlayers())
{
if ((plr.isOnlineInt() == 1) && (plr.getClient().getHardwareInfo().equals(hwInfo)))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
Disconnection.of(client).defaultSequence(false);
}
}
} }
}, 5000); }, 5000);
} }

View File

@@ -16,12 +16,8 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder; import org.l2jmobius.gameserver.model.holders.ClientHardwareInfoHolder;
import org.l2jmobius.gameserver.network.Disconnection;
import org.l2jmobius.gameserver.network.GameClient; import org.l2jmobius.gameserver.network.GameClient;
/** /**
@@ -82,20 +78,5 @@ public class RequestHardWareInfo implements IClientIncomingPacket
public void run(GameClient client) public void run(GameClient client)
{ {
client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion)); client.setHardwareInfo(new ClientHardwareInfoHolder(_macAddress, _windowsPlatformId, _windowsMajorVersion, _windowsMinorVersion, _windowsBuildNumber, _directxVersion, _directxRevision, _cpuName, _cpuSpeed, _cpuCoreCount, _vgaCount, _vgaPcxSpeed, _physMemorySlot1, _physMemorySlot2, _physMemorySlot3, _videoMemory, _vgaVersion, _vgaName, _vgaDriverVersion));
if (Config.HARDWARE_INFO_ENABLED && (Config.MAX_PLAYERS_PER_HWID > 0))
{
int count = 0;
for (PlayerInstance player : World.getInstance().getPlayers())
{
if ((player.isOnlineInt() == 1) && (player.getClient().getHardwareInfo().equals(client.getHardwareInfo())))
{
count++;
}
}
if (count >= Config.MAX_PLAYERS_PER_HWID)
{
Disconnection.of(client).defaultSequence(false);
}
}
} }
} }