コード例 #1
0
    public static void Main(String[] args)
    {
        try {
            Curl.GlobalInit((int)CURLinitFlag.CURL_GLOBAL_ALL);

            Easy easy = new Easy();

            Easy.WriteFunction wf = new Easy.WriteFunction(OnWriteData);
            easy.SetOpt(CURLoption.CURLOPT_WRITEFUNCTION, wf);

            Easy.SSLContextFunction sf = new Easy.SSLContextFunction(OnSSLContext);
            easy.SetOpt(CURLoption.CURLOPT_SSL_CTX_FUNCTION, sf);

            easy.SetOpt(CURLoption.CURLOPT_URL, args[0]);
            easy.SetOpt(CURLoption.CURLOPT_CAINFO, "ca-bundle.crt");

            easy.Perform();
            easy.Cleanup();

            Curl.GlobalCleanup();
        }
        catch (Exception ex) {
            Console.WriteLine(ex);
        }
    }
コード例 #2
0
        override public void Init()
        {
            try
            {
                Engine.Logger.Info("LibCurl init " + Curl.GlobalInit(CurlInitFlag.All).ToString());
                CurlHelper.OnErrorMessage += (msg) =>
                {
                    Engine.Logger.Error(msg);
                };
            }
            catch (Exception e)
            {
                Engine.Logger.Warn("Libcurl failed to initalize. Did you install it?");
                Engine.Logger.Warn("Debian: apt-get install libcurl4-openssl-dev");
                Engine.Logger.Warn("Redhat: yum install libcurl-devel");
                throw e;
            }

            var version = Curl.Version;

            Engine.Logger.Info("LibCurl version " + version);

            if (!Startup.DoSSLFix.HasValue && version.IndexOf("NSS") > -1)
            {
                Engine.Logger.Info("NSS Detected SSL ECC workaround enabled.");
                Startup.DoSSLFix = true;
            }
        }
コード例 #3
0
ファイル: SmtpMail.cs プロジェクト: jlankitus/Zendez-App
        private static void Main(string[] args)
        {
            try
            {
                Curl.GlobalInit(CurlInitFlag.All);

                using (var curl = new CurlEasy())
                {
                    /* This is the URL for your mailserver */
                    curl.Url = "smtp://*****:*****@example.org>");

                    /* Add two recipients, in this particular case they correspond to
                     * the To: and Cc: addressees in the header, but they could be any
                     * kind of recipient. */
                    using (var recipients = new CurlSlist())
                    {
                        recipients.Append("<*****@*****.**>");
                        recipients.Append("<*****@*****.**>");
                        curl.SetOpt(CurlOption.MailRcpt, recipients);

                        /* We're using a callback function to specify the payload (the
                         * headers and body of the message). You could just use the
                         * ReadData option to  specify a FILE pointer to read from. */
                        curl.ReadFunction = PayloadSource;
                        curl.ReadData     = new UploadContext();
                        curl.Upload       = true;

                        var res = curl.Perform();
                        if (res != CurlCode.Ok)
                        {
                            Console.WriteLine("CurlEasy.Perform() failed: " + res);
                        }
                    }

                    /* curl won't send the QUIT command until you call cleanup, so you should be
                     * able to re-use this connection for additional messages (setting
                     * CURLOPT_MAIL_FROM and CURLOPT_MAIL_RCPT as required, and calling
                     * Perform() again. It may not be a good idea to keep the
                     * connection open for a very long time though (more than a few minutes may
                     * result in the server timing out the connection), and you do want to clean
                     * up in the end.
                     */
                }

                Curl.GlobalCleanup();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                Console.ReadLine();
            }
        }
コード例 #4
0
        public async Task testRandomTryteHash()
        {
            var    powDiver = new PowDiver();
            ICurl  curl     = new Curl();
            String hash;

            int[] hashTrits          = new int[PowDiver.CURL_HASH_LENGTH], myTrits;
            int   i                  = 0,
                  testCount          = 20,
                  minWeightMagnitude = 9,
                  numCores           = -1; // use n-1 cores

            String trytes = getRandomTrytes();

            myTrits = Converter.ToTrits(trytes);
            await powDiver.Search(myTrits, minWeightMagnitude, 1);

            curl.Absorb(myTrits, 0, myTrits.Length);
            curl.Squeeze(hashTrits, 0, PowDiver.CURL_HASH_LENGTH);
            curl.Reset();
            hash = Converter.ToTrytes(hashTrits);
            var  hashToCheck = hash.Substring(PowDiver.CURL_HASH_LENGTH / 3 - minWeightMagnitude / 3);
            bool success     = isAllNines(hashToCheck);
            var  n           = minWeightMagnitude / 3;

            Assert.IsTrue(success, $"The hash should have {n} nines but was: {hashToCheck}");
        }
