Beispiel #1
0
        static void ParseZone(Level lvl, ref byte[] buffer, Stream gs)
        {
            Zone z = new Zone();

            z.MinX = Read_U16(buffer, gs); z.MaxX = Read_U16(buffer, gs);
            z.MinY = Read_U16(buffer, gs); z.MaxY = Read_U16(buffer, gs);
            z.MinZ = Read_U16(buffer, gs); z.MaxZ = Read_U16(buffer, gs);

            int metaCount = TryRead_I32(buffer, gs);

            ConfigElement[] elems = Server.zoneConfig;

            for (int j = 0; j < metaCount; j++)
            {
                int size = Read_U16(buffer, gs);
                if (size > buffer.Length)
                {
                    buffer = new byte[size + 16];
                }
                gs.Read(buffer, 0, size);

                string line = Encoding.UTF8.GetString(buffer, 0, size), key, value;
                PropertiesFile.ParseLine(line, '=', out key, out value);
                if (key == null)
                {
                    continue;
                }

                value = value.Trim();
                ConfigElement.Parse(elems, z.Config, key, value);
            }
            z.AddTo(lvl);
        }
Beispiel #2
0
        static void RetrieveProps(string level, out LevelPermission visit,
                                  out LevelPermission build, out bool loadOnGoto)
        {
            visit      = LevelPermission.Guest;
            build      = LevelPermission.Guest;
            loadOnGoto = true;
            Group grp;

            string file = LevelInfo.FindPropertiesFile(level);

            if (file == null)
            {
                return;
            }
            SearchArgs args = new SearchArgs();

            PropertiesFile.Read(file, ref args, ProcessLine);

            grp = args.Visit == null ? null : Group.Find(args.Visit);
            if (grp != null)
            {
                visit = grp.Permission;
            }
            grp = args.Build == null ? null : Group.Find(args.Build);
            if (grp != null)
            {
                build = grp.Permission;
            }
            if (!bool.TryParse(args.LoadOnGoto, out loadOnGoto))
            {
                loadOnGoto = true;
            }
        }
        public void TestAddAndRetrievePropertiesWithoutAttributes()
        {
            const string fileName = "no_attributes.xml";

            // Delete existing file.
            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }

            // Create new properties.
            var properties = new PropertiesFile(fileName);

            var test1Property = new Property("test1", "test1Value");
            var test2Property = new Property("test2", "test2Value");

            // Write properties
            properties.AddProperty(test1Property);
            properties.AddProperty(test2Property);

            // Read properties
            var test1Properties = properties.GetPropertiesByKey(test1Property.Key).ToArray();
            var test2Properties = properties.GetPropertiesByKey(test2Property.Key).ToArray();

            // Check lengths
            Assert.AreEqual(1, test1Properties.Length);
            Assert.AreEqual(1, test2Properties.Length);

            // Check contents
            Assert.AreEqual(test1Property, test1Properties[0]);
            Assert.AreEqual(test2Property, test2Properties[0]);
        }
Beispiel #4
0
 public void Retrieve(string mapName)
 {
     if (elems == null)
     {
         elems = ConfigElement.GetAll(typeof(CTFConfig));
     }
     PropertiesFile.Read("CTF/" + mapName + ".config", LineProcessor);
 }
