Exemplo n.º 1
0
        public Socket Accept()
        {
            byte[] response = new byte[262];

            if (_socket.Receive(response) < 10)
            {
                throw new SocksClientException("The connection was reset by the remote peer.");
            }

            if (response[0] != SocksClient.SOCKS_VERSION)
            {
                throw new SocksClientException("Socks version 5 is not supported by the proxy server.");
            }

            SocksReplyCode reply = (SocksReplyCode)response[1];

            if (reply != SocksReplyCode.Succeeded)
            {
                throw new SocksClientException("Socks proxy server request failed: " + reply.ToString());
            }

            _dstEP = SocksClient.ParseEndpoint(response, 3);

            return(_socket);
        }
Exemplo n.º 2
0
        private static EndPoint Request(Socket socket, SocksRequestCommand command, EndPoint dstAddr)
        {
            socket.Send(CreateRequest(command, dstAddr));

            byte[] response = new byte[262];

            if (socket.Receive(response) < 10)
            {
                throw new SocksClientException("The connection was reset by the remote peer.");
            }

            if (response[0] != SOCKS_VERSION)
            {
                throw new SocksClientException("Socks version 5 is not supported by the proxy server.");
            }

            SocksReplyCode replyCode = (SocksReplyCode)response[1];

            if (replyCode != SocksReplyCode.Succeeded)
            {
                throw new SocksClientException("Socks proxy server request failed: " + replyCode.ToString(), replyCode);
            }

            return(ParseEndpoint(response, 3));
        }
Exemplo n.º 3
0
        public Socket Accept()
        {
            byte[] response = new byte[262];

            if (_socket.Receive(response) < 10)
            {
                throw new SocksClientException("Invalid response received from proxy server");
            }

            if (response[0] != SocksClient.SOCKS_VERSION)
            {
                throw new SocksClientException("Socks version 5 is not supported by the proxy server.");
            }

            SocksReplyCode reply = (SocksReplyCode)response[1];

            if (reply != SocksReplyCode.Succeeded)
            {
                throw new SocksClientException("Socks proxy server request failed: " + reply.ToString());
            }

            _dstEP = new SocksEndPoint(response, 3);

            return(_socket);
        }
Exemplo n.º 4
0
        private SocksEndPoint Request(Socket socket, SocksRequestCommand command, SocksEndPoint dstAddr)
        {
            socket.Send(dstAddr.CreateRequest(command));

            byte[] response = new byte[262];

            if (socket.Receive(response) < 10)
            {
                throw new SocksClientException("Invalid response received from proxy server.");
            }

            if (response[0] != SOCKS_VERSION)
            {
                throw new SocksClientException("Socks version 5 is not supported by the proxy server.");
            }

            SocksReplyCode reply = (SocksReplyCode)response[1];

            if (reply != SocksReplyCode.Succeeded)
            {
                throw new SocksClientException("Socks proxy server request failed: " + reply.ToString());
            }

            return(new SocksEndPoint(response, 3));
        }
Exemplo n.º 5
0
 public SocksClientAuthenticationFailedException(string message, SocksReplyCode replyCode)
     : base(message)
 {
     _replyCode = replyCode;
 }
Exemplo n.º 6
0
 public SocksClientException(string message, SocksReplyCode replyCode)
     : base(message)
 {
     _replyCode = replyCode;
 }