Example #1
0
        static void Main(string[] args)
        {
            if (!ForkAdministrative())
            {
                return;
            }

            Console.WriteLine("Running in administrative mode");
            var dictionary = new Dictionary <string, string>();

            dictionary["www.privateinternetaccess.com"] = "127.0.0.1";
            dictionary["privateinternetaccess.com"]     = "127.0.0.1";
            Hosts.Merge(dictionary);
            RegionData.Exclude("turkey");
            Console.WriteLine("All updated");
            Console.ReadLine();
        }
Example #2
0
        public static void Merge(Dictionary <string, string> merge)
        {
            var src = Hosts.Read();

            using (StreamWriter w = File.AppendText(Hosts.Path))
            {
                foreach (var i in merge)
                {
                    if (src.ContainsKey(i.Key))
                    {
                        if (i.Value != src[i.Key])
                        {
                            Console.WriteLine("Already contains {0}: {1}. Please remove them manually if needed", i.Key,
                                              i.Value);
                        }
                        continue;
                    }
                    Console.WriteLine("Appending {0} {1} to hosts file", i.Value, i.Key);
                    w.WriteLine("{0} {1}", i.Value, i.Key);
                }
            }
        }