View Single Post
Author Message
raydan
Senior Member
Join Date: Aug 2006
Old 03-06-2011 , 04:41   [EXTENSION] cURL & Hash
Reply With Quote #1


A cURL extension in Sourcemod

A free and easy-to-use client-side URL transfer library, supporting DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, TELNET and TFTP. libcurl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, Kerberos), file transfer resume, http proxy tunneling and more!

cURL Website: http://curl.haxx.se/

Current Version: 1.3.0.0

This a a sourcemod extension, using libcurl
Current libcurl Information:
Version: libcurl/7.23.1 OpenSSL/0.9.8r zlib/1.2.5 libssh2/1.3.0
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp scp sftp smtp smtps telnet tftp

The extension includes 2 hash function (file hash, string hash), provided by openssl library:
Code:
enum Openssl_Hash {
 Openssl_Hash_MD5 = 0,
 Openssl_Hash_MD4,
 Openssl_Hash_MD2,
 Openssl_Hash_SHA,
 Openssl_Hash_SHA1,
 Openssl_Hash_SHA224,
 Openssl_Hash_SHA256,
 Openssl_Hash_SHA384,
 Openssl_Hash_SHA512,
 Openssl_Hash_RIPEMD160,
};
 
native curl_hash_file(const String:file[], Openssl_Hash:algorithm, Openssl_Hash_Complete:complete_callback, any:value=0);
 
native bool:curl_hash_string(const String:input[], dataSize, Openssl_Hash:algorithm, String:buffer[], maxlength);
More natives in cURL.inc or here



Developer Notes
  • Downloload the curl_examples.zip to see how to use
  • curl_echo.sp echo client test
  • curl_rcon.sp make a source rcon query to other server
  • curl_gmail.sp use read function send a email
  • curl_udp.sp send A2S_INFO to source server & get the result
  • curl_write_function.sp use write function download files
  • see http://curl.haxx.se/libcurl/c/example.html
Self Test
  • compile curl_self_test.sp & run curl_self_test and curl_hash_test
  • All output test files in addons/sourcemod/data/curl_test
    Test #1 Get cURL version & supported protocols
    Test #2 Get a web page
    Test #3 Get ca-bundle.crt for #4
    Test #4 Verify a https website using ca-bundle.crt
    Test #5 Get a web page body & header content to file
    Test #6 Download a image for #7
    Test #7 Upload image using curl_httppost() & get the uploaded image url
    Test #8 Download a file using ftps://
Sourcecode
https://code.google.com/p/sourcemod-curl-extension/

Download
https://code.google.com/p/sourcemod-...downloads/list


the windows version should install the following package (thanks Thrawn2 to figure out)
Microsoft Visual C++ 2005 Service Pack 1 Redistributable Package MFC Security Update
http://www.microsoft.com/download/en....aspx?id=26347


Last edited by raydan; 01-07-2012 at 06:44.
raydan is offline