Beispiel #5
0
        static void WritePatchVersion(string versionFile, string taskName, int version)
        {
            PropertiesFile properties = new PropertiesFile(versionFile);

            properties.Write(taskName, "version", version.ToString());
            properties.Write(taskName, "timpspan", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            properties.Save(versionFile);
        }
Beispiel #6
0
 public override void Load()
 {
     if (cfg == null)
     {
         cfg = ConfigElement.GetAll(typeof(ZSConfig));
     }
     PropertiesFile.Read(PropsPath, ProcessConfigLine);
 }
Beispiel #7
0
        static void ReadZonesSection(Level lvl, Stream gs)
        {
            byte[] buffer = new byte[sizeof(int)];
            int    count  = TryRead_I32(buffer, gs);

            if (count == 0)
            {
                return;
            }

            for (int i = 0; i < count; i++)
            {
                Zone z = new Zone(lvl);
                if (!TryRead_U16(buffer, gs, ref z.MinX) || !TryRead_U16(buffer, gs, ref z.MaxX))
                {
                    return;
                }
                if (!TryRead_U16(buffer, gs, ref z.MinY) || !TryRead_U16(buffer, gs, ref z.MaxY))
                {
                    return;
                }
                if (!TryRead_U16(buffer, gs, ref z.MinZ) || !TryRead_U16(buffer, gs, ref z.MaxZ))
                {
                    return;
                }

                int             metaCount = TryRead_I32(buffer, gs);
                ConfigElement[] elems     = Server.zoneConfig;

                for (int j = 0; j < metaCount; j++)
                {
                    ushort size = 0;
                    if (!TryRead_U16(buffer, gs, ref size))
                    {
                        return;
                    }
                    if (size > buffer.Length)
                    {
                        buffer = new byte[size + 16];
                    }
                    gs.Read(buffer, 0, size);

                    string line = Encoding.UTF8.GetString(buffer, 0, size), key, value;
                    PropertiesFile.ParseLine(line, '=', out key, out value);
                    if (key == null)
                    {
                        continue;
                    }

                    value = value.Trim();
                    ConfigElement.Parse(elems, key, value, z.Config);
                }

                z.AddTo(lvl);
            }
        }
Beispiel #8
0
        public static void Load()
        {
            aliases.Clear();
            coreAliases.Clear();

            if (!File.Exists(Paths.AliasesFile))
            {
                Save(); return;
            }
            PropertiesFile.Read(Paths.AliasesFile, LineProcessor, ':');
        }
Beispiel #9
0
 internal LolClient(string directory, PropertiesFile properties, LolProxy proxy)
 {
     if (proxy == null)
         throw new ArgumentNullException("proxy");
     if(!Directory.Exists(directory))
         throw new ArgumentException("directory");
     GameData = new LolClientGameData(Path.Combine(directory, GameDataFile));
     Images = new LolClientImages(directory, GameData);
     Connection=new LolConnection(proxy);
     Properties = properties;
 }
Beispiel #10
0
        static void LoadConfig()
        {
            configs.Clear();

            AuthServiceConfig cur = null;

            PropertiesFile.Read(Paths.AuthServicesFile, ref cur, ParseProperty, '=', true);
            if (cur != null)
            {
                configs.Add(cur);
            }
        }
        public void TestLoadValidPropertiesFiles()
        {
            var properties = new PropertiesFile("valid_properties.xml");

            // Read properties
            var test1Properties = properties.GetPropertiesByKey("test1").ToArray();
            var test2Properties = properties.GetPropertiesByKey("test2").ToArray();

            // Check lengths
            Assert.AreEqual(1, test1Properties.Length);
            Assert.AreEqual(1, test2Properties.Length);
        }
Beispiel #12
0
        public void LoadSettings()
        {
            if (!File.Exists("properties/lavasurvival.properties"))
            {
                SaveSettings(); return;
            }

            try {
                PropertiesFile.Read("properties/lavasurvival.properties", ProcessSettingsLine);
            } catch (Exception e) {
                Server.ErrorLog(e);
            }
        }
Beispiel #13
0
 /// <summary> Load a map into CTF </summary>
 /// <param name="map">The map to load</param>
 public void LoadMap(string map)
 {
     mapname = map;
     PropertiesFile.Read("CTF/" + mapname + ".config", LineProcessor);
     Command.all.Find("unload").Use(null, "ctf");
     if (File.Exists("levels/ctf.lvl"))
     {
         File.Delete("levels/ctf.lvl");
     }
     File.Copy("CTF/maps/" + mapname + ".lvl", "levels/ctf.lvl");
     CmdLoad.LoadLevel(null, "ctf");
     mainlevel = LevelInfo.FindExact("ctf");
 }
Beispiel #14
0
 internal LolClient(string directory, PropertiesFile properties, LolProxy proxy)
 {
     if (proxy == null)
     {
         throw new ArgumentNullException("proxy");
     }
     if (!Directory.Exists(directory))
     {
         throw new ArgumentException("directory");
     }
     GameData   = new LolClientGameData(Path.Combine(directory, GameDataFile));
     Images     = new LolClientImages(directory, GameData);
     Connection = new LolConnection(proxy);
     Properties = properties;
 }
Beispiel #15
0
        public static void LoadList()
        {
            if (!File.Exists("extra/teams.txt"))
            {
                return;
            }
            Team team = new Team();

            lock (ioLock)
                PropertiesFile.Read("extra/teams.txt", ref team, LineProcessor, '=');
            if (team.Name != null)
            {
                TeamsList[team.Name] = team;
            }
        }
Beispiel #16
0
        public static void Load()
        {
            if (!File.Exists("text/awardsList.txt"))
            {
                using (StreamWriter w = new StreamWriter("text/awardsList.txt")) {
                    WriteHeader(w);
                    w.WriteLine("Gotta start somewhere : Built your first house");
                    w.WriteLine("Climbing the ladder : Earned a rank advancement");
                    w.WriteLine("Do you live here? : Joined the server a huge bunch of times");
                }
            }

            Awards = new List <Award>();
            PropertiesFile.Read("text/awardsList.txt", ProcessLine, ':');
        }
        public void TestCreatePropertiesFile()
        {
            const string fileName = "test_creation.xml";

            // Delete existing file.
            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }

            // Create new properties.
            var properties = new PropertiesFile(fileName);

            // Check file existence.
            Assert.IsTrue(File.Exists(fileName));
        }
