コード例 #1
0
ファイル: WebServer.cs プロジェクト: furuya02/HideAndSeek
        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();
        }
コード例 #2
0
ファイル: WebServer.cs プロジェクト: furuya02/HideAndSeek
        public void Dispose()
        {
            if (_t != null) {//起動されている場合
                _life = false;//スイッチを切るとLoop内の無限ループからbreakする
                if (_t.IsAlive) {
                    Thread.Sleep(100);
                }
            }
            _t = null;

            if (_runMode == RunMode.Pcap) {
                _capture.OnCapture -= _capture_OnCapture;
                _capture.Dispose();
                _capture = null;
                _substitute = null;
            }
        }