예제 #1
0
        private void PopulateConfigurationForm()
        {
            TreeNode       treeNode;
            ConfigTreeNode config;

            treeNode = new ConfigTreeNode("Session", new config_session("Basic Connection Configuration"));
            treeNode.Nodes.Add(new ConfigTreeNode("Logging", new conf_template("Available Plugin Updates")));
            AddConfigItem(treeNode);

            //regular TreeNode as root will hold three ConfigurationTreeNode
            treeNode = new ConfigTreeNode("Connection", new conf_template("Connection"));
            treeNode.Nodes.Add(new ConfigTreeNode("Proxy", new conf_template("Proxy Server Setup")));
            treeNode.Nodes.Add(new ConfigTreeNode("Data", new conf_template("Data to send to server")));
            AddConfigItem(treeNode);

            treeNode = new ConfigTreeNode("Plugins", new conf_plugins("Installed Plugins"));
            treeNode.Nodes.Add(new ConfigTreeNode("Updates", new conf_template("Available Plugin Updates")));
            treeNode.Nodes.Add(new ConfigTreeNode("Available", new conf_template("Available Plugins")));
            AddConfigItem(treeNode);

            config = new ConfigTreeNode("Directories", new conf_template("Directories"));
            AddConfigItem(config);

            config = new ConfigTreeNode("Language", new conf_language("Language"));
            AddConfigItem(config);

            config = new ConfigTreeNode("Updates", new conf_template("Updates"));
            AddConfigItem(config);

            config = new ConfigTreeNode("About", new conf_template("About"));
            AddConfigItem(config);

            //RemoveConfigItem("Database Writer");
        }
예제 #2
0
 private void CreateConfigTree(DirectoryInfo directoryInfo, ConfigsMerger merger)
 {
     foreach (DirectoryInfo info in directoryInfo.GetDirectories())
     {
         string path = this.GetPath(info.FullName);
         this.root.FindOrCreateNode(path);
         this.CreateConfigTree(info, merger);
     }
     foreach (FileInfo info2 in directoryInfo.GetFiles())
     {
         if (this.configurationProfile.Match(info2.Name))
         {
             string         path           = this.GetPath(directoryInfo.FullName);
             ConfigTreeNode configTreeNode = this.root.FindOrCreateNode(path);
             try
             {
                 YamlNodeImpl yamlNode = YamlService.Load(info2);
                 merger.Put(configTreeNode, info2.Name, yamlNode);
             }
             catch (Exception exception1)
             {
                 throw new Exception(path, exception1);
             }
         }
     }
 }
예제 #3
0
        public JsonResult UpdateRawDataContents(JsonContainer jsonData)
        {
            var            model         = Session[Definitions.SMART_CONFIG_SESSION_KEY] as SmartConfigDataModel;
            ConfigTreeNode node          = null;
            var            jsonContainer = new JsonContainer();

            if (null != model)
            {
                var serializer = new JsonSerializer();
                var reader     = new JsonTextReader(new StringReader(jsonData.JsonString));
                var updateInfo = serializer.Deserialize <RawDataMapInfo>(reader);
                node = model.GetConfigNodeByGuid(updateInfo.Id);
                if (null != node)
                {
                    if (!string.IsNullOrEmpty(updateInfo.RawDataMap.Offset))
                    {
                        node.RawDataMap.Offset = updateInfo.RawDataMap.Offset;
                        node.NodeEditStatus    = ConfigNodeStatus.Modified.ToString();
                    }
                    if (!string.IsNullOrEmpty(updateInfo.RawDataMap.Size))
                    {
                        node.RawDataMap.Size = updateInfo.RawDataMap.Size;
                        node.NodeEditStatus  = ConfigNodeStatus.Modified.ToString();
                    }
                    if (!string.IsNullOrEmpty(updateInfo.RawDataMap.Value))
                    {
                        var val = updateInfo.RawDataMap.Value;
                        if (val == EditDataType.DataSizeEdit.ToString() ||
                            val == EditDataType.RawDataEdit.ToString())
                        {
                            node.RawDataMap.EditType = val;
                        }
                        else
                        {
                            node.RawDataMap.Value = val;
                            var buffer = val.Replace(" ", string.Empty).HexStringToByteArray();
                            if (null != buffer)
                            {
                                var offset = node.RawDataMap.Offset.HexToLong();
                                if (node.RawDataMap.TargetBinaryStream.CanSeek)
                                {
                                    node.RawDataMap.TargetBinaryStream.Seek(offset.Value, SeekOrigin.Begin);
                                    node.RawDataMap.TargetBinaryStream.Write(buffer, 0, buffer.Length);
                                }
                            }
                        }
                        node.NodeEditStatus = ConfigNodeStatus.Modified.ToString();
                    }

                    jsonContainer.JsonString = _RenderToHtmlString(PartialView("_ConfigTreeNodeContents", node));
                }
                this._UpdateSessionModel(model);
            }
            return(Json(jsonContainer));
        }
