void OnServerStart() { PlayerConnected += OnPlayerConnected; PlayerDisconnected += OnPlayerDisconnected; if (!System.IO.Directory.Exists("scripts\\TeknoAntiVPN")) { System.IO.Directory.CreateDirectory("scripts\\TeknoAntiVPN"); } if (!System.IO.File.Exists(apiKeyTxt)) { WriteLog.Warning("Api key file doesn't exist. Creating... Please fill this out and restart the server"); System.IO.File.Create(apiKeyTxt); } if (!System.IO.File.Exists(ignoredPlayersTxt)) { WriteLog.Warning("Ignored Players file doesn't exist. Creating... "); System.IO.File.Create(ignoredPlayersTxt); } if (!System.IO.File.Exists(playersInGameTxt)) { WriteLog.Warning("PlayersInGame file doesn't exist. Creating... "); System.IO.File.Create(playersInGameTxt); } WriteLog.Info("AntiVPN by Mahjestic successfully started."); API_KEY = System.IO.File.ReadAllText(apiKeyTxt); }
public void OnPlayerConnected(Entity player) { playersInGame = System.IO.File.ReadAllLines(playersInGameTxt); foreach (string playerInGame in playersInGame) { if (player.Name == playerInGame) { WriteLog.Info($"{player.Name} has already been scanned...ignoring them."); return; } } WriteLog.Info($"Detecting if player {player.Name} has a VPN..."); if (isVPN(player.IP.Address.ToString(), player)) { AfterDelay(2000, () => Utilities.ExecuteCommand($"kickclient {player.GetEntityNumber()} \"^1Proxies and VPNs are not allowed in this server.\"")); WriteLog.Warning($"Player {player.Name} has a VPN. Kicking them out."); } else { WriteLog.Info($"Player {player.Name} does not have a VPN. Allowing them in."); } }