public RouterLogin(RouterData Data)
        {
            this.Data = Data;

            TempPath         = Path.ChangeExtension(Path.GetTempFileName(), Guid.NewGuid().ToString());
            TempTemplatePath = Path.ChangeExtension(Path.GetTempFileName(), Guid.NewGuid().ToString());
        }
        private string GetASNStringFromIP(RouterData Data, string IP, out string Netmask)
        {
            string ASN;
            string Org;

            if (Data.ASNData.GetMatchingASNAndOrgForIP(IP, out ASN, out Org, out Netmask))
            {
                return(string.Format("{0} ({1})", Org, ASN));
            }

            return("Unknown");
        }
Ejemplo n.º 3
0
        public Main(RouterData Data)
        {
            this.Data = Data;

            InitializeComponent();

            RoutingList.Items.Clear();

            foreach (var Item in Data.StaticRoutes)
            {
                RoutingList.Items.Add(CreateLVIFromStaticRoutingRule(Item));
            }
            RoutingList.Refresh();

            Data.StaticRoutes.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(
                delegate(object Sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs EventArgs)
            {
                if (EventArgs.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
                {
                    foreach (var ItemObj in EventArgs.NewItems)
                    {
                        StaticRoutingData Item = (StaticRoutingData)ItemObj;

                        RoutingList.Items.Add(CreateLVIFromStaticRoutingRule(Item));
                    }
                }
                else if (EventArgs.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
                {
                    foreach (var ItemObj in EventArgs.OldItems)
                    {
                        StaticRoutingData Item = (StaticRoutingData)ItemObj;

                        foreach (var ListItemObj in RoutingList.Items)
                        {
                            var ListViewItem = ListItemObj as ListViewItem;
                            if (ListViewItem.Tag.Equals(Item))
                            {
                                RoutingList.Items.Remove(ListViewItem);
                                break;
                            }
                        }
                    }
                }

                RefreshDiff();
            }
                );
        }
Ejemplo n.º 4
0
        private void OK_Click(object sender, EventArgs e)
        {
            RouterData Data = new RouterData();

            Data.Address  = Address.Text;
            Data.Username = Username.Text;
            Data.Password = Password.Text;

            RouterLogin             LoginWork   = new RouterLogin(Data);
            AcquireASNData          ASNDataWork = new AcquireASNData(Data.ASNData);
            RouterGenerateNewConfig GenerateNew = new RouterGenerateNewConfig(Data);

            ChainWorker Work = new ChainWorker();

            Work.AddWork(ASNDataWork);
            Work.AddWork(LoginWork);
            Work.AddWork(GenerateNew);

            var Busy = new Busy(Work);

            if (Busy.ShowDialog() == DialogResult.OK)
            {
                Microsoft.Win32.RegistryKey regSettings = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(RegistryKey);
                regSettings.SetValue("Address", Address.Text);
                regSettings.SetValue("Username", Username.Text);
                regSettings.SetValue("SavePassword", SavePassword.Checked ? "True" : "False");
                if (SavePassword.Checked)
                {
                    regSettings.SetValue("Password", Util.EncryptString(Password.Text));
                }
                else
                {
                    regSettings.DeleteValue("Password", false);
                }
                regSettings.Close();

                var MainForm = new Main(Data);
                Visible = false;
                MainForm.Show();
                ProgrammaticClosing = true;
                Close();
            }
        }
 public RouterLogDNS(RouterData Data)
 {
     this.Data = Data;
 }
        public DNSLogViewer(string LogFilename, RouterData Data)
        {
            InitializeComponent();

            HashSet <string> ExistingItems = new HashSet <string>();

            ColumnSorter = new ListViewColumnSorter();
            RecordList.ListViewItemSorter = ColumnSorter;

            string[] LogData = File.ReadAllLines(LogFilename);

            var Regex = new Regex(@"^\w+\W+\d+\W+[0-9:]+\W+dnsmasq\[\d+\]:\W+(\w+(?:\[\w+\])?)\W+([^ ]+)\W+\w+\W+([0-9.]+|<\w+>)$");

            string        ParentQuery = "";
            string        QueryFrom   = "";
            List <string> CurrentIPs  = new List <string>();
            List <string> Owners      = new List <string>();
            List <string> Netmasks    = new List <string>();

            foreach (var Line in LogData)
            {
                Match Match = Regex.Match(Line);
                if (!Match.Success)
                {
                    continue;
                }

                var Type   = Match.Groups[1].Value;
                var Domain = Match.Groups[2].Value;
                var IP     = Match.Groups[3].Value;

                if (Type == "query" || Type == "query[A]")
                {
                    if (CurrentIPs.Count > 0)
                    {
                        ListViewItem Item = new ListViewItem();
                        Item.Text = ParentQuery;

                        string IPs   = "";
                        bool   first = true;
                        foreach (string s in CurrentIPs)
                        {
                            if (first)
                            {
                                first = false;
                            }
                            else
                            {
                                IPs += ", ";
                            }
                            IPs += s;
                        }

                        string OwnersString = "";
                        first = true;
                        foreach (string s in Owners)
                        {
                            if (first)
                            {
                                first = false;
                            }
                            else
                            {
                                OwnersString += ", ";
                            }
                            OwnersString += s;
                        }

                        string NetmasksString = "";
                        first = true;
                        foreach (string s in Netmasks)
                        {
                            if (first)
                            {
                                first = false;
                            }
                            else
                            {
                                NetmasksString += ", ";
                            }
                            NetmasksString += s;
                        }

                        Item.SubItems.Add(IPs);
                        Item.SubItems.Add(QueryFrom);
                        Item.SubItems.Add(OwnersString);
                        Item.SubItems.Add(NetmasksString);

                        RecordList.Items.Add(Item);

                        Owners.Clear();
                        CurrentIPs.Clear();
                        Netmasks.Clear();
                    }

                    ParentQuery = Domain;
                    QueryFrom   = IP;
                }
                else if (Type == "forwarded")
                {
                    //Ignore for now
                }
                else if (Type == "reply" || Type == "cached")
                {
                    if (IP != "<CNAME>")
                    {
                        if (!CurrentIPs.Contains(IP))
                        {
                            CurrentIPs.Add(IP);
                        }

                        string Netmask = "";
                        string Owner   = GetASNStringFromIP(Data, IP, out Netmask);
                        if (!Owners.Contains(Owner))
                        {
                            Owners.Add(Owner);
                        }

                        if (!Netmasks.Contains(Netmask))
                        {
                            Netmasks.Add(Netmask);
                        }
                    }
                }
            }

            if (ParentQuery != "")
            {
                ListViewItem Item = new ListViewItem();
                Item.Text = ParentQuery;

                string IPs   = "";
                bool   first = true;
                foreach (string s in CurrentIPs)
                {
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        IPs += ", ";
                    }
                    IPs += s;
                }

                string OwnersString = "";
                first = true;
                foreach (string s in Owners)
                {
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        OwnersString += ", ";
                    }
                    OwnersString += s;
                }

                string NetmasksString = "";
                first = true;
                foreach (string s in Netmasks)
                {
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        NetmasksString += ", ";
                    }
                    NetmasksString += s;
                }

                Item.SubItems.Add(IPs);
                Item.SubItems.Add(QueryFrom);
                Item.SubItems.Add(OwnersString);
                Item.SubItems.Add(NetmasksString);

                RecordList.Items.Add(Item);
            }
        }
 public RouterEnableDNSCrypt(RouterData Data, Form Parent)
 {
     this.Data   = Data;
     this.Parent = Parent;
 }
 public RouterWriteNewConfig(RouterData Data)
 {
     this.Data = Data;
 }
Ejemplo n.º 9
0
 public RouterGenerateNewConfig(RouterData Data)
 {
     this.Data = Data;
 }