private void RspHttpHandshakeReceive() { command = 1; // Set TCP connect command if (httpProxyState == null) { httpProxyState = new HttpPraser(); } else { command = 1; } if (Util.Utils.isMatchSubNet(((IPEndPoint)_connection.RemoteEndPoint).Address, "127.0.0.0/8")) { httpProxyState.httpAuthUser = ""; httpProxyState.httpAuthPass = ""; } else { httpProxyState.httpAuthUser = _config.authUser; httpProxyState.httpAuthPass = _config.authPass; } int err = httpProxyState.HandshakeReceive(_firstPacket, _firstPacketLength, ref _remoteHeaderSendBuffer); if (err == 1) { _connection.BeginReceive(_connetionRecvBuffer, 0, _firstPacket.Length, 0, new AsyncCallback(HttpHandshakeRecv), null); } else if (err == 2) { string dataSend = httpProxyState.Http407(); byte[] httpData = System.Text.Encoding.UTF8.GetBytes(dataSend); _connection.BeginSend(httpData, 0, httpData.Length, 0, new AsyncCallback(HttpHandshakeAuthEndSend), null); } else if (err == 3) { Connect(); } else if (err == 4) { Connect(); } else if (err == 0) { string dataSend = httpProxyState.Http200(); byte[] httpData = System.Text.Encoding.UTF8.GetBytes(dataSend); _connection.BeginSend(httpData, 0, httpData.Length, 0, new AsyncCallback(StartConnect), null); } else if (err == 500) { string dataSend = httpProxyState.Http500(); byte[] httpData = System.Text.Encoding.UTF8.GetBytes(dataSend); _connection.BeginSend(httpData, 0, httpData.Length, 0, new AsyncCallback(HttpHandshakeAuthEndSend), null); } }
private void RspHttpHandshakeReceive() { if (httpProxyState == null) { httpProxyState = new HttpPraser(true); } httpProxyState.httpAuthUser = _config.authUser; httpProxyState.httpAuthPass = _config.authPass; byte[] remoteHeaderSendBuffer = null; int err = httpProxyState.HandshakeReceive(_firstPacket, _firstPacketLength, ref remoteHeaderSendBuffer); if (err == 1) { _local.BeginReceive(connetionRecvBuffer, 0, _firstPacket.Length, 0, new AsyncCallback(HttpHandshakeRecv), null); } else if (err == 2) { string dataSend = httpProxyState.Http407(); byte[] httpData = System.Text.Encoding.UTF8.GetBytes(dataSend); _local.BeginSend(httpData, 0, httpData.Length, 0, new AsyncCallback(HttpHandshakeAuthEndSend), null); } else if (err == 3) { Connect(); } else if (err == 4) { Connect(); } else if (err == 0) { string dataSend = httpProxyState.Http200(); byte[] httpData = System.Text.Encoding.UTF8.GetBytes(dataSend); _local.BeginSend(httpData, 0, httpData.Length, 0, new AsyncCallback(StartConnect), null); } else if (err == 500) { string dataSend = httpProxyState.Http500(); byte[] httpData = System.Text.Encoding.UTF8.GetBytes(dataSend); _local.BeginSend(httpData, 0, httpData.Length, 0, new AsyncCallback(HttpHandshakeAuthEndSend), null); } }
private void RspHttpHandshakeReceive() { command = 1; // Set TCP connect command httpProxyState = new HttpPraser(); httpProxyState.httpAuthUser = authUser; httpProxyState.httpAuthPass = authPass; int err = httpProxyState.HandshakeReceive(_firstPacket, _firstPacketLength, ref remoteHeaderSendBuffer); if (err == 1) { connection.BeginReceive(connetionRecvBuffer, 0, _firstPacket.Length, 0, new AsyncCallback(HttpHandshakeRecv), null); } else if (err == 2) { string dataSend = httpProxyState.Http407(); byte[] httpData = System.Text.Encoding.UTF8.GetBytes(dataSend); connection.BeginSend(httpData, 0, httpData.Length, 0, new AsyncCallback(HttpHandshakeAuthEndSend), null); } else if (err == 3) { Connect(); } else if (err == 4) { Connect(); } else if (err == 0) { string dataSend = httpProxyState.Http200(); byte[] httpData = System.Text.Encoding.UTF8.GetBytes(dataSend); connection.BeginSend(httpData, 0, httpData.Length, 0, new AsyncCallback(StartConnect), null); } }