Beispiel #18
0
        public static void LoadList()
        {
            if (!File.Exists("extra/teams.txt"))
            {
                return;
            }
            Team tmp = new Team();

            lock (ioLock)
                PropertiesFile.Read("extra/teams.txt", ref tmp, LineProcessor, '=');

            if (tmp.Name != null)
            {
                Add(tmp);
            }
        }
Beispiel #19
0
        public static void Start(string dbPath)
        {
            LoginDatabase = new PropertiesFile(dbPath);
            LoginDatabase.Load();

            if (LoginDatabase.Count == 0)
            {
                var bytes = new byte[8];
                (new Random((int)DateTime.Now.Ticks)).NextBytes(bytes);

                string password = String.Format("{0:x2}{1:x2}-{2:x2}{3:x2}-{4:x2}{5:x2}-{6:x2}{7:x2}",
                                                bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7]);
                string login = "******";
                ProgramLog.Admin.Log("The rcon login database was empty, a new user \"{1}\" has been created with password: {0}", password, login);

                LoginDatabase.setValue(login, Hash(login, password));
            }

            LoginDatabase.Save();

            var       bind  = Program.properties.RConBindAddress;
            var       split = bind.Split(':');
            IPAddress addr;
            ushort    port;

            if (split.Length != 2 || !IPAddress.TryParse(split[0], out addr) || !ushort.TryParse(split[1], out port) || port < 1)
            {
                ProgramLog.Error.Log("{0} is not a valid bind address, remote console disabled.", bind);
                return;
            }

            listener = new TcpListener(addr, port);

            try
            {
                listener.Start();
            }
            catch (Exception)
            {
                ProgramLog.Error.Log("Failed to bind to address {0}, remote console disabled.", bind);
                //ProgramLog.Log (exception, "Failed to bind to address 127.0.0.1:" + 7776);
                return;
            }

            thread = new ProgramThread("RCon", RConLoop);
            thread.Start();
        }
Beispiel #20
0
        public void LoadSettings()
        {
            if (!File.Exists("properties/lavasurvival.properties"))
            {
                SaveSettings(); return;
            }

            try {
                PropertiesFile.Read("properties/lavasurvival.properties", ProcessSettingsLine);
                if (needsSaveSettings)
                {
                    SaveSettings();
                }
            } catch (Exception e) {
                Logger.LogError(e);
            }
        }
