コード例 #1
0
        public bool ConfigOPCRules(OPCRulesForm orf, bool log_flag, bool add_delete)
        {
            string flag = null;

            String opc_rules_from_client_to_server0    = "iptables -A FORWARD -p tcp -s " + orf.getSrc_IP() + " -d " + orf.getDst_IP() + " --dport 135 -m state --state ESTABLISHED -j NFQUEUE --queue-num 1";
            String opc_rules_from_client_to_server1    = "iptables -A FORWARD -p tcp -s " + orf.getDst_IP() + " -d " + orf.getSrc_IP();
            String opc_rules_from_client_to_server_log = "iptables -A FORWARD -p tcp -s " + orf.getSrc_IP() + " -d " + orf.getDst_IP() + " --dport 135 -m state --state ESTABLISHED -j LOG --log-prefix " + "\"" + "ACCEPT&OPC&ESTABLISHED " + "\"";

            //String opc_rules_from_server_to_client = "iptables -A FORWARD -p tcp -s " + orf.getDst_IP() + " -d " + orf.getSrc_IP() + " --sport 135 -m state --state ESTABLISHED -j NFQUEUE --queue-num 1";
            if (add_delete == true)
            {
                flag = "DPI1";
                string frule = devform.getDev_IP() + " " + orf.getDst_IP() + " " + orf.getSrc_IP() + " ACCEPT " + log_flag.ToString();
                of.SaveRules(frule, "opc");
            }

            else if (add_delete == false)
            {
                flag = "DPI0";
                string frule = devform.getDev_IP() + " " + orf.getDst_IP() + " " + orf.getSrc_IP() + " ACCEPT " + log_flag.ToString();
                of.DeleteRules(frule, "opc");
            }

            string   rule    = flag + opc_rules_from_client_to_server_log + " && " + opc_rules_from_client_to_server0 + " && " + opc_rules_from_client_to_server1;
            SendInfo sendcmd = new SendInfo(devform);

            return(sendcmd.SendConfigInfo(rule));
        }
コード例 #2
0
        public bool ConfigOPCRules(OPCRulesForm orf, bool log_flag, bool add_delete)
        {
            string flag = null; string sql_rule = null;

            String opc_rules_from_client_to_server0    = "iptables -A FORWARD -p tcp -s " + orf.getSrc_IP() + " -d " + orf.getDst_IP() + " --dport 135 -m state --state ESTABLISHED -j NFQUEUE --queue-num 1";
            String opc_rules_from_client_to_server1    = "iptables -A FORWARD -p tcp -s " + orf.getDst_IP() + " -d " + orf.getSrc_IP();
            String opc_rules_from_client_to_server_log = "iptables -A FORWARD -p tcp -s " + orf.getSrc_IP() + " -d " + orf.getDst_IP() + " --dport 135 -m state --state ESTABLISHED -j LOG --log-prefix " + "\"" + "ACCEPT&OPC&ESTABLISHED " + "\"";

            //String opc_rules_from_server_to_client = "iptables -A FORWARD -p tcp -s " + orf.getDst_IP() + " -d " + orf.getSrc_IP() + " --sport 135 -m state --state ESTABLISHED -j NFQUEUE --queue-num 1";
            if (add_delete == true)
            {
                flag     = "DPI1";
                sql_rule = "INSERT INTO OPC values " + "('" + devform.getDev_IP() + "','" + orf.getDst_IP() + "','" + orf.getSrc_IP() + "','ACCEPT','" + log_flag + "')";
            }

            else if (add_delete == false)
            {
                flag     = "DPI0";
                sql_rule = "DELETE FROM OPC where (dev_IP='" + devform.getDev_IP() + "' and dst_IP='" + orf.getDst_IP() + "' and src_IP='" + orf.getSrc_IP() + "' and method='ACCEPT')";
            }

            string rule = flag + opc_rules_from_client_to_server_log + " && " + opc_rules_from_client_to_server0 + " && " + opc_rules_from_client_to_server1;

            DPIdb_operate.dboperate(sql_rule);
            SendInfo sendcmd = new SendInfo(devform);

            return(sendcmd.SendConfigInfo(rule));
        }