Exemple #1
0
        public WebServer(int port, Log log, CaptureView captureView,Option option)
        {
            _log = log;
            _port = port;
            _runMode = option.RunMode;
            _captureView = captureView;

            _documentRoot = Path.GetFullPath(Directory.GetCurrentDirectory() + "\\..\\..\\..\\www");

            _log.Clear();
            log.Set(string.Format("Mode={0}",_runMode));

            _t = new Thread(Loop) { IsBackground = true };
            if (_runMode != RunMode.Pcap) {
                _captureView.Enable= false;
            } else {
                _capture = new Capture();
                _substitute = new Substitute(_capture, _port,option.AckReply,option.ArpReplyList, _log);

                _capture.OnCapture += new OnCaptureHandler(_capture_OnCapture);
                _captureView.Enable = true;

                var ar = _capture.GetAdapterList();
                _captureView.Adapter = null;
                int index = option.AdapterIndex;
                bool promiscuous = false;
                _capture.Start(ar[index].Name, promiscuous);
                _captureView.Adapter = ar[index];
                _substitute.Adapter = ar[index];

            }
            _t.Start();
        }
Exemple #2
0
 private void MainMenuOption_Click(object sender, EventArgs e)
 {
     var dlg = new OptionDlg(_option);
     if (DialogResult.OK == dlg.ShowDialog()) {
         _option = dlg.Option;
         InitializeWebServer();
     }
 }
Exemple #3
0
        public MainForm()
        {
            InitializeComponent();
            _option = new Option();
            _log = new Log(listBoxLog);
            _captureView = new CaptureView(listViewCapture);

            InitializeWebServer();
        }
Exemple #4
0
        public OptionDlg(Option option)
        {
            InitializeComponent();

            Option = option;

            radioButtonNone.Checked = (option.RunMode == RunMode.None);
            radioButtonBind.Checked = (option.RunMode == RunMode.Bind);
            radioButtonPcap.Checked = (option.RunMode == RunMode.Pcap);

            checkBoxAckReply.Checked = option.AckReply;
            var sb = new StringBuilder();
            foreach(var ip in option.ArpReplyList){
                sb.Append(ip);
                sb.Append("\n");
            }
            textBox1.Text = sb.ToString();

            Capture capture = new Capture();
            var ar = capture.GetAdapterList();
            foreach (var a in ar) {
                sb = new StringBuilder();
                sb.Append(a.Description);
                sb.Append(" ");
                foreach (var s in a.Ip) {
                    sb.Append(s);
                    sb.Append(" , ");
                }
                listBoxAdapter.Items.Add(sb.ToString());
            }
            if (listBoxAdapter.Items.Count > 0) {
                listBoxAdapter.SelectedIndex = 0;
                if (listBoxAdapter.Items.Count > option.AdapterIndex)
                    listBoxAdapter.SelectedIndex = option.AdapterIndex;
            } else {
                //アダプタが列挙できていないときは、Pcapモードは使用できない
                radioButtonPcap.Enabled = false;
            }
            initDisplay();
        }