How do i set the proxy and SOCKs in libcurl?
Posted
by
acidzombie24
on Stack Overflow
See other posts from Stack Overflow
or by acidzombie24
Published on 2011-01-15T08:34:32Z
Indexed on
2011/01/15
8:53 UTC
Read the original article
Hit count: 234
I am trying to configure my .NET app to use a proxy. My source is in C# but i learned CURL via C++. My question is where do i put the SOCKs IP and port? i looked through the documentation and didnt see it. I believe that is what is causing me these problems.
When i run this code it will quiet literally timeout and not call my header function or writer function. If i comment out the first two curlopt lines (the two proxy lines) my code runs with no problems.
In firefox i set the http proxy and SOCKs host separately, they are different IPs and ports. How do i set the sock part, the below has the dummy proxy set but i cant figure out the socks part.
static void Main(string[] args)
{
SeasideResearch.LibCurlNet.Curl.GlobalInit((int)SeasideResearch.LibCurlNet.CURLinitFlag.CURL_GLOBAL_ALL);
var curl = new Easy();
{
curl.SetOpt(CURLoption.CURLOPT_PROXY, "http://127.0.0.1:1234");
curl.SetOpt(CURLoption.CURLOPT_PROXYTYPE, CURLproxyType.CURLPROXY_SOCKS5);
curl.SetOpt(CURLoption.CURLOPT_URL, "http://whatismyipaddress.com/ip-lookup");
curl.SetOpt(CURLoption.CURLOPT_FOLLOWLOCATION, 1);
curl.SetOpt(CURLoption.CURLOPT_USERAGENT, @"Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2b5) Gecko/20091204 Firefox/3.6b5");
curl.SetOpt(CURLoption.CURLOPT_HEADERFUNCTION, hf);
curl.SetOpt(CURLoption.CURLOPT_HEADERDATA, data);
curl.SetOpt(CURLoption.CURLOPT_WRITEFUNCTION, wf);
curl.SetOpt(CURLoption.CURLOPT_WRITEDATA, sw);
curl.SetOpt(CURLoption.CURLOPT_SSL_VERIFYPEER, 0);
curl.Perform();
var sz = sw.ToString();
var myrealip = sz.IndexOf("12.34.56.78") !=-1;
}
//Console.WriteLine(sz);
SeasideResearch.LibCurlNet.Curl.GlobalCleanup();
}
© Stack Overflow or respective owner