Beispiel #21
0
        //Converts settings to json file then saves it
        public static void SaveProperties()
        {
            string dir = startDir + PropertiesFilePath;

            PropertiesFile propFile = new PropertiesFile();

            propFile.GameDir         = GameDir;
            propFile.SelectedKitName = SelectedKitName;
            propFile.MasterVolume    = MasterVolume;
            Console.WriteLine(propFile.GameDir);

            string jsonFile = JsonConvert.SerializeObject(propFile);

            Console.WriteLine("Saving json properties: ");
            Console.WriteLine(jsonFile);
            File.WriteAllText(dir, jsonFile);
        }
Beispiel #22
0
        /// <summary>
        /// Initializes the properties file and checks for errors.
        /// Also checks for missing properties and writes their default values.
        /// </summary>
        private static GameServerConfiguration InitializeProperties()
        {
            // If there is no properties file, generate one.
            if (!File.Exists(PropertiesFilePath))
            {
                // Create a new properties file.
                var properties = new PropertiesFile(PropertiesFilePath);

                // Create a config with defaults.
                var config = new GameServerConfiguration();

                // Write defaults to properties file.
                properties.SetProperties(config.ToProperties());

                return(config);
            }

            // A properties file exists, so try to read it.
            try
            {
                // Read the properties file.
                var properties = new PropertiesFile(PropertiesFilePath);

                // Create a config with defaults.
                var config = new GameServerConfiguration();

                // Populate the config with the properties file.
                config.FromProperties(properties.GetAllProperties());

                // Write the config back to the properties file, in case any defaults were inferred.
                properties.SetProperties(config.ToProperties());

                return(config);
            }
            catch (IOException)
            {
                // Could not load properties file.
                // Log error and quit.
                Logger.Log(LogLevel.Fatal, Resources.GameServer_Log_PropertiesLoadFailed);
                Console.Read();
                Environment.Exit(-1);
            }

            return(null);
        }
Beispiel #23
0
        protected override void Initialized(object state)
        {
            string pluginFolder = Statics.PluginPath + Path.DirectorySeparatorChar + "map";

            CreateDirectory(pluginFolder);

            properties = new PropertiesFile(pluginFolder + Path.DirectorySeparatorChar + "map.properties");
            properties.Load();
            var dummy  = mapoutputpath;
            var dummy2 = colorscheme;
            var dummy3 = autosavepath;
            var dummy4 = autosaveinterval;
            var dummy5 = autosavetimestamp;
            var dummy6 = autosavehighlight;
            var dummy7 = autosavehightlightID;
            var dummy8 = autosaveenabled;
            var dummy9 = autosavename;

            properties.Save();

            if (colorscheme == "MoreTerra" || colorscheme == "Terrafirma")
            {
                isEnabled = true;
            }
            else
            {
                ProgramLog.Error.Log("<map> ERROR: colorscheme must be either 'MoreTerra' or 'Terrafirma'");
                ProgramLog.Error.Log("<map> ERROR: map command will not work until you change it");
                isEnabled = false;
            }

            AddCommand("map")
            .WithDescription("map options")
            .WithAccessLevel(AccessLevel.OP)
            .WithHelpText("map help")
            .WithHelpText("map -t")
            .WithHelpText("map -n outputname.png")
            .WithHelpText("map -L")
            .WithHelpText("map [-s] -p /path/to/output")
            .WithHelpText("map [-s] -p \"C:\\path\\to\\output\"")
            .WithHelpText("map [-s] -c MoreTerra")
            .WithHelpText("map [-s] -c Terrafirma")
            .WithHelpText("map -h \"name or ID of item to highlight\"")
            .Calls(this.MapCommand);
        }
Beispiel #24
0
            public void FromOfflineLevel(string name)
            {
                this.Name = name;
                string  path = LevelInfo.LevelPath(name);
                Vec3U16 dims = IMapImporter.Formats[0].ReadDimensions(path);

                Width = dims.X; Height = dims.Y; Length = dims.Z;

                path = LevelInfo.FindPropertiesFile(name);
                if (path != null)
                {
                    PropertiesFile.Read(path, ParseProperty, '=');
                }
                if (Authors == null)
                {
                    Authors = "";
                }
            }
Beispiel #25
0
        static void ReadViewmode()
        {
            PlatformID platform = Environment.OSVersion.Platform;

            useConsole = !(platform == PlatformID.Win32NT || platform == PlatformID.Win32Windows);

            if (!File.Exists("Viewmode.cfg"))
            {
                using (StreamWriter w = new StreamWriter("Viewmode.cfg")) {
                    w.WriteLine("#This file controls how the console window is shown to the server host");
                    w.WriteLine("#cli: True or False (Determines whether a CLI interface is used) (Set True if on Mono)");
                    w.WriteLine("#high-quality: True or false (Determines whether the GUI interface uses higher quality objects)");
                    w.WriteLine();
                    w.WriteLine("cli = " + useConsole);
                    w.WriteLine("high-quality = true");
                }
            }
            PropertiesFile.Read("Viewmode.cfg", ViewmodeLineProcessor);
        }
        public void TestAddAndRetrieveMultipleOfSameProperties()
        {
            const string fileName = "save_load_multiple.xml";

            // Delete existing file.
            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }

            // Create new properties.
            var properties = new PropertiesFile(fileName);

            var attributes1 = new Dictionary <string, string> {
                ["test1Attr"] = "test1AttrValue"
            };
            var attributes2 = new Dictionary <string, string> {
                ["test2Attr"] = "test2AttrValue"
            };

            var test1Property = new Property("test1", "test1Value", attributes1);
            var test2Property = new Property("test2", "test2Value", attributes2);
            var test3Property = new Property("test1", "test1Value2");

            // Write properties
            properties.AddProperty(test1Property);
            properties.AddProperty(test2Property);
            properties.AddProperty(test3Property);

            // Read properties
            var test1Properties = properties.GetPropertiesByKey(test1Property.Key).ToArray();
            var test2Properties = properties.GetPropertiesByKey(test2Property.Key).ToArray();

            // Check lengths
            Assert.AreEqual(2, test1Properties.Length);
            Assert.AreEqual(1, test2Properties.Length);

            // Check contents
            Assert.AreEqual(test1Property, test1Properties[0]);
            Assert.AreEqual(test2Property, test2Properties[0]);
            Assert.AreEqual(test3Property, test1Properties[1]);
        }
Beispiel #27
0
        static int ReadPatchVersion(string versionFile, string taskName, string versionType, int version, ref DateTime timespan)
        {
            if (!File.Exists(versionFile))
            {
                FileHelper.Create(versionFile);
            }

            PropertiesFile properties = new PropertiesFile(versionFile);

            string versionValue  = properties.Read(taskName, "version");
            string timpspanValue = properties.Read(taskName, "timpspan");

            DateTime latestTimespan = DateTime.MinValue;

            if (!string.IsNullOrEmpty(timpspanValue))
            {
                latestTimespan = Convert.ToDateTime(timpspanValue);
            }

            if (string.IsNullOrEmpty(versionValue))
            {
                version = 0;
            }
            else
            {
                if (!string.IsNullOrEmpty(versionValue) && versionType == "DailyIncrement")
                {
                    version = (latestTimespan.Day == DateTime.Now.Day) ? Convert.ToInt32(versionValue) : 0;
                }
                else
                {
                    version = Convert.ToInt32(versionValue);
                }

                if (timespan == DateTime.MinValue)
                {
                    timespan = Convert.ToDateTime(timpspanValue);
                }
            }

            return(version);
        }
Beispiel #28
0
        // returns true if an update was found, false otherwise
        private bool DoCheckForUpdatesInternal()
        {
            var result = false;

            logger.Info("Checking for updates from " + URL);

            // download the properties file
            var webClient         = new WebClient();
            var versionProperties = webClient.DownloadString(URL);

            // extract version details
            var properties   = PropertiesFile.ReadProperties(versionProperties, "version.properties");
            var versionStr   = properties[PROPERTY_VERSION_NUMBER];
            var installerUrl = properties[PROPERTY_INSTALLER_URL];

            var version        = new Version(versionStr);
            var currentVersion = GetCurrentVersion();

            logger.Info("Current version: " + currentVersion);
            logger.Info("Last version: " + version);
            logger.Info("Installer URL: " + installerUrl);

            if (version <= currentVersion)
            {
                logger.Info("No updates");
            }
            else
            {
                logger.Info("An update is available");

                // disable the timer
                EnableTimer(false);

                if (NewVersionAvailable != null)
                {
                    NewVersionAvailable(version, installerUrl);
                }

                result = true;
            }
            return(result);
        }
