protected override void SetupData() { base.SetupData(); _connectionInfo = new ConnectionInfo(IPAddress.Loopback.ToString(), 777, "user", ProxyTypes.Http, IPAddress.Loopback.ToString(), 8122, "proxyUser", "proxyPwd", new KeyboardInteractiveAuthenticationMethod("user")); _connectionInfo.Timeout = TimeSpan.FromMilliseconds(100); _bytesReceivedByProxy = new List <byte>(); _actualException = null; _clientSocket = SocketFactory.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _proxyServer = new AsyncSocketListener(new IPEndPoint(IPAddress.Loopback, _connectionInfo.ProxyPort)); _proxyServer.Disconnected += socket => _disconnected = true; _proxyServer.BytesReceived += (bytesReceived, socket) => { if (_bytesReceivedByProxy.Count == 0) { socket.Send(Encoding.ASCII.GetBytes("Whatever\r\n")); socket.Shutdown(SocketShutdown.Send); } _bytesReceivedByProxy.AddRange(bytesReceived); }; _proxyServer.Start(); }
protected override void SetupData() { base.SetupData(); _connectionInfo = CreateConnectionInfo(new string('a', 256), new string('b', 255)); _connectionInfo.Timeout = TimeSpan.FromMilliseconds(100); _bytesReceivedByProxy = new List <byte>(); _actualException = null; _clientSocket = SocketFactory.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _proxyServer = new AsyncSocketListener(new IPEndPoint(IPAddress.Loopback, _connectionInfo.ProxyPort)); _proxyServer.Disconnected += socket => _disconnected = true; _proxyServer.BytesReceived += (bytesReceived, socket) => { _bytesReceivedByProxy.AddRange(bytesReceived); // Wait until we received the greeting if (_bytesReceivedByProxy.Count == 4) { socket.Send(new byte[] { // SOCKS version 0x05, // Username/password authentication 0x02 }); } }; _proxyServer.Start(); }
protected override void SetupData() { base.SetupData(); _connectionInfo = CreateConnectionInfo("proxyUser", "proxyPwd"); _connectionInfo.Timeout = TimeSpan.FromMilliseconds(100); _bytesReceivedByProxy = new List <byte>(); _clientSocket = SocketFactory.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _actualException = null; _proxyServer = new AsyncSocketListener(new IPEndPoint(IPAddress.Loopback, _connectionInfo.ProxyPort)); _proxyServer.Disconnected += socket => _disconnected = true; _proxyServer.BytesReceived += (bytesReceived, socket) => { if (_bytesReceivedByProxy.Count == 0) { socket.Send(new byte[] { // Reply version (null byte) 0x00, // Connection refused 0x5b }); } _bytesReceivedByProxy.AddRange(bytesReceived); }; _proxyServer.Start(); }
public void ProxyExceptionConstructorTest1() { string message = string.Empty; // TODO: Initialize to an appropriate value ProxyException target = new ProxyException(message); Assert.Inconclusive("TODO: Implement code to verify target"); }
protected override void Act() { try { Connector.Connect(_connectionInfo); Assert.Fail(); } catch (ProxyException ex) { _actualException = ex; } }
protected override void SetupData() { base.SetupData(); _connectionInfo = CreateConnectionInfo("proxyUser", "proxyPwd"); _connectionInfo.Timeout = TimeSpan.FromMilliseconds(100); _proxySocksVersion = GetNotSupportedSocksVersion(); _actualException = null; _clientSocket = SocketFactory.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _proxyServer = new AsyncSocketListener(new IPEndPoint(IPAddress.Loopback, _connectionInfo.ProxyPort)); _proxyServer.Disconnected += socket => _disconnected = true; _proxyServer.BytesReceived += (bytesReceived, socket) => { socket.Send(new byte[] { _proxySocksVersion }); }; _proxyServer.Start(); }
public void ProxyExceptionConstructorTest() { ProxyException target = new ProxyException(); Assert.Inconclusive("TODO: Implement code to verify target"); }
/// <summary> Initializes a new instance of the ProxyException class. </summary> /// <param name="socks5Error"> The error number returned by a SOCKS5 server. </param> public ProxyException(int socks5Error) : this(ProxyException.Socks5ToString(socks5Error)) { }