diff --git a/dist/ba_root/mods/changelogs.json b/dist/ba_root/mods/changelogs.json index f478784..3a0f551 100644 --- a/dist/ba_root/mods/changelogs.json +++ b/dist/ba_root/mods/changelogs.json @@ -38,6 +38,10 @@ "75": { "log": "bug fixes, BS 1.7.19 , season end notfication, server restart notification, more maps and games", "time": "4 March 2023" + }, + "76": { + "log": "added limit for max players per IP address , account at a time.", + "time": "5 March 2023" } } diff --git a/dist/ba_root/mods/custom_hooks.py b/dist/ba_root/mods/custom_hooks.py index 132a8c0..50cd1fd 100644 --- a/dist/ba_root/mods/custom_hooks.py +++ b/dist/ba_root/mods/custom_hooks.py @@ -25,7 +25,7 @@ from bastd.activity.coopscore import CoopScoreScreen import setting from chatHandle import handlechat -from features import team_balancer, afk_check, fire_flies, dual_team_score as newdts +from features import team_balancer, afk_check, fire_flies, hearts, dual_team_score as newdts from stats import mystats from spazmod import modifyspaz from tools import servercheck, ServerUpdate, logger, playlist @@ -78,6 +78,7 @@ def score_screen_on_begin(_stats: ba.Stats) -> None: """Runs when score screen is displayed.""" team_balancer.balanceTeams() mystats.update(_stats) + announcement.showScoreScreenAnnouncement() def playerspaz_init(playerspaz: ba.Player, node: ba.Node, player: ba.Player): @@ -194,7 +195,6 @@ def new_end(self, results: Any = None, delay: float = 0.0, force: bool = False): _ba.prop_axis(1, 0, 0) if isinstance(activity, CoopScoreScreen): team_balancer.checkToExitCoop() - announcement.showScoreScreenAnnouncement() org_end(self, results, delay, force) ba._activity.Activity.end = new_end @@ -251,7 +251,6 @@ def on_map_init(): from ba._servermode import ServerController - def shutdown(func) -> None: """Set the app to quit either now or at the next clean opportunity.""" def wrapper(*args, **kwargs): @@ -272,3 +271,18 @@ def shutdown(func) -> None: func(*args, **kwargs) return wrapper ServerController.shutdown = shutdown(ServerController.shutdown) + +from ba._session import Session +def on_player_request(func) -> bool: + def wrapper(*args, **kwargs): + player = args[1] + count = 0 + for current_player in args[0].sessionplayers: + if current_player.get_v1_account_id() == player.get_v1_account_id(): + count +=1 + if count >= settings["maxPlayersPerDevice"]: + _ba.screenmessage("Reached max players limit per device",clients=[player.inputdevice.client_id],transient=True,) + return False + return func(*args, **kwargs) + return wrapper +Session.on_player_request = on_player_request(Session.on_player_request) diff --git a/dist/ba_root/mods/setting.json b/dist/ba_root/mods/setting.json index 6a303c5..581b080 100644 --- a/dist/ba_root/mods/setting.json +++ b/dist/ba_root/mods/setting.json @@ -109,6 +109,8 @@ "minAgeToJoinInHours":24, "maxWarnCount":2, "WarnCooldownMinutes":30, + "maxAccountPerIP":1, + "maxPlayersPerDevice":1, "warnMsg":"WARNING !!!", "afterWarnKickMsg":"Enough warnings, Goodbye have a nice day :)", "firstTimeJoinMsg":"Welcome to the server,we r saving all your account details and chats", diff --git a/dist/ba_root/mods/tools/ServerUpdate.py b/dist/ba_root/mods/tools/ServerUpdate.py index 6011b6b..1889ec4 100644 --- a/dist/ba_root/mods/tools/ServerUpdate.py +++ b/dist/ba_root/mods/tools/ServerUpdate.py @@ -6,7 +6,7 @@ from efro.terminal import Clr import json import requests import _ba -VERSION=75 +VERSION=76 def check(): diff --git a/dist/ba_root/mods/tools/servercheck.py b/dist/ba_root/mods/tools/servercheck.py index 3e82551..3bd4159 100644 --- a/dist/ba_root/mods/tools/servercheck.py +++ b/dist/ba_root/mods/tools/servercheck.py @@ -31,11 +31,24 @@ class checkserver(object): def check(self): newPlayers = [] + ipClientMap = {} for ros in ba.internal.get_game_roster(): - + ip = _ba.get_client_ip(ros["client_id"]) + if ip not in ipClientMap: + ipClientMap[ip] = [ros["client_id"]] + else: + ipClientMap[ip].append(ros["client_id"]) + if len(ipClientMap[ip]) >= settings['maxAccountPerIP']: + _ba.chatmessage(f"Only {settings['maxAccountPerIP']} player per IP allowed, disconnecting this device.", clients=[ros["client_id"]]) + ba.internal.disconnect_client(ros["client_id"]) + logger.log(" Player disconnected, reached max players per IP address ||"+ ros["account_id"] , + "playerjoin") + continue newPlayers.append(ros['account_id']) if ros['account_id'] not in self.players and ros[ 'client_id'] != -1: + # new player joined lobby + d_str = ros['display_string'] d_str2 = profanity.censor(d_str) try: