public static string GeneratePassword(GameServer gameServer)
        {
            string fileZillaExecuteable = gameServer.FTPData.Executeable;
            string xmlDocument = gameServer.FTPData.XmlFile;
            string user = gameServer.FTPData.User;

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(xmlDocument);

            XmlNodeList userNodes = xmlDoc.SelectNodes("/FileZillaServer/Users/User");

            foreach (XmlNode userNode in userNodes) {
                if (userNode.Attributes["Name"].Value.Equals(user)) {
                    Console.WriteLine("I found the correct user: "******"Name"] != null && optionNode.Attributes["Name"].Value.Equals("Pass")) {
                            Console.WriteLine("BEFORE: " + optionNode.Attributes["Name"].Value + " == " + optionNode.InnerText);

                            string newPassword = Guid.NewGuid().ToString().Substring(0, 8);
                            Console.WriteLine("Generating MD5 for: " + newPassword);
                            string md5 = GenerateMD5(newPassword);

                            optionNode.InnerText = md5;

                            Console.WriteLine("AFTER: " + optionNode.Attributes["Name"].Value + " == " + optionNode.InnerText);

                            xmlDoc.Save(xmlDocument);
                            Process.Start(fileZillaExecuteable, "/reload-config");

                            return newPassword;
                        }
                    }
                    break;
                }
            }

            return null;
        }
 public void ServerOutput(GameServer server, string message)
 {
     if (this.messageLog.InvokeRequired) {
         SetTextCallback d = new SetTextCallback(Output);
         this.Invoke(d, new object[] { message });
     }
     else {
         messageLog.Items.Add(server.Id + ":: " + message);
         messageLog.SelectedIndex = messageLog.Items.Count - 1;
     }
 }
Example #3
0
        private void OnPerformanceTick(GameServer server, double ram, double cpu)
        {
            try {
                if (ram >= 220) {
                    server.PerformanceWarnings.Add("[" + DateTime.Now + "]" + " RAM usage too high: " + ram + " MB");
                    form.errorLog.Items.Add("[" + DateTime.Now + "]" + "RAM usage too high, Server " + server.Id + ", RAM (MB): " + ram + ", CPU: " + cpu);
                }

                if (cpu >= 10) {
                    server.PerformanceWarnings.Add("[" + DateTime.Now + "]" + "CPU usage too high: " + cpu + " %");
                    form.errorLog.Items.Add("[" + DateTime.Now + "]" + "CPU usage too high, Server " + server.Id + ", RAM (MB): " + ram + ", CPU: " + cpu);
                }

                if(server.PerformanceWarnings.Count > 100) {
                    List<string> messages;

                    if (server.Stop(out messages)) {
                        form.errorLog.Items.Add("[" + DateTime.Now + "]" + "PerformanceWarnings OVER 100:: Stopped server: " + string.Join(",", messages.ToArray()));
                    }
                }
            }
            catch (Exception ex) {
                form.Error("OnPerformanceTick:: " + ex.ToString());
            }
        }