Exemple #1
0
        public override void Connect(EndPoint remoteEndPoint)
        {
            if (remoteEndPoint == null)
            {
                throw new ArgumentNullException("remoteEndPoint");
            }

            if (!(remoteEndPoint is IPEndPoint || remoteEndPoint is DnsEndPoint))
            {
                throw new ArgumentException("remoteEndPoint must be IPEndPoint or DnsEndPoint", "remoteEndPoint");
            }

            try
            {
#if SILVERLIGHT && !WINDOWS_PHONE
                ProxyEndPoint.ConnectAsync(ClientAccessPolicyProtocol, ProcessConnect, remoteEndPoint);
#elif WINDOWS_PHONE
                ProxyEndPoint.ConnectAsync(ProcessConnect, remoteEndPoint);
#else
                ProxyEndPoint.ConnectAsync(ProcessConnect, remoteEndPoint);
#endif
            }
            catch (Exception e)
            {
                OnException(new Exception("Failed to connect proxy server", e));
            }
        }
        public override void Connect(EndPoint remoteEndPoint)
        {
            DnsEndPoint targetEndPoint = remoteEndPoint as DnsEndPoint;

            if (targetEndPoint == null)
            {
                OnCompleted(new ProxyEventArgs(new Exception("The argument 'remoteEndPoint' must be a DnsEndPoint")));
                return;
            }

            try
            {
#if SILVERLIGHT && !WINDOWS_PHONE
                ProxyEndPoint.ConnectAsync(ClientAccessPolicyProtocol, ProcessConnect, targetEndPoint);
#elif WINDOWS_PHONE
                ProxyEndPoint.ConnectAsync(ProcessConnect, remoteEndPoint);
#else
                ProxyEndPoint.ConnectAsync(null, ProcessConnect, targetEndPoint);
#endif
            }
            catch (Exception e)
            {
                OnException(new Exception("Failed to connect proxy server", e));
            }
        }
Exemple #3
0
        public override void Connect(EndPoint remoteEndPoint)
        {
            IPEndPoint targetEndPoint = remoteEndPoint as IPEndPoint;

            if (targetEndPoint == null)
            {
                OnCompleted(new ProxyEventArgs(new Exception("The argument 'remoteEndPoint' must be a IPEndPoint")));
                return;
            }

            try
            {
                ProxyEndPoint.ConnectAsync(null, ProcessConnect, targetEndPoint);
            }
            catch (Exception e)
            {
                OnException(new Exception("Failed to connect proxy server", e));
            }
        }
Exemple #4
0
        public override void Connect(EndPoint remoteEndPoint)
        {
            if (remoteEndPoint == null)
            {
                throw new ArgumentNullException("remoteEndPoint");
            }

            if (!(remoteEndPoint is IPEndPoint || remoteEndPoint is DnsEndPoint))
            {
                throw new ArgumentException("remoteEndPoint must be IPEndPoint or DnsEndPoint", "remoteEndPoint");
            }

            try
            {
                ProxyEndPoint.ConnectAsync(this.ProcessConnect, remoteEndPoint);
            }
            catch (Exception e)
            {
                this.OnException(new Exception("Failed to connect proxy server", e));
            }
        }
        public override void Connect(EndPoint remoteEndPoint)
        {
            if (remoteEndPoint == null)
            {
                throw new ArgumentNullException("remoteEndPoint");
            }

            if (!(remoteEndPoint is IPEndPoint || remoteEndPoint is DnsEndPoint))
            {
                throw new ArgumentException("remoteEndPoint must be IPEndPoint or DnsEndPoint", "remoteEndPoint");
            }

            //check if our hostname matches an ip address or not
            Match isProxyIpAddress = Regex.Match(ProxyHostName, @"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}");

            Debug.WriteLine("[PROXY] Connecting to proxy: " + ProxyHostName);

            if (isProxyIpAddress.Success)
            {
                Debug.WriteLine("[PROXY] endpoint is IP endpoint");
            }
            else
            {
                Debug.WriteLine("[PROXY] endpoint is a hostname/DNS endpoint");
                isProxyHostname = true;
            }

            try
            {
                //save reference to remote endpoint if we need to do back-and-forth connecting
                lastEndpoint = remoteEndPoint;
                ProxyEndPoint.ConnectAsync(null, ProcessConnect, remoteEndPoint);
            }
            catch (Exception e)
            {
                OnException(new Exception("[PROXY] Failed to connect proxy server", e));
            }
        }
        public override void Connect(EndPoint remoteEndPoint)
        {
            if (remoteEndPoint == null)
            {
                throw new ArgumentNullException("remoteEndPoint");
            }

            if (!(remoteEndPoint is IPEndPoint || remoteEndPoint is DnsEndPoint))
            {
                throw new ArgumentException("remoteEndPoint must be IPEndPoint or DnsEndPoint", "remoteEndPoint");
            }

            try
            {
                //save reference to remote endpoint if we need to do back-and-forth connecting
                lastEndpoint = remoteEndPoint;
                ProxyEndPoint.ConnectAsync(null, ProcessConnect, remoteEndPoint);
            }
            catch (Exception e)
            {
                OnException(new Exception("Failed to connect proxy server", e));
            }
        }