예제 #4
0
        public T Import <T>(string path, ConfigurationProfile configurationProfile) where T : ConfigTreeNode, new()
        {
            this.configurationProfile = configurationProfile;
            this.root = Activator.CreateInstance <T>();
            DirectoryInfo directoryInfo = new DirectoryInfo(path);

            this.rootPath = directoryInfo.FullName;
            this.CreateConfigTree(directoryInfo, this.configsMerger);
            this.configsMerger.Merge();
            return((T)this.root);
        }
예제 #5
0
        /* General
         * UI Settings
         * Connections
         *  - IP Filter
         *  - IP Binding
         *  - Autoban
         * SSL Configuration
         * Secruity
         * Admin Settings
         * Speed Limits
         * Messages
         * Plugins
         * Miscellaneous
         * Logging
         * Updates
         * Development
         * Advanced
         *  - Proxy
         */

        private void PopulateConfigurationForm()
        {
            ConfigTreeNode config;
            TreeNode       treeNode;

            config = new ConfigTreeNode("General", new settings_general("General"));
            AddConfigItem(config);

            config = new ConfigTreeNode("UI Settings", new settings_ui("UI Settings"));
            AddConfigItem(config);

            //regular TreeNode as root will hold three ConfigurationTreeNode
            treeNode = new ConfigTreeNode("Connections", new settings_connections("Connections"));
            treeNode.Nodes.Add(new ConfigTreeNode("IP Filter", new settings_ip_binding("IP Filter")));
            treeNode.Nodes.Add(new ConfigTreeNode("IP Binding", new settings_ip_filter("IP Binding")));
            treeNode.Nodes.Add(new ConfigTreeNode("Autoban", new settings_autoban("Autoban Settings")));
            AddConfigItem(treeNode);

            config = new ConfigTreeNode("SSL Configuration", new settings_SSL("SSL Configuration"));
            AddConfigItem(config);

            config = new ConfigTreeNode("Security", new settings_security("Security Settings"));
            AddConfigItem(config);

            config = new ConfigTreeNode("Admin Settings", new settings_admin("Admin Settings"));
            AddConfigItem(config);

            config = new ConfigTreeNode("Speed Limits", new settings_speedlimits("Speed Limits"));
            AddConfigItem(config);

            config = new ConfigTreeNode("Messages", new settings_messages("Connection Messages"));
            AddConfigItem(config);

            config = new ConfigTreeNode("Plugins", new settings_plugins("Plugins"));
            AddConfigItem(config);

            config = new ConfigTreeNode("Miscellaneous", new settings_misc("Miscellaneous"));
            AddConfigItem(config);

            config = new ConfigTreeNode("Logging", new settings_logging("Logging"));
            AddConfigItem(config);

            config = new ConfigTreeNode("Updates", new settings_updates("Updates"));
            AddConfigItem(config);

            config = new ConfigTreeNode("Development", new settings_development("Development"));
            AddConfigItem(config);

            treeNode = new ConfigTreeNode("Advanced", new settings_advanced("Advanced"));
            treeNode.Nodes.Add(new ConfigTreeNode("Proxy", new conf_template("")));
            AddConfigItem(treeNode);

            //RemoveConfigItem("Database Writer");
        }
예제 #6
0
        public YamlNode GetConfigOrNull(string path)
        {
            YamlNodeImpl impl;

            if (!this.cache.TryGetValue(path, out impl))
            {
                ConfigTreeNode node = this.root.FindNode(path);
                impl             = (node == null) ? null : ((YamlNodeImpl)node.GetYaml());
                this.cache[path] = impl;
            }
            return(impl);
        }
예제 #7
0
 private static void CacheAllPaths(ConfigTreeNode node, string parentPath, Dictionary <string, YamlNodeImpl> nodes)
 {
     foreach (ConfigTreeNode node2 in node.GetChildren())
     {
         string key = !string.IsNullOrEmpty(parentPath) ? (parentPath + "/" + node2.ConfigPath) : node2.ConfigPath;
         if (node2.HasYaml())
         {
             nodes.Add(key, (YamlNodeImpl)node2.GetYaml());
         }
         CacheAllPaths(node2, key, nodes);
     }
 }
예제 #8
0
        public void Put(ConfigTreeNode configTreeNode, string configName, YamlNodeImpl yamlNode)
        {
            List <ConfigData> list;
            ConfigData        item = new ConfigData(configName, yamlNode);

            if (this.configNodeToConfigDataList.ContainsKey(configTreeNode))
            {
                list = this.configNodeToConfigDataList[configTreeNode];
            }
            else
            {
                list = new List <ConfigData>();
                this.configNodeToConfigDataList[configTreeNode] = list;
            }
            list.Add(item);
        }
