From f124a5adab9947b37aec4508f4a8dd3bc3d52593 Mon Sep 17 00:00:00 2001 From: Neon Date: Sun, 24 Nov 2024 02:21:02 +0100 Subject: [PATCH] MultiClientingService exclusion config --- game-server/config/main/security.properties | 3 +++ .../configs/main/SecurityConfig.java | 20 ++++++++++++++++++- .../player/MultiClientingService.java | 10 ++++++++-- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/game-server/config/main/security.properties b/game-server/config/main/security.properties index ea558c6fe..45e39b28e 100644 --- a/game-server/config/main/security.properties +++ b/game-server/config/main/security.properties @@ -109,6 +109,9 @@ gameserver.security.survey.delay.minute = 20 # SAME_FACTION - Players are allowed to log in multiple accounts per computer, but only log in characters of the same faction gameserver.security.multi_clienting.restriction_mode = NONE +# Comma separated list of MAC addresses that are allowed to log in regardless of the configured restrictions. +gameserver.security.multi_clienting.ignored_mac_addresses = + # If multi-clienting is restricted to the same faction, logging in characters of one faction will be denied until all characters of the opposite # faction have been offline for the specified amount of time. gameserver.security.multi_clienting.faction_switch_cooldown_minutes = 20 diff --git a/game-server/src/com/aionemu/gameserver/configs/main/SecurityConfig.java b/game-server/src/com/aionemu/gameserver/configs/main/SecurityConfig.java index 2291d42a5..303f3a545 100644 --- a/game-server/src/com/aionemu/gameserver/configs/main/SecurityConfig.java +++ b/game-server/src/com/aionemu/gameserver/configs/main/SecurityConfig.java @@ -1,9 +1,11 @@ package com.aionemu.gameserver.configs.main; +import java.util.Set; + import com.aionemu.commons.configuration.Property; public class SecurityConfig { - + @Property(key = "gameserver.security.aion.bin.check", defaultValue = "false") public static boolean AION_BIN_CHECK; @@ -70,9 +72,25 @@ public class SecurityConfig { @Property(key = "gameserver.security.survey.delay.minute", defaultValue = "20") public static int SURVEY_DELAY; + /** + * Restriction mode for multi-clienting:
+ * NONE - Players are allowed to log in multiple accounts per computer
+ * FULL - Players are allowed to log in one account per computer
+ * SAME_FACTION - Players are allowed to log in multiple accounts per computer, but only log in characters of the same faction
+ */ @Property(key = "gameserver.security.multi_clienting.restriction_mode", defaultValue = "NONE") public static MultiClientingRestrictionMode MULTI_CLIENTING_RESTRICTION_MODE; + /** + * Comma separated list of MAC addresses that are allowed to log in regardless of the configured restrictions. + */ + @Property(key = "gameserver.security.multi_clienting.ignored_mac_addresses", defaultValue = "") + public static Set MULTI_CLIENTING_IGNORED_MAC_ADDRESSES; + + /** + * If multi-clienting is restricted to the same faction, logging in characters of one faction will be denied until all characters of the opposite + * faction have been offline for the specified amount of time. + */ @Property(key = "gameserver.security.multi_clienting.faction_switch_cooldown_minutes", defaultValue = "20") public static int MULTI_CLIENTING_FACTION_SWITCH_COOLDOWN_MINUTES; diff --git a/game-server/src/com/aionemu/gameserver/services/player/MultiClientingService.java b/game-server/src/com/aionemu/gameserver/services/player/MultiClientingService.java index 930f1a3c6..3d9d412ca 100644 --- a/game-server/src/com/aionemu/gameserver/services/player/MultiClientingService.java +++ b/game-server/src/com/aionemu/gameserver/services/player/MultiClientingService.java @@ -22,7 +22,7 @@ public class MultiClientingService { private static final Map sessionsByAccountId = new ConcurrentHashMap<>(); public static boolean tryEnterWorld(Player player, AionConnection con) { - if (SecurityConfig.MULTI_CLIENTING_RESTRICTION_MODE == MultiClientingRestrictionMode.FULL) { + if (SecurityConfig.MULTI_CLIENTING_RESTRICTION_MODE == MultiClientingRestrictionMode.FULL && !SecurityConfig.MULTI_CLIENTING_IGNORED_MAC_ADDRESSES.contains(con.getMacAddress())) { String mac = con.getMacAddress(); String hdd = con.getHddSerial(); String ip = con.getIP(); @@ -58,10 +58,12 @@ public static void onLeaveWorld(Player player) { } public static Integer checkForFactionSwitchCooldownTime(Race race, AionConnection con) { + if (SecurityConfig.MULTI_CLIENTING_IGNORED_MAC_ADDRESSES.contains(con.getMacAddress())) + return null; Race oppositeRace = race == Race.ELYOS ? Race.ASMODIANS : Race.ELYOS; long minLastOnlineMillis = System.currentTimeMillis() - Duration.ofMinutes(SecurityConfig.MULTI_CLIENTING_FACTION_SWITCH_COOLDOWN_MINUTES).toMillis(); return sessionsByAccountId.values().stream() - .filter(s -> s.wasPlayingOnSameIpOrMac(oppositeRace, minLastOnlineMillis, con)) + .filter(s -> !s.isIgnored() && s.wasPlayingOnSameIpOrMac(oppositeRace, minLastOnlineMillis, con)) .findAny() .map(s -> s.accountId) .orElse(null); @@ -77,6 +79,10 @@ public AccountSession(int accountId) { this.accountId = accountId; } + synchronized boolean isIgnored() { + return !identifiers.isEmpty() && SecurityConfig.MULTI_CLIENTING_IGNORED_MAC_ADDRESSES.contains(identifiers.getFirst().mac); + } + synchronized void putIdentifiers(AionConnection connection) { Identifiers ids = new Identifiers(connection.getIP(), connection.getMacAddress()); if (!identifiers.contains(ids)) {