コード例 #5
0
        public void testRandomTryte_DoesNotCorrupt()
        {
            var powDiver = new PowDiver();
            // var powDiver = new PearlDiver();
            ICurl  curl = new Curl();
            String hash;

            int[] hashTrits          = new int[PowDiver.CURL_HASH_LENGTH], myTrits;
            int   i                  = 0,
                  testCount          = 20,
                  minWeightMagnitude = 9,
                  numCores           = -1; // use n-1 cores

            String trytes = getRandomTrytes();

            string orgTrytes = trytes.Clone() + "";

            myTrits = Converter.ToTrits(trytes);
            powDiver.Search(myTrits, minWeightMagnitude, 1).Wait();
            curl.Absorb(myTrits, 0, myTrits.Length);
            curl.Squeeze(hashTrits, 0, PowDiver.CURL_HASH_LENGTH);
            curl.Reset();
            hash = Converter.ToTrytes(hashTrits);
            var  hashToCheck = hash.Substring(PowDiver.CURL_HASH_LENGTH / 3 - minWeightMagnitude / 3);
            bool success     = isAllNines(hashToCheck);
            var  n           = minWeightMagnitude / 3;

            Assert.IsTrue(success, $"The hash should have {n} nines but was: {hashToCheck}");

            var powTrytes = Converter.ToTrytes(myTrits);

            Assert.AreEqual(orgTrytes, trytes);
            // These will differ in the last 27 chars which is the nonce.
            Assert.AreEqual(orgTrytes.Substring(0, 2646), powTrytes.Substring(0, 2646));
        }
コード例 #6
0
        public void ItDoesNotPanic()
        {
            // ReSharper disable StringLiteralTypo
            string seed = "ABCDEFGHIJKLMNOPQRSTUVWXYZ9ABCDEFGHIJKLMNOPQRSTUVWXYZ9ABCDEFGHIJKLMNOPQRSTUVWXYZ9";

            // ReSharper restore StringLiteralTypo
            seed = InputValidator.PadSeedIfNecessary(seed);

            sbyte[] trits = Converter.ToTrits(seed);

            ICurl c1 = new Curl(SpongeFactory.Mode.CURLP27);
            ICurl c2 = new Curl(SpongeFactory.Mode.CURLP27);
            ICurl c3 = new Curl(SpongeFactory.Mode.CURLP27);

            int start     = 1;
            int index     = 5;
            int treeDepth = 5;
            int leafCount = 9;
            int security  = 1;
            //int[] digest = new int[MAM.Utils.Constants.DigestLength];

            var rootNode = MerkleTree.CreateMerkleTree(
                trits, start, (uint)leafCount, security, c1, c2, c3);

            var someBranch = MerkleTree.CreateMerkleBranch(rootNode, index);

            Assert.AreEqual(20, rootNode.Size);
            Assert.AreEqual(treeDepth, rootNode.Depth);
            Assert.AreEqual(leafCount, rootNode.Count);

            int branchLength = someBranch.Length;

            Assert.AreEqual(treeDepth - 1, branchLength);
        }
