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(); }
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(); }
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(); }
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(); }