Beispiel #29
0
        public static void Load()
        {
            if (!File.Exists("text/awardsList.txt"))
            {
                using (StreamWriter w = new StreamWriter("text/awardsList.txt")) {
                    w.WriteLine("#This is a full list of awards. The server will load these and they can be awarded as you please");
                    w.WriteLine("#Format is:");
                    w.WriteLine("# AwardName : Description of award goes after the colon");
                    w.WriteLine();
                    w.WriteLine("Gotta start somewhere : Built your first house");
                    w.WriteLine("Climbing the ladder : Earned a rank advancement");
                    w.WriteLine("Do you live here? : Joined the server a huge bunch of times");
                }
            }

            AwardsList = new List <Award>();
            PropertiesFile.Read("text/awardsList.txt", AwardsListLineProcessor, ':');
            PlayerAwards = new List <PlayerAward>();
            PropertiesFile.Read("text/playerAwards.txt", PlayerAwardsLineProcessor, ':');
        }
Beispiel #30
0
            public void FromOfflineLevel(string name)
            {
                this.name = name;
                LvlFile.LoadDimensions(LevelInfo.LevelPath(name),
                                       out Width, out Height, out Length);
                string path = LevelInfo.GetPropertiesPath(name);

                Server.s.Log(path);
                if (path != null)
                {
                    PropertiesFile.Read(path, ParseProperty, '=');
                }

                path = "levels/level properties/" + name + ".env";
                Server.s.Log(path);
                if (File.Exists(path))
                {
                    PropertiesFile.Read(path, ParseEnv, '=');
                }
            }
