Ejemplo n.º 1
0
        public void Init(SSHParam inparam, STRule inrule, string innodename)
        {
            sshParam = inparam;
            string filepathname = string.Format("/tmp/{0}{1}{2}", innodename, DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss"), inrule.rFileName);

            inrule.rFileName = filepathname;
            STTask task = new STTask();

            task.myRule = inrule;
            task.hName  = innodename;
            task.GetCmdLine();
            myTask = task;
            try {
                sshclient = new SshClient(sshParam.hostIP, sshParam.userName, sshParam.userPWD);
                if (sshclient == null)
                {
                    return;
                }
                sshclient.Connect();
                sshcmd     = sshclient.CreateCommand(task.GetCmdLine());
                ssharesult = sshcmd.BeginExecute();
            } catch (Exception exc) {
                exc.ToString();
            }
        }
Ejemplo n.º 2
0
 void Bt_delruleClick(object sender, EventArgs e)
 {
     if (listBox_allrules.SelectedIndex >= 0)
     {
         editRule = listBox_allrules.SelectedItem as STRule;
         allRules.Remove(editRule);
     }
 }
Ejemplo n.º 3
0
 void Bt_editruleClick(object sender, EventArgs e)
 {
     if (listBox_allrules.SelectedIndex >= 0)
     {
         editRule = listBox_allrules.SelectedItem as STRule;
         param_2_ctrl(editRule);
     }
 }
Ejemplo n.º 4
0
 public void RulesInit()
 {
     journal_short_rule             = new STRule();
     journal_short_rule.RuleName    = "journalctl rule with short-precise option";
     journal_short_rule.rType       = STRuleType.Block;
     journal_short_rule.rFileOption = string.Empty;
     journal_short_rule.rFileName   = string.Empty;
     RulesUpdate();
 }
Ejemplo n.º 5
0
        public NonBlockFileSession(string inHost, string inUserName, string inPwd, string inCmd, string inOP, string infilename, string innodename)
        {
            SSHParam para = new SSHParam(inHost, inUserName, inPwd);
            STRule   rule = new STRule();

            rule.rCmdLine    = inCmd;
            rule.rFileOption = inOP;
            rule.rFileName   = infilename;
            rule.rType       = STRuleType.NonBlockFile;
            rule.rName       = "NonBlockFileSession internal";
            Init(para, rule, innodename);
        }
Ejemplo n.º 6
0
 void Bt_saveClick(object sender, EventArgs e)
 {
     if (editRule != null)
     {
         if (this.allRules.Contains(editRule) == false)
         {
             this.allRules.Add(editRule);
         }
     }
     editRule = null;
     this.groupBox1.Enabled = false;
 }
Ejemplo n.º 7
0
        public void dummy()
        {
            STRule obj = null;

            obj             = new STRule();
            obj.rCmdLine    = "ls -lah";
            obj.rType       = STRuleType.Block;
            obj.rFileOption = string.Empty;
            obj.rName       = "show ls result";
            allRules.Add(obj);
            obj             = new STRule();
            obj.rCmdLine    = "ps -ef";
            obj.rType       = STRuleType.Block;
            obj.rFileOption = string.Empty;
            obj.rName       = "show ps result";
            allRules.Add(obj);
        }
Ejemplo n.º 8
0
 public void update_ruleitem_show()
 {
     if (listBox_allrules.SelectedIndex >= 0)
     {
         STRule selectedruleitem = listBox_allrules.SelectedItem as STRule;
         this.label_show_ruleitem.Text = string.Format("{0}\n\tRuleName:{1}\n\tRuleCmd:{2} {3} {4}\n\tRuleType:{5}",
                                                       listBox_allrules.SelectedIndex.ToString(),
                                                       selectedruleitem.RuleName,
                                                       selectedruleitem.RuleCmdLine,
                                                       selectedruleitem.RuleFileOption,
                                                       selectedruleitem.RuleFileName,
                                                       selectedruleitem.RuleType.ToString());
     }
     else
     {
         this.label_show_ruleitem.Text = "No rule item selected";
     }
 }
Ejemplo n.º 9
0
 public STTask()
 {
     hName  = string.Empty;
     hPort  = 22;
     myRule = null;
 }
Ejemplo n.º 10
0
 public void ctrl_2_param(STRule inrule)
 {
     inrule.RuleName     = this.tb_rulename.Text;
     inrule.RuleCmdLine  = this.tb_rulecmd.Text;
     inrule.RuleFileName = this.tb_filename.Text;
 }
Ejemplo n.º 11
0
 public void param_2_ctrl(STRule inrule)
 {
     this.tb_rulename.Text = inrule.RuleName;
     this.tb_rulecmd.Text  = inrule.RuleCmdLine;
     this.tb_filename.Text = inrule.RuleFileName;
 }