예제 #9
0
        public JsonResult UpdateNode(JsonContainer jsonData)
        {
            var            model = Session[Definitions.SMART_CONFIG_SESSION_KEY] as SmartConfigDataModel;
            ConfigTreeNode node  = null;

            if (null != model)
            {
                node = model.GetConfigNodeByGuid(jsonData.JsonString);
                if (null != node && node.NodeEditStatus == ConfigNodeStatus.Modified.ToString())
                {
                    node.NodeEditStatus = ConfigNodeStatus.Updated.ToString();
                    this._UpdateSessionModel(model);
                }
            }
            return(Json("N/A"));
        }
예제 #10
0
 private static void CollectAllLeafPaths(ConfigTreeNode parentNode, string parentPath, List <string> paths)
 {
     if (parentNode != null)
     {
         foreach (ConfigTreeNode node in parentNode.GetChildren())
         {
             string str = parentPath + "/" + node.ConfigPath;
             if (node.GetChildren().Count > 0)
             {
                 CollectAllLeafPaths(node, str, paths);
                 continue;
             }
             paths.Add(str);
         }
     }
 }
예제 #11
0
        private void PopulateConfigurationForm()
        {
            ConfigTreeNode config;
            TreeNode       treeNode;

            config = new ConfigTreeNode("General", new settings_general("General"));
            AddConfigItem(config);

            config = new ConfigTreeNode("Connections", new settings_connections("Connections"));
            AddConfigItem(config);

            //regular TreeNode as root will hold three ConfigurationTreeNode
            treeNode = new ConfigTreeNode("Interface", new conf_template("Interface"));
            treeNode.Nodes.Add(new ConfigTreeNode("", new conf_template("")));
            AddConfigItem(treeNode);

            config = new ConfigTreeNode("Remote Access", new settings_remote("Remote Access"));
            AddConfigItem(config);

            config = new ConfigTreeNode("Directories", new settings_general("Directories"));
            AddConfigItem(config);

            config = new ConfigTreeNode("Language", new settings_language("Language"));
            AddConfigItem(config);

            config = new ConfigTreeNode("Updates", new settings_updates("Updates"));
            AddConfigItem(config);

            config = new ConfigTreeNode("Logging", new settings_logging("Logging"));
            AddConfigItem(config);
            config = new ConfigTreeNode("Development", new settings_development("Development"));
            AddConfigItem(config);

            treeNode = new ConfigTreeNode("Advanced", new conf_template("Advanced"));
            treeNode.Nodes.Add(new ConfigTreeNode("Proxy", new conf_template("")));
            AddConfigItem(treeNode);

            //RemoveConfigItem("Database Writer");
        }
예제 #12
0
        private void PopulateConfigurationForm()
        {
            ConfigTreeNode config;
            TreeNode       treeNode;

            treeNode = new ConfigTreeNode("Users", new settings_connections("Configure Users"));
            treeNode.Nodes.Add(new ConfigTreeNode("General", new settings_ip_binding("IP Filter")));
            treeNode.Nodes.Add(new ConfigTreeNode("IP Binding", new settings_ip_filter("IP Binding")));
            treeNode.Nodes.Add(new ConfigTreeNode("Autoban", new settings_autoban("Autoban Settings")));
            AddConfigItem(treeNode);

            treeNode = new ConfigTreeNode("Groups", new settings_connections("Configure Groups"));
            treeNode.Nodes.Add(new ConfigTreeNode("IP Filter", new settings_ip_binding("IP Filter")));
            treeNode.Nodes.Add(new ConfigTreeNode("IP Binding", new settings_ip_filter("IP Binding")));
            treeNode.Nodes.Add(new ConfigTreeNode("Autoban", new settings_autoban("Autoban Settings")));
            AddConfigItem(treeNode);

            treeNode = new ConfigTreeNode("Policy", new settings_connections("Policy"));
            treeNode.Nodes.Add(new ConfigTreeNode("IP Filter", new settings_ip_binding("IP Filter")));
            treeNode.Nodes.Add(new ConfigTreeNode("IP Binding", new settings_ip_filter("IP Binding")));
            treeNode.Nodes.Add(new ConfigTreeNode("Autoban", new settings_autoban("Autoban Settings")));
            AddConfigItem(treeNode);
        }
예제 #13
0
 public ConfigNodeDoesntContainYamlException(ConfigTreeNode treeNode) : base("node: " + treeNode)
 {
 }