Beispiel #31
0
        //Reads properties file then deserializes it
        public static void LoadProperties()
        {
            //startDir = Directory.GetCurrentDirectory();
            startDir = GetAppDirectory();
            Console.WriteLine("App Directory: " + startDir);
            string         dir = startDir + PropertiesFilePath;
            PropertiesFile propFile;

            try
            {
                string jsonFile = File.ReadAllText(dir);
                propFile        = JsonConvert.DeserializeObject <PropertiesFile>(jsonFile);
                GameDir         = propFile.GameDir;
                SelectedKitName = propFile.SelectedKitName;
                MasterVolume    = propFile.MasterVolume;
            }
            catch (FileNotFoundException e)
            {
                propFile = new PropertiesFile();
            }
        }
        public static void Start(string dbPath)
        {
            LoginDatabase = new PropertiesFile(dbPath);
            LoginDatabase.Load();

            if (String.IsNullOrEmpty(Entry.RConHashNonce))
            {
                var nonceFile = Path.Combine(Globals.DataPath, "rcon.nonce");

                if (File.Exists(nonceFile))
                    Entry.RConHashNonce = File.ReadAllText(nonceFile);

                if (String.IsNullOrEmpty(Entry.RConHashNonce))
                {
                    ProgramLog.Admin.Log("The rcon nonce value has not been set, one is being generated...");
                    var rand = new Random(Main.rand.Next(Int32.MinValue, Int32.MaxValue));
                    var length = rand.Next(12, 32);
                    var sb = new StringBuilder(length);

                    while (sb.Length != length)
                    {
                        System.Threading.Thread.Sleep(rand.Next(0, 200));

                        var chr = (char)(byte)rand.Next(0x20, 0x7E);
                        sb.Append(chr);
                    }
                    Entry.RConHashNonce = sb.ToString();
                    File.WriteAllText(nonceFile, Entry.RConHashNonce);
                    ProgramLog.Admin.Log("Saved nonce to {0}", nonceFile);
                }
            }

            if (LoginDatabase.Count == 0)
            {
                var bytes = new byte[8];
                (new Random((int)DateTime.Now.Ticks)).NextBytes(bytes);

                string password = String.Format("{0:x2}{1:x2}-{2:x2}{3:x2}-{4:x2}{5:x2}-{6:x2}{7:x2}",
                    bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7]);
                string login = "******";
                ProgramLog.Admin.Log("The rcon login database was empty, a new user \"{1}\" has been created with password: {0}", password, login);

                LoginDatabase.SetValue(login, Hash(login, password));
            }

            LoginDatabase.Save();

            var bind = Entry.RConBindAddress;
            var split = bind.Split(':');
            IPAddress addr;
            ushort port;

            if (split.Length != 2 || !IPAddress.TryParse(split[0], out addr) || !ushort.TryParse(split[1], out port) || port < 1)
            {
                ProgramLog.Error.Log("{0} is not a valid bind address, remote console disabled.", bind);
                return;
            }

            listener = new TcpListener(addr, port);

            try
            {
                listener.Start();
            }
            catch (Exception)
            {
                ProgramLog.Error.Log("Failed to bind to address {0}, remote console disabled.", bind);
                //ProgramLog.Log (exception, "Failed to bind to address 127.0.0.1:" + 7776);
                return;
            }

            thread = new ProgramThread("RCon", RConLoop);
            thread.Start();
        }
        void ProcessInjector_ProcessFound(object sender, Process e)
        {
            ProcessInjector pi = sender as ProcessInjector;
            if (pi == null) return;

            //sometimes it takes a while for the main module to be loaded...
            while (e.MainWindowHandle == IntPtr.Zero)
                Thread.Sleep(1000);
            #if AIRDEBUG && DEBUG
            string loldir = null;
            string wmiQuery = string.Format("select CommandLine from Win32_Process where Name='{0}'", "adl.exe");
            ManagementObjectSearcher searcher = new ManagementObjectSearcher(wmiQuery);
            ManagementObjectCollection retObjectCollection = searcher.Get();
            foreach (ManagementObject retObject in retObjectCollection)
                loldir = ProcessHelper.SplitCommandLineArgs((string)retObject["CommandLine"])[2];
            #else
            var loldir = Path.GetDirectoryName(e.MainModule.FileName)??string.Empty;
            #endif
            _lolProperties = new PropertiesFile(Path.Combine(loldir, LolPropertiesFilename));
            var host = _lolProperties["host"];
            _rtmpAddress = host.Contains(",") ? host.Substring(0, host.IndexOf(',')) : host;

            if (_rtmpAddress == null) return;

            _certificate = GetCertificate(_rtmpAddress);

            if (_certificate == null)
            {
                Dispatcher.Invoke(() => MessageBox.Show(this, "This program is not compatible with your region: " + _lolProperties["platformId"] + ".\n", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning));

                return;
            }

            if (!IsInstalled(_certificate))
            {
                MessageBoxResult res = MessageBoxResult.None;

                Dispatcher.Invoke(() => res = MessageBox.Show(this, "A certificate needs to be installed.\n\n" +
                                                "You can see which certificates are installed under Views->FinalesFunkeln->Certificates and uninstall them at any time.\n\nInstall the certificate now?", "Confirmation",
                                                MessageBoxButton.YesNo, MessageBoxImage.Information));
                if (res != MessageBoxResult.Yes)
                    return;
                InstallCertificate(_certificate);

            }

            InitProxy();
            _lolClient = new LolClient(loldir, _lolProperties, _proxy);
            _extensionManager.FireLolClientInjectedEvent(_lolClient);
            try
            {
                pi.Inject();
                _lolClientProcess = e;
            }
            catch (WarningException ex)
            {
                //I think this only happens when we try to inject into an already redirected app.
            }
            catch (AccessViolationException ex)
            {
                //Not sure what to do if that happens
                if(Debugger.IsAttached)
                    Debugger.Break();
            }
        }
 public HttpDigestAuth(string databasePath)
 {
     _database = new PropertiesFile(databasePath);
     _lastNonceLookup = new Dictionary<String, String>();
 }