private FWAdapterBase LoadAdapter() { using (SshClient ssh = FirewallUnit.CreateSsh()) { ssh.Connect(); FirewalldAdapter fwAdp = new FirewalldAdapter(); if (fwAdp.CheckEnable(ssh)) { return(fwAdp); } } return(null); }
/// <summary> /// 刷新到防火墙信息 /// </summary> public void RefreashFirewall() { List <string> lstIP = _fwHandle.LoadUserIP(); using (SshClient ssh = FirewallUnit.CreateSsh()) { ssh.Connect(); //对别哪些需要执行 List <string> cmd = _fwHandle.CreateCommand(ssh); foreach (string command in cmd) { SshCommand res = ssh.RunCommand(command); if (!string.IsNullOrWhiteSpace(res.Error)) { Console.WriteLine(res.Error); } } _fwHandle.ReLoad(ssh); } }