示例#1
0
        public Form1()
        {
            InitializeComponent();

            _listview        = new FastObjectListView();
            olvColumnId      = new OLVColumn();
            olvColumnSent    = new OLVColumn();
            olvColumnRec     = new OLVColumn();
            olvColumnState   = new OLVColumn();
            olvColumnIp      = new OLVColumn();
            olvColumnAddress = new OLVColumn();

            _listview.AllColumns.Add(olvColumnId);
            _listview.AllColumns.Add(olvColumnSent);
            _listview.AllColumns.Add(olvColumnRec);
            _listview.AllColumns.Add(olvColumnState);
            _listview.AllColumns.Add(olvColumnIp);
            _listview.AllColumns.Add(olvColumnAddress);
            _listview.CellEditUseWholeCell = false;
            _listview.Columns.AddRange(new ColumnHeader[] {
                olvColumnId,
                olvColumnSent,
                olvColumnRec,
                olvColumnState,
                olvColumnIp,
                olvColumnAddress
            });
            _listview.Cursor        = Cursors.Default;
            _listview.Dock          = DockStyle.Fill;
            _listview.HideSelection = false;
            _listview.Location      = new Point(0, 0);
            _listview.Name          = "fastObjectListView1";
            _listview.ShowGroups    = false;
            _listview.Size          = new Size(925, 551);
            _listview.TabIndex      = 21;
            _listview.UseCompatibleStateImageBehavior = false;
            _listview.View        = View.Details;
            _listview.VirtualMode = true;

            //
            // olvColumnId
            //
            olvColumnId.AspectName = "UniqueId";
            olvColumnId.Text       = "UniqueId";
            //
            // olvColumnSent
            //
            olvColumnSent.AspectName = "ParcelsSent";
            olvColumnSent.Text       = "Parcels Sent";
            //
            // olvColumnRec
            //
            olvColumnRec.AspectName = "ParcelsReceived";
            olvColumnRec.Text       = "Parcels Received";
            //
            // olvColumnState
            //
            olvColumnState.AspectName = "State";
            olvColumnState.Text       = "State";
            olvColumnState.Width      = 150;
            //
            // olvColumnIp
            //
            olvColumnIp.AspectName = "IP";
            olvColumnIp.Text       = "IP";
            olvColumnIp.Width      = 90;
            //
            // olvColumnAddress
            //
            olvColumnAddress.AspectName = "Address";
            olvColumnAddress.Text       = "Hostname";
            olvColumnAddress.Width      = 125;

            _listview.Dock = DockStyle.Fill;
            splitContainer1.Panel1.Controls.Add(_listview);

            _pierceClient = new PierceClient();

            _strumpServer                   = new StrumpServer();
            _strumpServer.Certificate       = null;
            _strumpServer.InitialBufferSize = 2;
            _strumpServer.Port              = 1080;
            _strumpServer.Stats             = new Stats();
            _strumpServer.UseSSL            = false;

            _listview.SetObjects(new List <SOCKSRequest>());


            Logger.Instance.LogAdded += (sender, log) =>
            {
                if ((checkBoxLogging.Checked && log.Severity == Severity.Debug) || log.Severity != Severity.Debug)
                {
                    Print(log.ToString());
                }
            };


            _strumpServer.SockOutgoing = parcel =>
            {
                //if (parcel.Parcel != null && (checkBoxLogging.Checked && parcel.Parcel.Length > 5000))
                //    Logger.Log("STRUMP REC: " + parcel, Severity.Debug);
                var pierceMessage = new PierceMessage(parcel);
                while (!_pierceClient.Connected)
                {
                    Thread.Sleep(1000);
                }
                _pierceClient.Send(pierceMessage);
            };

            _strumpServer.ConnectionAdded   += (sender, request) => { _listview.AddObject(request); };
            _strumpServer.ConnectionRemoved += (sender, request) => { _listview.RemoveObject(request); };
        }