Beispiel #1
0
        bool INoIPConfig.NoipConfig(FWDeviceForm fw_dev)
        {
            string cmd = "ifconfig br0 down && ifconfig br0 0.0.0.0 up";

            fw_dev.setDev_port(22222);

            /*
             *本身就无IP的防火墙不能配置为无IP模式
             */
            if (fw_dev.getDev_IP() == "0.0.0.0")
            {
                return(false);
            }
            SendInfo sendcmd = new SendInfo(fw_dev);

            if (sendcmd.SendConfigInfo(cmd))
            {
                fw_dev.setDev_IP("0.0.0.0");
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
        /* 监听扫描返回数据包端口 */
        public void listenCheckResult()
        {
            while (true)
            {
                byte[] content = listener.Receive(ref groupEP);
                confirm = Encoding.Default.GetString(content);
                if ((confirm.IndexOf("firedeviceConfirm")) != -1)
                {
#if debug
                    Console.WriteLine("捕获到返回信息!!!");
#endif
                    string[] sArray_IP_MAC = confirm.Split('&');
                    string   fw_IP         = sArray_IP_MAC[0]; //防火墙IP
                    string   dev_mac       = sArray_IP_MAC[1]; //受保护设备MAC
                    string   fw_mac        = sArray_IP_MAC[2]; //防火墙MAC
                    string   dev_IP        = sArray_IP_MAC[4]; //受保护设备IP
                    //if (dev_mac != "")
                    //{
                    if (fw_IP != "0.0.0.0" && (fwMAC_list.Contains(fw_mac)))        //如果已经存在
                    {
                        foreach (FWDeviceForm fwdev in fw_list)
                        {
                            if (fwdev.getDev_MAC() == fw_mac)
                            {
                                if (!fwdev.getProtecDevIP_list().Contains(dev_IP))
                                {
                                    ProtecDeviceForm protecDev = new ProtecDeviceForm(dev_IP, dev_mac);
                                    fwdev.addProtecDev(protecDev);
                                    fwdev.addProtecDevIP(dev_IP);
                                }
                            }
                        }
                    }
                    else
                    {
                        FWDeviceForm fw_dev = new FWDeviceForm(fw_IP, 22222, fw_mac);
                        fw_dev.addProtecDev(new ProtecDeviceForm(dev_IP, dev_mac));
                        fw_dev.addProtecDevIP(dev_IP);
                        fwMAC_list.Add(fw_mac);
                        fw_list.Add(fw_dev);
                    }
                    //}

#if debug
                    Console.WriteLine("保存设备信息!!!");
#endif
                }
                else
                {
                    Console.WriteLine("未扫描到设备");
                }
            }
        }
Beispiel #3
0
 private void NoIPConfigure_Click(object sender, RoutedEventArgs e)
 {
     if (UserMessageBox.Show("无IP配置", "确定要将此防火墙配置成无IP吗?") == true)
     {
         INoIPConfig  noip  = new NoIPConfig();
         FWDeviceForm fwdev = (from devices in StaticGlobal.fwdev_list
                               where devices.getDev_MAC() == currentselectedItem.Header.ToString().Replace("防火墙  MAC: ", "")
                               select devices).ToList <FWDeviceForm>()[0];
         if (noip.NoipConfig(fwdev))
         {
             UserMessageBox.Show("提示", "无IP配置成功!");
         }
         else
         {
             UserMessageBox.Show("提示", "无IP配置失败!");
         }
     }
 }