/// <summary> /// Sends a RCON command to a server /// </summary> /// <param name="command">Command to send</param> /// <param name="server">3 letter server code</param> /// <returns>Output from RCON command</returns> public async Task <string> RconCommand(string command, LevelTestingServer server) { string reply = null; //Get the bots IP, typically my IP string botIp = new WebClient().DownloadString("http://icanhazip.com").Trim(); IPHostEntry iPHostEntry = null; try { iPHostEntry = Dns.GetHostEntry(server.Address); } catch { return("HOST_NOT_FOUND"); } //Setup new RCON object using (var rcon = new RCON(IPAddress.Parse($"{iPHostEntry.AddressList[0]}"), 27015, server.Password)) { //Send the RCON command to the server reply = await rcon.SendCommandAsync(command); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine($"{DateTime.Now}\nRCON COMMAND: {server.Address}\nCommand: {command}\n"); Console.ResetColor(); } //Remove the Bot's public IP from the string. reply = reply.Replace($"{botIp}", "69.420.MLG.1337"); return(reply); }
public void Start(IReadOnlyList <string> testInfo, LevelTestingServer server) { if (!worker.IsBusy) { // RunWorkerAsync raises the DoWork event. worker.RunWorkerAsync((testInfo, server)); } }
protected Downloader(IReadOnlyList <string> testInfo, LevelTestingServer server, DataServices dataSvc) { DataSvc = dataSvc; DateTime time = Convert.ToDateTime(testInfo[1]); string title = testInfo[2].Substring(0, testInfo[2].IndexOf(" ")); DemoName = $"{time:MM_dd_yyyy}_{title}"; FtpPath = server.FtpPath; LocalPath = $"{DataSvc.DemoPath}\\{time:yyyy}\\{time:MM} - " + $"{time:MMMM}\\{DemoName}"; WorkshopId = Regex.Match(testInfo[6], @"\d+$").Value; }
public FtpDownloader(IReadOnlyList <string> testInfo, LevelTestingServer server, DataServices dataSvc) : base(testInfo, server, dataSvc) { gamemode = testInfo[7]; Client = new FtpClient(server.Address, server.FtpUser, server.FtpPass); if (server.FtpType == "ftps") { Client.EncryptionMode = FtpEncryptionMode.Explicit; Client.SslProtocols = SslProtocols.Tls; Client.ValidateCertificate += (control, e) => { e.Accept = true; }; } }
public SftpDownloader(IReadOnlyList <string> testInfo, LevelTestingServer server, DataServices dataSvc) : base(testInfo, server, dataSvc) { Client = new SftpClient(testInfo[10], server.FtpUser, server.FtpPass); }