コード例 #1
0
        public PingResult Send(string sAddrOrIPe)
        {
            IPAddress addr;

            if (IPAddress.TryParse(sAddrOrIPe, out addr))
            {
                return(Send(addr));
            }
            var ipe = SocketHelper.ParseEndPoint(sAddrOrIPe);

            return(Send(ipe));
        }
コード例 #2
0
        private void CheckSocks(HttpContext context, out Guid agentSock, out IPEndPoint agentDirect)
        {
            string direct = context.Request.Headers[AgentDirect];

            if (!Guid.TryParseExact(context.Request.Headers[AgentSock], "N", out agentSock) || string.IsNullOrEmpty(direct))
            {
                this.ResponseForbidden(context);
            }
            try
            {
                agentDirect = SocketHelper.ParseEndPoint(direct);
                if (agentDirect.Address.Equals(IPAddress.Loopback) && BlockPorts.Contains((ushort)agentDirect.Port))
                {
                    throw new HttpException(403, string.Format("CheckSocks proxyClient({0}) invalid", agentDirect));
                }
            }
            catch (ArgumentException)
            {
                agentDirect = null;
                this.ResponseForbidden(context);
            }
        }
コード例 #3
0
 private void checkBox1_CheckedChanged(object sender, EventArgs e)
 {
     if (((CheckBox)sender).Checked)
     {
         if (!_initialized)
         {
             Cursor = Cursors.WaitCursor;
             try
             {
                 var ipe = SocketHelper.ParseEndPoint(textBox1.Text);
                 this.monitorUserControl1.Initialize(ipe);
                 _initialized = true;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 App.LogError(ex, "MonitorClient");
             }
             Cursor = Cursors.Arrow;
         }
         if (_task == null || _task.IsCompleted)
         {
             _task = TaskHelper.Factory.StartNew(() =>
             {
                 while (_initialized)
                 {
                     this.monitorUserControl1.UpdateDisplay();
                     Thread.Sleep(200);
                 }
             });
         }
     }
     else
     {
         _initialized = false;
     }
 }