コード例 #1
0
 private void RspHttpHandshakeReceive()
 {
     httpProxyState = new HttpProxyState(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 = "HTTP/1.1 407 Proxy Authentication Required\r\nProxy-Authenticate: Basic realm=\"RRR\"\r\n\r\n";
         dataSend += "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN" +
                     " \"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd\">" +
                     "<HTML>" +
                     "  <HEAD>" +
                     "    <TITLE>Error</TITLE>" +
                     "    <META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=ISO-8859-1\">" +
                     "  </HEAD>" +
                     "  <BODY><H1>407 Proxy Authentication Required.</H1></BODY>" +
                     "</HTML>";
         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 = "HTTP/1.1 200 Connection Established\r\n\r\n";
         byte[] httpData = System.Text.Encoding.UTF8.GetBytes(dataSend);
         _local.BeginSend(httpData, 0, httpData.Length, 0, new AsyncCallback(StartConnect), null);
     }
 }
コード例 #2
0
ファイル: Local.cs プロジェクト: hehaiquan/shadowsocks-csharp
 private void RspHttpHandshakeReceive()
 {
     command = 1; // Set TCP connect command
     httpProxyState = new HttpProxyState();
     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 == 0)
     {
         string dataSend = "HTTP/1.1 200 Connection Established\r\n\r\n";
         byte[] httpData = System.Text.Encoding.UTF8.GetBytes(dataSend);
         connection.BeginSend(httpData, 0, httpData.Length, 0, new AsyncCallback(StartConnect), null);
     }
 }
コード例 #3
0
ファイル: Local.cs プロジェクト: jw8013/shadowsocks-csharp
 private void RspHttpHandshakeReceive()
 {
     command = 1; // Set TCP connect command
     httpProxyState = new HttpProxyState();
     httpProxyState.httpAuthString = httpAuthString;
     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 = "HTTP/1.1 407 Proxy Authentication Required\r\nProxy-Authenticate: Basic realm=\"SSR\"\r\n\r\n";
         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 = "HTTP/1.1 200 Connection Established\r\n\r\n";
         byte[] httpData = System.Text.Encoding.UTF8.GetBytes(dataSend);
         connection.BeginSend(httpData, 0, httpData.Length, 0, new AsyncCallback(StartConnect), null);
     }
 }