示例#1
0
        public GameServerListConfig(XmlElement el)
        {
            foreach (XmlElement gs in el.GetElementsByTagName("game-server"))
            {
                string name = GetElementString(gs, "name");
                if (name == null)
                {
                    Console.WriteLine("Game server without name ignored");
                    continue;
                }

                string addressString = GetElementString(gs, "address");
                if (addressString == null)
                {
                    Console.WriteLine("Game server without address ignored");
                    continue;
                }

                string[] splitted = addressString.Split(new char[] { ':' }, 2);
                if (splitted.Length != 2)
                {
                    Console.WriteLine("Game server without port ignored");
                    continue;
                }

                IPAddress ip;
                try {
                    IPHostEntry he = Dns.Resolve(splitted[0]);
                    if (he.AddressList.Length == 0)
                    {
                        Console.WriteLine("Failed to resolve {0}", splitted[0]);
                        continue;
                    }
                    ip = he.AddressList[he.AddressList.Length - 1];
                } catch (Exception e) {
                    Console.WriteLine("Failed to resolve {0}: {1}", splitted[0], e);
                    continue;
                }

                short port;
                try {
                    port = Int16.Parse(splitted[1]);
                } catch {
                    Console.WriteLine("Invalid game server port ignored");
                    continue;
                }

                IPEndPoint address = new IPEndPoint(ip, port);

                bool sendAuthID = Config.GetElementBool(gs, "send-auth-id", false);
                bool query      = Config.GetElementBool(gs, "query", false);

                servers.Add(new GameServerConfig(name, address, sendAuthID, query));
            }
        }
示例#2
0
        public LoginConfig(XmlElement el)
        {
            ignoreAuthID       = Config.GetElementBool(el, "ignore-auth-id", false);
            autoCreateAccounts = Config.GetElementBool(el, "auto-create-accounts", false);
            accountDatabase    = GetElementString(el, "account-database");

            foreach (XmlElement priv in el.GetElementsByTagName("super-client"))
            {
                string ip = priv.InnerText;
                if (ip == null)
                {
                    continue;
                }
                ip = ip.Trim();
                if (ip == "")
                {
                    continue;
                }
                superClients[ip] = true;
            }
        }
示例#3
0
 public LoginConfig(XmlElement el)
 {
     ignoreAuthID = Config.GetElementBool(el, "ignore-auth-id", false);
 }