Необходимо используя socks5 получить страничку, к примеру https://ipcheckit.com/ (обязательно https) Как это можно сделать? Нашла класс Org.Mentalis.Network.ProxySocket http://www.mentalis.org/soft/class.qpx?id=9 - работает с сокетами отлично, когда 80 порт. Но когда пытаюсь подсоединится на 443 порт, выдаёт "Your browser sent a request that this server could not understand" и я не удивлена, ведь https должен быть шифрованный а я шлю просто http запрос:
| Код | ProxySocket s = new ProxySocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); // set the proxy settings s.ProxyEndPoint = new IPEndPoint(IPAddress.Parse("124.160.239.233"), 1080); s.ProxyUser = "username"; s.ProxyPass = "password"; s.ProxyType = ProxyTypes.Socks5; // if you set this to ProxyTypes.None, // the ProxySocket will act as a normal Socket // connect to the remote server // (note that the proxy server will resolve the domain name for us) s.Connect("ipcheckit.com", 443); // send an HTTP request s.Send(Encoding.ASCII.GetBytes("GET / HTTP/1.1\r\nHost: ipcheckit.com\r\nUser-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0\r\n" + "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Language: ru-ru,ru;q=0.8,en-us;q=0.5,en;q=0.3\r\nAccept-Encoding: gzip, deflate\r\n" + "Connection: keep-alive\r\nCache-Control: max-age=0\r\n\r\n\r\n")); // read the HTTP reply int recv = 0; byte[] buffer = new byte[1024]; recv = s.Receive(buffer); while (recv > 0) { Console.Write(Encoding.ASCII.GetString(buffer, 0, recv)); recv = s.Receive(buffer); } // wait until the user presses enter Console.WriteLine("Press enter to continue..."); Console.ReadLine();
|
Есть варианты? |