예제 #1
0
        public bool ChangeWhiteLists(string dev_IP, string dst_IP, string src_IP, string dst_port, string src_port, bool log_record, bool add_delete)
        {
            this.devform.setDev_IP(dev_IP);
            WhiteLists lists = new WhiteLists();

            lists.setIPAndPort(dst_IP, src_IP, dst_port, src_port);

            string flag = null; string sql_rule = "";

            string whiteList_from_client_to_server0 = "iptables -A FORWARD -p tcp -s " + lists.getsrc_IP() + " -d " + lists.getdst_IP() + " --sport " + lists.getsrc_port()
                                                      + " --dport " + lists.getdst_port() + " -j ACCEPT ";

            // string whiteList_from_client_to_server1 = "iptables -A FORWARD -p tcp -d" + wl.getSrc_IP() + "--sport" + wl.getPort();

            if (add_delete)
            {
                flag     = "DPI1";
                sql_rule = "INSERT INTO whitelist values " + "('" + dev_IP + "','" + dst_IP + "','" + src_IP + "','" + dst_port + "','" + src_port + "')";
            }

            else
            {
                flag     = "DPI0";
                sql_rule = "DELETE FROM whitelist where (dev_IP='" + dev_IP + "' and dst_IP='" + dst_IP + "' and src_IP='" + src_IP + "' and dst_port='" + dst_port + "' and src_port='" + src_port + "')";
            }

            string changewl = flag + whiteList_from_client_to_server0;

            LISTdb_operate.dboperate(sql_rule);

            //DeviceForm devform = new DeviceForm(dev_IP, 22222);
            SendInfo sendcmd = new SendInfo(devform);

            return(sendcmd.SendConfigInfo(changewl));
        }
예제 #2
0
        public bool ChangeWhiteLists(string dev_IP, string dst_IP, string src_IP, string dst_port, string src_port, bool log_record, bool add_delete)
        {
            this.devform.setDev_IP(dev_IP);
            WhiteLists lists = new WhiteLists();

            lists.setIPAndPort(dst_IP, src_IP, dst_port, src_port);

            string flag = null;

            string whiteList_from_client_to_server0 = "iptables -A FORWARD -p tcp -s " + lists.getsrc_IP() + " -d " + lists.getdst_IP() + " --sport " + lists.getsrc_port()
                                                      + " --dport " + lists.getdst_port() + " -j ACCEPT ";

            // string whiteList_from_client_to_server1 = "iptables -A FORWARD -p tcp -d" + wl.getSrc_IP() + "--sport" + wl.getPort();

            if (add_delete)
            {
                flag = "WHL1";
                string frule = dev_IP + " " + dst_IP + " " + src_IP + " " + dst_port + " " + src_port;
                of.SaveRules(frule, "whl");
            }

            else
            {
                flag = "WHL0";
                string frule = dev_IP + " " + dst_IP + " " + src_IP + " " + dst_port + " " + src_port;
                of.DeleteRules(frule, "whl");
            }

            string changewl = flag + whiteList_from_client_to_server0;
            //DeviceForm devform = new DeviceForm(dev_IP, 22222);
            SendInfo sendcmd = new SendInfo(devform);

            return(sendcmd.SendConfigInfo(changewl));
        }
예제 #3
0
        public bool ChangeWhiteLists(string dst_IP, string src_IP, string dev_IP, string dst_port, string src_port, bool log_record, bool add_delete)
        {
            WhiteLists lists = new WhiteLists();

            lists.setIPAndPort(dst_IP, src_IP, dst_port, src_port);

            DeviceForm   devform      = new DeviceForm(dev_IP, 22222);
            IConfigRules configDevice = new ConfigRules(devform);

            return(configDevice.ConfigWhiteLists(lists, add_delete));
        }
예제 #4
0
        public bool ConfigWhiteLists(WhiteLists wl, bool add_delete)
        {
            string flag = null;

            if (add_delete == true)
            {
                flag = "$";
            }

            else if (add_delete == false)
            {
                flag = "#";
            }
            string whiteList_from_client_to_server0 = "iptables -A FORWARD -p tcp -s " + wl.getsrc_IP() + " -d " + wl.getdst_IP() + " --sport " + wl.getsrc_port()
                                                      + " --dport " + wl.getdst_port() + " -j ACCEPT ";
            // string whiteList_from_client_to_server1 = "iptables -A FORWARD -p tcp -d" + wl.getSrc_IP() + "--sport" + wl.getPort();
            string changewl = flag + whiteList_from_client_to_server0;

            SendInfo sendcmd = new SendInfo(devform);

            return(sendcmd.SendConfigInfo(changewl));
        }