예제 #14
0
        private void PopulateConfigurationForm()
        {
            m_optionsTV.ImageList = this.imageList1;

            ConfigTreeNode config;
            TreeNode       treeNode;

            config = new ConfigTreeNode("General", new create_stub_General("General"));
            AddConfigItem(config, "arrow_direction_back.png");


            treeNode = new ConfigTreeNode("Connections", new create_stub_Connections("Connections"));

            config                  = new ConfigTreeNode("Permissions", new create_stub_Permissions("Permissions"));
            config.ImageKey         = "check_box_list.png";
            config.SelectedImageKey = "check_box_list.png";
            treeNode.Nodes.Add(config);

            config                  = new ConfigTreeNode("SSL/TLS", new create_stub_SSLTLS("SSL/TLS"));
            config.ImageKey         = "connections.png";
            config.SelectedImageKey = "connections.png";
            treeNode.Nodes.Add(config);

            AddConfigItem(treeNode, "connections.png");



            treeNode = new ConfigTreeNode("Installation", new create_stub_Installation("Installation"));

            config                  = new ConfigTreeNode("Kernal-mode Driver", new create_stub_SSLTLS("Kernal-mode Driver"));
            config.ImageKey         = "Setup.ico";
            config.SelectedImageKey = "Setup.ico";
            treeNode.Nodes.Add(config);

            AddConfigItem(treeNode, "Setup.ico");



            config = new ConfigTreeNode("Safe Mode", new create_stub_SafeMode("Safe Mode"));
            AddConfigItem(config, "shield.png");

            config = new ConfigTreeNode("Display MsgBox", new create_stub_DisplayMsgBox("Display Message Box"));
            AddConfigItem(config, "dialog.png");

            config = new ConfigTreeNode("Rootkit", new create_stub_Rootkit("Rootkit"));
            AddConfigItem(config, "distribution.png");

            config = new ConfigTreeNode("Redistribution", new create_stub_Redistribution("Redistribution"));
            AddConfigItem(config, "Processes.ico");

            config = new ConfigTreeNode("Process Injection", new create_stub_ProcessInjection("Process Injection"));
            AddConfigItem(config, "chart_bar.png");

            config = new ConfigTreeNode("Black List", new create_stub_BlackList("Black List"));
            AddConfigItem(config, "chart_bar.png");

            config = new ConfigTreeNode("Hosts Editor", new create_stub_HostsEditor("Hosts Editor"));
            AddConfigItem(config, "chart_bar.png");

            config = new ConfigTreeNode("Plugins", new create_stub_AddPlugins("Plugins"));
            AddConfigItem(config, "Plugin Add.ico");

            config = new ConfigTreeNode("File Binder", new create_stub_FileBinder("File Binder"));
            AddConfigItem(config, "Execute.ico");

            config = new ConfigTreeNode("Choose Icon", new create_stub_ChooseIcon("Choose Icon"));
            AddConfigItem(config, "chart_bar.png");

            config = new ConfigTreeNode("Assembly Binding", new create_stub_AssemblyBinding("Assembly Binding"));
            AddConfigItem(config, "application.png");

            config = new ConfigTreeNode("Overview", new create_stub_Overview("Brief Overview"));
            AddConfigItem(config, "chart_bar.png");

            config = new ConfigTreeNode("Build Finalization", new create_stub_BuildFinalization("Build Finalization"));
            AddConfigItem(config, "chart_bar.png");

            config = new ConfigTreeNode("Profile Manager", new create_stub_General("Profile Manager"));
            AddConfigItem(config, "User.ico");



            //RemoveConfigItem("Database Writer");
        }
예제 #15
0
			private void AddTypeChildren(Type objType, ConfigTreeNode parentNode = null)
			{
#warning Need to allow proper full name qualifier for flattened fields where requested.
				foreach (PropertyInfo prop in objType.GetProperties(BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.Instance))
				{
					if (prop.GetCustomAttributes(true).Where(o => o is ConfigureAttribute).FirstOrDefault() != null)
						Nodes.Add(new ConfigTreeNode(prop) { ParentNode = parentNode });
					else if (prop.GetCustomAttributes(true).Where(o => o is FlattenAttribute).FirstOrDefault() != null)
						AddTypeChildren(prop.PropertyType, new ConfigTreeNode(prop));
				}
				foreach (FieldInfo fld in objType.GetFields(BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.Instance))
				{
					if (fld.GetCustomAttributes(true).Where(o => o is ConfigureAttribute).FirstOrDefault() != null)
						Nodes.Add(new ConfigTreeNode(fld) { ParentNode = parentNode });
					else if (fld.GetCustomAttributes(true).Where(o => o is FlattenAttribute).FirstOrDefault() != null)
						AddTypeChildren(fld.FieldType, new ConfigTreeNode(fld));
				}
			}
예제 #16
0
 public void SetRootConfigNode(ConfigTreeNode configTreeNode)
 {
     this.root = configTreeNode;
 }