コード例 #7
0
        public void Perform()
        {
            try
            {
                using (Curl curl = new Curl())
                {
                    //Curl.GlobalInit((int)CURLinitFlag.CURL_GLOBAL_ALL);

                    curl.OnWriteCallback = new Curl.GenericCallbackDelegate(OnWriteData);
                    curl.SetWriteData(null);

                    // simple post - with a string
                    curl.SetPost();
                    curl.SetPostFields("url=index%3Dstripbooks&field-keywords=Topology&Go.x=10&Go.y=10");

                    curl.SetUserAgent("Mozilla 4.0 (compatible; MSIE 6.0; Win32");
                    curl.SetFollowLocation(true);
                    curl.SetUrl("http://www.amazon.com/exec/obidos/search-handle-form/002-5928901-6229641");

                    curl.Perform();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
コード例 #8
0
        private void Go_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Output.Document.Blocks.Clear();

                Curl curl = new Curl();
                curl.Method                = Method.Text;
                curl.Url                   = Url.Text;
                curl.Body                  = Body.Text;
                curl.Headers               = Headers;
                curl.JsonContent           = ChkJson.IsChecked.HasValue ? ChkJson.IsChecked.Value : false;
                curl.AcceptSelfSignedCerts = ChkSelfSigne.IsChecked.HasValue ? ChkSelfSigne.IsChecked.Value : false;
                curl.Verbose               = ChkVerbose.IsChecked.HasValue ? ChkVerbose.IsChecked.Value : false;

                curl.Run();

                HistoryManager.Add(Url.Text);
                Output.AppendText(curl.Output);
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, ":(", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #9
0
        private static void Main(string[] args)
        {
            try
            {
                Curl.GlobalInit(CurlInitFlag.All);

                using (var curl = new CurlEasy())
                {
                    curl.Url    = "smtp://*****:*****@example.com>");
                    using (var recipients = new CurlSlist())
                    {
                        recipients.Append("<*****@*****.**>");
                        recipients.Append("<*****@*****.**>");
                        var s = recipients.Strings;
                        curl.SetOpt(CurlOption.MailRcpt, recipients.Handle);

                        curl.Perform();
                    }
                }

                Curl.GlobalCleanup();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
コード例 #10
0
        /// <summary>
        /// 初始化配置
        /// </summary>
        private void InitSettings()
        {
            //初始化设备ID
            Settings.deviceId = CommonFunction.GetMachineGuid();
            Settings.Xlog.Add("软件启动,设备ID:" + Settings.deviceId, "系统日志");

            //初始化数据库,如果不存在则创建空数据库
            var dbPath = CreatPath(@"\data") + @"\db.data";

            Settings.db = new Db(dbPath);
            Settings.Xlog.Add("初始化数据库成功,数据库地址:" + dbPath, "系统日志");

            //根据设备ID读取设备配置,如果无配置则创建空配置
            Settings.sc = Settings.db.ReadConfig(Settings.deviceId);
            Settings.Xlog.Add("载入软件配置成功", "系统日志");

            //初始化缓存路径
            Settings.sc.cachePath = CreatPath(@"\cache");
            Settings.Xlog.Add("缓存路径:" + Settings.sc.cachePath, "系统日志");

            //初始化网络访问代理配置
            Curl.InitProxy();

            //如果缺少必要配置,必须先进行配置,此处修改适配8.1改动
            if (string.IsNullOrEmpty(Settings.sc.device_name) || string.IsNullOrEmpty(Settings.sc.game_path) || !Settings.sc.game_path.Contains("_retail_"))
            {
                using (var c = new Config())
                {
                    c.StartPosition = FormStartPosition.CenterScreen;
                    c.FormClosed   += C_FormClosed;
                    c.ShowDialog();
                }
            }
        }
コード例 #11
0
        public void VersionTest()
        {
            string version = Curl.GetVersion();

            Assert.NotNull(version);
            Assert.False(version == "", "Version is empty");
        }
コード例 #12
0
ファイル: Upload.cs プロジェクト: wz2cool/CurlSharp
        public static void Main(String[] args)
        {
            try
            {
                Curl.GlobalInit(CurlInitFlag.All);

                using (var fs = new FileStream(args[0], FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    using (var easy = new CurlEasy())
                    {
                        easy.ReadFunction  = OnReadData;
                        easy.ReadData      = fs;
                        easy.DebugFunction = OnDebug;
                        easy.SetOpt(CurlOption.Verbose, true);
                        easy.ProgressFunction = OnProgress;
                        easy.Url = args[1];
                        easy.SetOpt(CurlOption.UserPwd, args[2] + ":" + args[3]);
                        easy.Upload     = true;
                        easy.InfileSize = fs.Length;

                        easy.Perform();
                    }
                }

                Curl.GlobalCleanup();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                Console.ReadLine();
            }
        }
コード例 #13
0
 private void logQuery(object sender, DoWorkEventArgs e)
 {
     Curl.GlobalInit(CurlInitFlag.All);
     using (var easy = new CurlEasy())
     {
         String[] ar         = e.Argument as String[];
         string   postData   = "form_submitted=1&form_username="******"&form_password="******"&form_autologin=1";
         var      postLength = postData.Length;
         easy.WriteFunction += OnWriteData;
         easy.WriteData      = null;
         easy.UserAgent      = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/32.0.1700.107 Chrome/32.0.1700.107 Safari/537.36";
         easy.FollowLocation = true;
         easy.Url            = "https://thepilotslife.com/?";
         string   fileName = "cookie.txt";
         FileInfo f        = new FileInfo(fileName);
         easy.CookieJar     = f.FullName;
         easy.CookieFile    = f.FullName;
         easy.SslVerifyPeer = false;
         easy.CookieSession = true;
         easy.Post          = true;
         easy.PostFields    = postData;
         easy.PostFieldSize = postLength;
         var code = easy.Perform();
     }
     Curl.GlobalCleanup();
 }
コード例 #14
0
        public void testRandomTryteHash()
        {
            PowDiver powDiver = new PowDiver();
            Curl     curl     = new Curl();
            String   hash;

            int[] hashTrits = new int[PowDiver.CURL_HASH_LENGTH],
            myTrits;
            int i                  = 0,
                testCount          = 20,
                minWeightMagnitude = 9,
                numCores           = -1; // use n-1 cores

            String trytes = getRandomTrytes();

            myTrits = Converter.ToTrits(trytes);
            powDiver.search(myTrits, minWeightMagnitude, numCores);
            curl.Absorb(myTrits, 0, myTrits.Length);
            curl.Squeeze(hashTrits, 0, PowDiver.CURL_HASH_LENGTH);
            curl.Reset();
            hash = Converter.ToTrytes(hashTrits);
            bool success = isAllNines(hash.Substring(PowDiver.CURL_HASH_LENGTH / 3 - minWeightMagnitude / 3));

            Assert.IsTrue(success, "The hash should have n nines");
        }
コード例 #15
0
 public LibCurlScraper()
 {
     UserAgent   = "useragent";
     ContentType = "application/x-www-form-urlencoded";
     Curl.GlobalInit((int)CURLinitFlag.CURL_GLOBAL_ALL);
     DisplayHeaders = false;
 }
コード例 #16
0
    public static void run(String[] args)
    {
        try {
            Curl.GlobalInit((int)CURLinitFlag.CURL_GLOBAL_ALL);

            VersionInfoData vd = Curl.GetVersionInfo(CURLversion.CURLVERSION_NOW);
            Console.WriteLine("           Age: {0}", vd.Age);
            Console.WriteLine("Version String: {0}", vd.Version);
            Console.WriteLine("Version Number: {0}", vd.VersionNum);
            Console.WriteLine("   Host System: {0}", vd.Host);
            Console.WriteLine("Feature Bitmap: {0}", vd.Features);
            Console.WriteLine("   SSL Version: {0}", vd.SSLVersion);
            Console.WriteLine("SSL VersionNum: {0}", vd.SSLVersionNum);
            Console.WriteLine("  LibZ Version: {0}", vd.LibZVersion);
            Console.WriteLine("  ARES Version: {0}", vd.ARes);
            Console.WriteLine("  ARES Ver Num: {0}", vd.AResNum);
            Console.WriteLine("LibIDN Version: {0}", vd.LibIDN);
            Console.WriteLine();
            Console.WriteLine("Protocols:");
            String[] protocols = vd.Protocols;
            foreach (String prot in protocols)
            {
                Console.WriteLine("  {0}", prot);
            }

            Curl.GlobalCleanup();
        }
        catch (Exception ex) {
            Console.WriteLine(ex);
        }
    }
コード例 #17
0
ファイル: Html.cs プロジェクト: git-thinh/ben
        public static string f_https_getTextByUrl(string url)
        {
            var dataRecorder = new EasyDataRecorder();

            Curl.GlobalInit((int)CURLinitFlag.CURL_GLOBAL_DEFAULT);
            try
            {
                using (Easy easy = new Easy())
                {
                    easy.SetOpt(CURLoption.CURLOPT_WRITEFUNCTION, (Easy.WriteFunction)dataRecorder.HandleWrite);

                    Easy.SSLContextFunction sf = new Easy.SSLContextFunction(OnSSLContext);
                    easy.SetOpt(CURLoption.CURLOPT_SSL_CTX_FUNCTION, sf);

                    easy.SetOpt(CURLoption.CURLOPT_URL, url);
                    //easy.SetOpt(CURLoption.CURLOPT_CAINFO, "ca-bundle.crt");
                    easy.SetOpt(CURLoption.CURLOPT_CAINFO, "ca-bundle.crt");


                    easy.Perform();
                }
            }
            finally
            {
                Curl.GlobalCleanup();
            }

            string s = Encoding.UTF8.GetString(dataRecorder.Written.ToArray());

            return(s);
        }
コード例 #18
0
ファイル: WechatBasicApi.cs プロジェクト: wolfweb/Ww
 //method: 获取用户基本信息
 //help  : http://mp.weixin.qq.com/wiki/index.php?title=获取用户基本信息
 //url   : https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN                  
 #region result
 //{
 //    "subscribe": 1, 
 //    "openid": "o6_bmjrPTlm6_2sgVt7hMZOPfL2M", 
 //    "nickname": "Band", 
 //    "sex": 1, 
 //    "language": "zh_CN", 
 //    "city": "广州", 
 //    "province": "广东", 
 //    "country": "中国", 
 //    "headimgurl":    "http://wx.qlogo.cn/mmopen/g3MonUZtNHkdmzicIlibx6iaFqAc56vxLSUfpb6n5WKSYVY0ChQKkiaJSgQ1dZuTOgvLLrhJbERQQ4eMsv84eavHiaiceqxibJxCfHe/0", 
 //    "subscribe_time": 1382694957,
 //    "unionid": " o6_bmasdasdsad6_2sgVt7hMZOPfL"
 //}
 #endregion
 public static WechatResponseWrapper<WechatUserInfo> GetUserBaseInfo(String accessToken, String openId)
 {
     String reqUrl = String.Format("https://api.weixin.qq.com/cgi-bin/user/info?access_token={0}&openid={1}&lang=zh_CN",
         accessToken, openId);
     String respText = new Curl().Get(reqUrl);
     return new WechatResponseWrapper<WechatUserInfo>(reqUrl, respText);
 }
コード例 #19
0
ファイル: WechatBasicApi.cs プロジェクト: wolfweb/Ww
        //method: 发送客服消息
        //help  : http://mp.weixin.qq.com/wiki/index.php?title=发送客服消息
        //url   : https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN

        public static WechatResponseWrapper SendCustomMessage(String acessToken, WechatSendMessage message)
        {
            String reqUrl = String.Format("https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={0}",
                acessToken);
            String respText = new Curl().Post(reqUrl, JsonConvert.SerializeObject(message));
            return new WechatResponseWrapper(reqUrl, respText);
        }
コード例 #20
0
    public static void run(String[] args)
    {
        try {
            Curl.GlobalInit((int)CURLinitFlag.CURL_GLOBAL_ALL);

            dnsLock    = new Object();
            cookieLock = new Object();

            Share share              = new Share();
            Share.LockFunction   lf  = new Share.LockFunction(OnLock);
            Share.UnlockFunction ulf = new Share.UnlockFunction(OnUnlock);
            share.SetOpt(CURLSHoption.CURLSHOPT_LOCKFUNC, lf);
            share.SetOpt(CURLSHoption.CURLSHOPT_UNLOCKFUNC, ulf);
            share.SetOpt(CURLSHoption.CURLSHOPT_SHARE,
                         CURLlockData.CURL_LOCK_DATA_COOKIE);
            share.SetOpt(CURLSHoption.CURLSHOPT_SHARE,
                         CURLlockData.CURL_LOCK_DATA_DNS);

            EasyThread et1 = new EasyThread(args[0], share);
            EasyThread et2 = new EasyThread(args[1], share);
            Thread     t1  = new Thread(new ThreadStart(et1.ThreadFunc));
            Thread     t2  = new Thread(new ThreadStart(et2.ThreadFunc));
            t1.Start();
            t2.Start();
            t1.Join();
            t2.Join();

            share.Cleanup();
            Curl.GlobalCleanup();
        }
        catch (Exception ex) {
            Console.WriteLine(ex);
        }
    }
コード例 #21
0
ファイル: Program.cs プロジェクト: git-thinh/tt2
    public static void Main(String[] args)
    {
        try
        {
            Curl.GlobalInit((int)CURLinitFlag.CURL_GLOBAL_ALL);

            Easy easy = new Easy();

            Easy.WriteFunction wf = new Easy.WriteFunction(OnWriteData);
            easy.SetOpt(CURLoption.CURLOPT_WRITEFUNCTION, wf);

            Easy.SSLContextFunction sf = new Easy.SSLContextFunction(OnSSLContext);
            easy.SetOpt(CURLoption.CURLOPT_SSL_CTX_FUNCTION, sf);



            easy.SetOpt(CURLoption.CURLOPT_URL, "https://dictionary.cambridge.org/grammar/british-grammar/above-or-over");
            easy.SetOpt(CURLoption.CURLOPT_CAINFO, "ca-bundle.crt");

            easy.Perform();
            //easy.Cleanup();
            //easy.Dispose();

            Curl.GlobalCleanup();

            Console.WriteLine("Enter to exit ...");
            Console.ReadLine();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
        }
    }
コード例 #22
0
    public static void Main(String[] args)
    {
        try {
            Curl.GlobalInit((int)CURLinitFlag.CURL_GLOBAL_ALL);

            Easy easy = new Easy();

            Easy.WriteFunction wf = new Easy.WriteFunction(OnWriteData);
            easy.SetOpt(CURLoption.CURLOPT_WRITEFUNCTION, wf);

            // simple post - with a string
            easy.SetOpt(CURLoption.CURLOPT_POSTFIELDS,
                        "url=index%3Dstripbooks&field-keywords=Topology&Go.x=10&Go.y=10");

            easy.SetOpt(CURLoption.CURLOPT_USERAGENT,
                        "Mozilla 4.0 (compatible; MSIE 6.0; Win32");
            easy.SetOpt(CURLoption.CURLOPT_FOLLOWLOCATION, true);
            easy.SetOpt(CURLoption.CURLOPT_URL,
                        "http://www.amazon.com/exec/obidos/search-handle-form/002-5928901-6229641");
            easy.SetOpt(CURLoption.CURLOPT_POST, true);

            easy.Perform();
            easy.Cleanup();

            Curl.GlobalCleanup();
        }
        catch (Exception ex) {
            Console.WriteLine(ex);
        }
    }
コード例 #23
0
    public static void Main(String[] args)
    {
        try
        {
            Curl.GlobalInit(CurlInitFlag.All);

            var vd = Curl.GetVersionInfo(CurlVersion.Now);
#if USE_LIBCURLSHIM
            Console.WriteLine("           Age: {0}", vd.Age);
            Console.WriteLine("Version String: {0}", vd.Version);
            Console.WriteLine("Version Number: {0}", vd.VersionNum);
            Console.WriteLine("   Host System: {0}", vd.Host);
            Console.WriteLine("Feature Bitmap: {0}", vd.Features);
            Console.WriteLine("   Ssl Version: {0}", vd.SslVersion);
            Console.WriteLine("Ssl VersionNum: {0}", vd.SSLVersionNum);
            Console.WriteLine("  LibZ Version: {0}", vd.LibZVersion);
            Console.WriteLine("  ARES Version: {0}", vd.ARes);
            Console.WriteLine("  ARES Ver Num: {0}", vd.AResNum);
            Console.WriteLine("LibIdn Version: {0}", vd.LibIdn);
            Console.WriteLine();
            Console.WriteLine("Protocols:");
            var protocols = vd.Protocols;
            foreach (var prot in protocols)
            {
                Console.WriteLine("  {0}", prot);
            }
#endif
            Curl.GlobalCleanup();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
            Console.ReadLine();
        }
    }
コード例 #24
0
 internal static void ThrowIfNotOk(this Curl instance, CurlCode code)
 {
     if (code != CurlCode.Ok)
     {
         throw new CurlException(code, instance);
     }
 }
コード例 #25
0
        public static void Main(String[] args)
        {
            try
            {
                Curl.GlobalInit(CurlInitFlag.All);

                using (var easy = new CurlEasy())
                {
                    const string postData = "url=index%3Dstripbooks&field-keywords=Topology&Go.x=10&Go.y=10";
                    easy.WriteFunction  = OnWriteData;
                    easy.WriteData      = null;
                    easy.PostFields     = postData;
                    easy.PostFieldSize  = postData.Length;
                    easy.UserAgent      = "Mozilla 4.0 (compatible; MSIE 6.0; Win32";
                    easy.FollowLocation = true;
                    easy.Url            = "http://www.amazon.com/exec/obidos/search-handle-form/002-5928901-6229641";
                    easy.Post           = true;

                    var code = easy.Perform();
                }

                Curl.GlobalCleanup();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
コード例 #26
0
ファイル: WechatBasicApi.cs プロジェクト: wolfweb/Ww
 //method: 获取 jsapi_ticket
 //help  : http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html
 //url   : https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=ACCESS_TOKEN&type=jsapi
 //resp  : { "errcode":0, "errmsg":"ok", "ticket":"bxLdikRXVbTPdHSM05e5u5sUoXNKd8-41ZO3MhKoyN5OfkWITDGgnr2fwJ0m9E8NYzWKVZvdVtaUgWvsdshFKA", "expires_in":7200 }
 public static WechatResponseWrapper<WechatJsapiTicket> GetJsapiTicket(String accessToken)
 {
     String reqUrl = String.Format("https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token={0}&type=jsapi",
         accessToken);
     String respText = new Curl().Get(reqUrl);
     //String respText = "{\"access_token\":\"-Ribi5K3sIZ3bgUrORlWu0BJDy7vS5JW2OYm8JYKEjG1luoNrsibj8kZHAdTp8Bc0Vpy9JdUxg013rKkM13ZAQ\",\"expires_in\":7200}";
     return new WechatResponseWrapper<WechatJsapiTicket>(reqUrl, respText);
 }
コード例 #27
0
ファイル: WechatBasicApi.cs プロジェクト: wolfweb/Ww
 //method: 获取access token
 //help  : http://mp.weixin.qq.com/wiki/15/54ce45d8d30b6bf6758f68d2e95bc627.html
 //url   : https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET
 //result: {"access_token":"ACCESS_TOKEN","expires_in":7200}
 public static WechatResponseWrapper<WechatAccessToken> GetAccessToken(String appId, String appSecret)
 {
     String reqUrl = String.Format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}",
         appId, appSecret);
     String respText = new Curl().Get(reqUrl);
     //String respText = "{\"access_token\":\"-Ribi5K3sIZ3bgUrORlWu0BJDy7vS5JW2OYm8JYKEjG1luoNrsibj8kZHAdTp8Bc0Vpy9JdUxg013rKkM13ZAQ\",\"expires_in\":7200}";
     return new WechatResponseWrapper<WechatAccessToken>(reqUrl, respText);
 }
コード例 #28
0
        private void test()
        {
            Log.console("homecontroller.test()");
            Curl   ocurl    = new Curl();
            string response = ocurl.get_response();

            Log.file(response, "response");
        }
コード例 #29
0
ファイル: WechatBasicApi.cs プロジェクト: wolfweb/Ww
 //method: 刷新access_token有效期
 //url   : https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=APPID&grant_type=refresh_token&refresh_token=REFRESH_TOKEN
 //result: {"access_token":"ACCESS_TOKEN", "expires_in":7200, "refresh_token":"REFRESH_TOKEN", "openid":"OPENID", "scope":"SCOPE"}
 //error : {"errcode":40030,"errmsg":"invalid refresh_token"}
 public static WechatResponseWrapper<WechatAccessToken> RefreshAccessToken(String appId, String refresh_token) {
     String grant_type = "refresh_token";
     String reqUrl = String.Format("https://api.weixin.qq.com/sns/oauth2/refresh_token?appid={0}&grant_type={1}&refresh_token={2}",
         appId, grant_type, refresh_token);
     String respText = new Curl().Get(reqUrl);
     //String respText = "{\"access_token\":\"-Ribi5K3sIZ3bgUrORlWu0BJDy7vS5JW2OYm8JYKEjG1luoNrsibj8kZHAdTp8Bc0Vpy9JdUxg013rKkM13ZAQ\",\"expires_in\":7200}";
     return new WechatResponseWrapper<WechatAccessToken>(reqUrl, respText);
 }
コード例 #30
0
 protected override bool ReleaseHandle()
 {
     if (_initialized && _available)
     {
         Curl.GlobalCleanup();
         _available = false;
     }
     return(true);
 }
コード例 #31
0
ファイル: FileUpload.cs プロジェクト: git-thinh/tt2
    public static void run(String[] args)
    {
        try {
            Curl.GlobalInit((int)CURLinitFlag.CURL_GLOBAL_ALL);

            // <form action="http://mybox/cgi-bin/myscript.cgi
            //  method="post" enctype="multipart/form-data">
            MultiPartForm mf = new MultiPartForm();

            // <input name="frmUsername">
            mf.AddSection(CURLformoption.CURLFORM_COPYNAME, "frmUsername",
                          CURLformoption.CURLFORM_COPYCONTENTS, "testtcc",
                          CURLformoption.CURLFORM_END);

            // <input name="frmPassword">
            mf.AddSection(CURLformoption.CURLFORM_COPYNAME, "frmPassword",
                          CURLformoption.CURLFORM_COPYCONTENTS, "tcc",
                          CURLformoption.CURLFORM_END);

            // <input name="frmFileOrigPath">
            mf.AddSection(CURLformoption.CURLFORM_COPYNAME, "frmFileOrigPath",
                          CURLformoption.CURLFORM_COPYCONTENTS, args[1],
                          CURLformoption.CURLFORM_END);

            // <input name="frmFileDate">
            mf.AddSection(CURLformoption.CURLFORM_COPYNAME, "frmFileDate",
                          CURLformoption.CURLFORM_COPYCONTENTS, "08/01/2004",
                          CURLformoption.CURLFORM_END);

            // <input type="File" name="f1">
            mf.AddSection(CURLformoption.CURLFORM_COPYNAME, "f1",
                          CURLformoption.CURLFORM_FILE, args[1],
                          CURLformoption.CURLFORM_CONTENTTYPE, "application/binary",
                          CURLformoption.CURLFORM_END);

            Easy easy = new Easy();

            Easy.DebugFunction df = new Easy.DebugFunction(OnDebug);
            easy.SetOpt(CURLoption.CURLOPT_DEBUGFUNCTION, df);
            easy.SetOpt(CURLoption.CURLOPT_VERBOSE, true);

            Easy.ProgressFunction pf = new Easy.ProgressFunction(OnProgress);
            easy.SetOpt(CURLoption.CURLOPT_PROGRESSFUNCTION, pf);

            easy.SetOpt(CURLoption.CURLOPT_URL, args[0]);
            easy.SetOpt(CURLoption.CURLOPT_HTTPPOST, mf);

            easy.Perform();
            //easy.Cleanup();
            mf.Free();

            Curl.GlobalCleanup();
        }
        catch (Exception ex) {
            Console.WriteLine(ex);
        }
    }
コード例 #32
0
ファイル: Empleados.cs プロジェクト: JaredLevi23/Restaurante
        private void iconButton2_Click(object sender, EventArgs e)
        {
            try
            {
                JSON.Trabajador trabajador = new JSON.Trabajador();
                JSON.Api        api        = new JSON.Api();
                JSON.Curl       curl       = new Curl();


                curl.url   = "http://192.168.0.7:8084/esp32-api/public/api/verTrabajador";
                curl.verbo = Method.POST;
                curl.json  = trabajador;

                string fileJson = api.apicall(curl);
                //Console.WriteLine(fileJson);

                List <Trabajador> trabajadores = JsonConvert.DeserializeObject <List <Trabajador> >(fileJson);
                int array = trabajadores.Count;
                Console.WriteLine("" + array);
                int x = 10, y = 57;
                for (int i = 0; i < array; i++)
                {
                    string nom, ape, pue;

                    int id = Int32.Parse(trabajadores[i].idTrabajador.ToString());;
                    nom = trabajadores[i].Nombre.ToString();
                    ape = trabajadores[i].Apellido.ToString();
                    pue = trabajadores[i].Puesto.ToString();

                    Contenedor_Empleado contenedor = new Contenedor_Empleado(id, nom, ape, pue);
                    contenedor.Location = new Point(x, y);

                    if (i % 2 == 0)
                    {
                        if (i != 0 && i != 1)
                        {
                            x = 10;
                            y = y + 252;
                        }
                        else
                        {
                            x = x + 395;
                        }
                    }
                    else
                    {
                        x = 10;
                        y = y + 252;
                    }
                    panel2.Controls.Add(contenedor);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("ALGO SALIO MAAAAL :( : " + ex);
            }
        }
コード例 #33
0
        private void ThreadLaunch(TimelineHandler handler)
        {
            try
            {
                _log.Trace($"Attempting new thread for: {handler.HandlerType}");

                Thread t         = null;
                var    threadJob = new ThreadJob();
                threadJob.Id      = Guid.NewGuid().ToString();
                threadJob.Handler = handler;

                switch (handler.HandlerType)
                {
                case HandlerType.NpcSystem:
                //var npc = new NpcSystem(handler);
                //break;
                case HandlerType.Command:
                    t = new Thread(() =>
                    {
                        var bash = new Bash(handler);
                    });
                    t.IsBackground = true;
                    t.Name         = threadJob.Id;
                    t.Start();

                    //threadJob.ProcessName = ProcessManager.ProcessNames.Command;
                    break;

                case HandlerType.Curl:
                    t = new Thread(() =>
                    {
                        var curl = new Curl(handler);
                    });
                    t.IsBackground = true;
                    t.Name         = threadJob.Id;
                    t.Start();

                    //threadJob.ProcessName = ProcessManager.ProcessNames.Command;
                    break;
                }

                if (threadJob.ProcessName != null)
                {
                    this._threadJobs.Add(threadJob);
                }

                if (t != null)
                {
                    this._threads.Add(t);
                }
            }
            catch (Exception e)
            {
                _log.Error(e);
            }
        }
コード例 #34
0
ファイル: Program.cs プロジェクト: mili-tan/Tokuiten.Yako
        //curl https://pixiv.net/
        //curl: (35) schannel: failed to receive handshake, SSL/TLS connection failed

        //curl http://www.example.com/?name=www.twitter.com
        //curl: (56) Recv failure: Connection was reset

        static void Main()
        {
            try
            {
                var aResolve = new DnsClient(IPAddress.Parse("2.2.2.2"), 5000).Resolve(DomainName.Parse("pixiv.net"));
                aResolve.AnswerRecords.ForEach(Console.WriteLine);
                var bResolve = new DnsClient(IPAddress.Parse("2.2.2.2"), 5000).Resolve(DomainName.Parse("baidu.com"));
                bResolve.AnswerRecords.ForEach(Console.WriteLine);
                Curl.GlobalInit(CurlInitFlag.All);
                using (var easy = new CurlEasy())
                {
                    easy.DnsUseGlobalCache = false;
                    easy.DnsCacheTimeout   = 0;
                    //easy.Proxy = "127.0.0.1:7890";
                    easy.CaInfo = "cacert.pem";
                    //easy.SetOpt(CurlOption.DnsLocalIp4, "1.1.1.1");
                    easy.Url            = "https://pixiv.net/";
                    easy.ConnectTimeout = 5;
                    easy.Timeout        = 5;
                    easy.HeaderFunction = (buf, size, nmemb, data) => {
                        Console.Write(Encoding.UTF8.GetString(buf));
                        return(size * nmemb);
                    };
                    easy.WriteFunction = (buf, size, nmemb, data) => {
                        Console.Write(Encoding.UTF8.GetString(buf));
                        return(size * nmemb);
                    };
                    easy.Filetime = true;

                    var c = easy.Perform();
                    Console.WriteLine("Perform:" + c + (int)c);
                    Console.WriteLine("SslEngine: {0}", easy.SslEngine);
                    Console.WriteLine("Connect Time: {0}", easy.ConnectTime);
                    Console.WriteLine("Content Type: {0}", easy.ContentType);
                    Console.WriteLine("HTTP Connect Code: {0}", easy.HttpConnectCode);
                    Console.WriteLine("Name Lookup Time: {0}", easy.NameLookupTime);
                    Console.WriteLine("OS Errno: {0}", easy.OsErrno);
                    Console.WriteLine("Pretransfer time: {0}", easy.PreTransferTime);
                    Console.WriteLine("Redirect time: {0}", easy.RedirectTime);
                    Console.WriteLine("Response code: {0}", easy.ResponseCode);
                    Console.WriteLine("Ssl verification result: {0}", easy.SslVerifyResult);
                    Console.WriteLine("Start transfer time: {0}", easy.StartTransferTime);
                    Console.WriteLine("Total time: {0}", easy.TotalTime);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            finally
            {
                Curl.GlobalCleanup();
            }

            Console.ReadKey();
        }
コード例 #35
0
ファイル: MamService.cs プロジェクト: Faolain/Chiota
        public MamService(IIotaRepository repository, IMask mask, Seed seed)
        {
            var curl        = new Curl();
            var treeFactory = new CurlMerkleTreeFactory(new CurlMerkleNodeFactory(curl), new CurlMerkleLeafFactory(new AddressGenerator(seed, SecurityNumber)));
            var mamFactory  = new CurlMamFactory(curl, mask);
            var mamParser   = new CurlMamParser(mask, treeFactory, curl);

            this.ChannelFactory      = new MamChannelFactory(mamFactory, treeFactory, repository);
            this.SubscriptionFactory = new MamChannelSubscriptionFactory(repository, mamParser);
        }
コード例 #36
0
ファイル: WechatBasicApi.cs プロジェクト: wolfweb/Ww
 //method: 自定义菜单创建接口
 //url   : http://mp.weixin.qq.com/wiki/index.php?title=%E8%87%AA%E5%AE%9A%E4%B9%89%E8%8F%9C%E5%8D%95%E6%9F%A5%E8%AF%A2%E6%8E%A5%E5%8F%A3        
 public static WechatResponseWrapper CreateCustomMenu(String acessToken, WechatMenuButtonSet menu)
 {
     //https://api.weixin.qq.com/cgi-bin/menu/create?access_token=ACCESS_TOKEN
     String reqUrl = String.Format("https://api.weixin.qq.com/cgi-bin/menu/create?access_token={0}", acessToken);
     JsonSerializerSettings settings = new JsonSerializerSettings();
     settings.NullValueHandling = NullValueHandling.Ignore;
     String respText = new Curl().Post(reqUrl, JsonConvert.SerializeObject(menu, settings));
     return new WechatResponseWrapper(reqUrl, respText);
 }
コード例 #37
0
ファイル: WechatBasicApi.cs プロジェクト: wolfweb/Ww
 //method: 检验授权凭证(access_token)是否有效
 //url   : https://api.weixin.qq.com/sns/auth?access_token=ACCESS_TOKEN&openid=OPENID
 //result: {"errcode":0,"errmsg":"ok"}
 public static WechatResponseWrapper VerifyAccessToken(String access_token, String openid) {
     String reqUrl = String.Format("https://api.weixin.qq.com/sns/auth?access_token={0}&openid={1}",
         access_token, openid);
     String respText = new Curl().Get(reqUrl);
     return new WechatResponseWrapper(reqUrl, respText);
 }
コード例 #38
0
ファイル: WechatBasicApi.cs プロジェクト: wolfweb/Ww
 //method: 自定义菜单创建接口
 //url   : http://mp.weixin.qq.com/wiki/index.php?title=%E8%87%AA%E5%AE%9A%E4%B9%89%E8%8F%9C%E5%8D%95%E5%88%A0%E9%99%A4%E6%8E%A5%E5%8F%A3
 public static WechatResponseWrapper DeleteCustomMenu(String acessToken)
 {
     //https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=ACCESS_TOKEN
     String reqUrl = String.Format("https://api.weixin.qq.com/cgi-bin/menu/delete?access_token={0}", acessToken);
     String respText = new Curl().Get(reqUrl);
     return new WechatResponseWrapper(reqUrl, respText);
 }
コード例 #39
0
ファイル: WechatBasicApi.cs プロジェクト: wolfweb/Ww
 //method: 通过code换取网页授权access_token
 //url   : https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code
 public static WechatResponseWrapper<WechatAuthToken> GetAuthToken(String appId, String appSecret, String code)
 {
     String reqUrl = String.Format("https://api.weixin.qq.com/sns/oauth2/access_token?appid={0}&secret={1}&code={2}&grant_type=authorization_code",
        appId, appSecret, code);
     String respText = new Curl().Get(reqUrl);
     return new WechatResponseWrapper<WechatAuthToken>(reqUrl, respText);
 }