erikminekus / sm-ripext Goto Github PK
View Code? Open in Web Editor NEWSourceMod REST in Pawn Extension
Home Page: https://forums.alliedmods.net/showthread.php?t=298024
License: GNU General Public License v3.0
SourceMod REST in Pawn Extension
Home Page: https://forums.alliedmods.net/showthread.php?t=298024
License: GNU General Public License v3.0
FormatString
9d4f069 can fail and you have to check for exceptions in the VM like here https://cs.alliedmods.net/sourcemod/source/core/logic/smn_console.cpp#156-162
Just scrolling through the commits 🍻
Lines 42 to 46 in 55e1f01
If OS doesn't reallocate memory, she also doesn't remove data by old pointer.
But we rewrite pointer, and if OS doesn't reallocated memory - we also lose some memory.
Downloading files using HTTPClient.DownloadFile returns timeout error after reaching HTTPClient.Timeout amount of seconds being in that process, but with almost no data downloaded at all, whether it was 30 seconds or 5 minutes given as timeout value, downloaded amount of data was less than 1kb.
Doesn't seem to be related to headers sent with the request, at least setting Accept/Accept-Encoding/Content-Type/Host didn't make any difference.
Such behavior is true only for some files (wasn't able to identify what could be the reason), but trying to download same files directly with curl (7.68.0 and 7.75.0) succeeds without any errors whatsoever.
Such case's different files' URLs:
https://gamebanana.com/dl/509036
https://fastdlv2.gflclan.com/file/gflfastdlv2/csgo/maps/bhop_lego3.bsp.bz2
https://images.pexels.com/photos/325185/pexels-photo-325185.jpeg
https://www.learningcontainer.com/wp-content/uploads/2020/05/sample-large-zip-file.zip
Fully downloaded file located in <sourcemod>/data directory
An error telling request was timed out returned
Used url: https://images.pexels.com/photos/325185/pexels-photo-325185.jpeg with different timeouts.
With 30s timeout set: Operation timed out after 29999 milliseconds with 555 out of 8635776 bytes received
With 305s timeout set: Operation timed out after 304999 milliseconds with 553 out of 8635776 bytes received
after i move to my new VPS the PUT is not working, always return HTTPStatus_Invalid = 0.
My Old VPS : Plesk Panel (PHP 7.4.20 + Server API FPM/FastCGI)
My New VPS : Cyberpanel (PHP 7.4.20 + Server API LiteSpeed V7.9)
Tested with REST in Pawn v1.2.3 and REST in Pawn v1.3.0
=== Info: STATE: INIT => CONNECT handle 0xde922140; line 1646 (connection #-5000)
=== Info: Found bundle for host subdomain.domain.com: 0xde9070c0 [can multiplex]
=== Info: Re-using existing connection! (#0) with host subdomain.domain.com
=== Info: Connected to subdomain.domain.com (194.XXX.XX.XX) port 443 (#0)
=== Info: STATE: CONNECT => DO handle 0xde922140; line 1700 (connection #0)
=== Info: http2_send len=194
=== Info: h2 header: :method:PUT
=== Info: h2 header: :path:/api/retakes/76561199145573335
=== Info: h2 header: :scheme:https
=== Info: h2 header: :authority:subdomain.domain.com
=== Info: h2 header: user-agent:sm-ripext/1.3.0
=== Info: h2 header: accept-encoding:deflate, gzip
=== Info: h2 header: accept:application/json
=== Info: h2 header: content-type:applicaton/json
=== Info: http2_send request allowed 1 (easy handle 0xde922140)
=== Info: Using Stream ID: 3 (easy handle 0xde922140)
==> Send header
PUT /api/retakes/76561199145573335 HTTP/2
Host: subdomain.domain.com
user-agent: sm-ripext/1.3.0
accept-encoding: deflate, gzip
accept: application/json
content-type: applicaton/json
=== Info: STATE: DO => DO_DONE handle 0xde922140; line 1935 (connection #0)
=== Info: STATE: DO_DONE => PERFORM handle 0xde922140; line 2056 (connection #0)
=== Info: http2_send len=306
=== Info: data_source_read_callback: returns 306 bytes stream 3
=== Info: http2_send returns 306 for stream 3
==> Send data
{"pistolround_ct": "weapon_usp_silencer", "primary_ct": "weapon_ak47", "secondary_ct": "weapon_usp_silencer", "smg_ct": "weapon_ump45", "awp_ct": 0, "scout_ct": 0, "pistolround_t": "weapon_glock", "primary_t": "weapon_ak47", "secondary_t": "weapon_glock", "smg_t": "weapon_ump45", "awp_t": 0, "scout_t": 0}
=== Info: h2_process_pending_input: All data in connection buffer processed
=== Info: data_source_read_callback: returns 0 bytes stream 3
=== Info: http2_recv: easy 0xde922140 (stream 3) win 33554278/33554432
=== Info: nread=13
=== Info: on_frame_recv() header 3 stream 3
=== Info: Got frame type 3 for stream 3!
=== Info: on_stream_close(), PROTOCOL_ERROR (err 1), stream 3
=== Info: Removed stream 3 hash!
=== Info: h2_process_pending_input: All data in connection buffer processed
=== Info: http2_recv: easy 0xde922140 (stream 0) win 33554278/4294967295
=== Info: h2_process_pending_input: All data in connection buffer processed
=== Info: HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)
*********ވ*************************** %******************ܠ******************P*********************************************`*************************** ***************************p***************************,***************************H***************************蠓*********************************************|******************************************************<***************************Ǥ*********ވ***************************`***************************@!******************@Ȓ*********X***************************R***************************
=== Info: multi_done
=== Info: stopped the pause stream!
=== Info: Connection #0 to host subdomain.domain.com left intact
=== Info: Expire cleared (transfer 0xde922140)
Stack
im using -nodns in start parameter. Sigsegv:
#0 0xf7624248 in rewind () from /lib/i386-linux-gnu/i686/cmov/libc.so.6
#1 0xf0443e04 in ?? () from /lib/i386-linux-gnu/i686/cmov/libnss_files.so.2
#2 0xf0444e6d in _nss_files_gethostbyname4_r () from /lib/i386-linux-gnu/i686/cmov/libnss_files.so.2
#3 0xf768ce28 in ?? () from /lib/i386-linux-gnu/i686/cmov/libc.so.6
#4 0xf768e19b in getaddrinfo () from /lib/i386-linux-gnu/i686/cmov/libc.so.6
#5 0xed47f527 in Curl_getaddrinfo_ex (nodename=0xeac02c68 "mysite.ru", servname=0xe898231f "443", hints=0xeac02c1c, result=0xeac02c18)
at /home/runner/work/sm-ripext/sm-ripext/extension/curl/lib/curl_addrinfo.c:124
#6 0xed47b106 in getaddrinfo_thread (arg=0xeac02bf8) at /home/runner/work/sm-ripext/sm-ripext/extension/curl/lib/asyn-thread.c:306
#7 0xed47fd7e in curl_thread_create_thunk (arg=0xeac02ca8) at /home/runner/work/sm-ripext/sm-ripext/extension/curl/lib/curl_threads.c:57
#8 0xf756cecb in start_thread () from /lib/i386-linux-gnu/i686/cmov/libpthread.so.0
#9 0xf76a4d0e in clone () from /lib/i386-linux-gnu/i686/cmov/libc.so.6
My English is terrible. Excuse me.
Sometimes I catch sigsegv when I use your extension. Probably the problem is in the libc6, is it not fixed in the extension itself?
Debian 8
Why default connectTimeout
= 10 when libCurl describes this value as 300?
Set to zero to switch to the default built-in connection timeout - 300 seconds.
https://curl.se/libcurl/c/CURLOPT_CONNECTTIMEOUT.html
And also this incident is not reflected in the documentation
https://github.com/ErikMinekus/sm-ripext/blob/master/pawn/scripting/include/ripext/http.inc#L173-L177
Sometimes request should be sent via specific network interface.
https://curl.se/libcurl/c/CURLOPT_INTERFACE.html
Some web hosting providers are using nginx as primary web server. By default it rejects PUT requests. We can solve this problem by editing the configuration, but usually web hosting providers do not allow doing such things.
When sending a post request to localhost: 3000, on which my web server is running on node.js, I get http status code 100, while throwing a request to my domain (to the server), there is already an nginx web server, I also get 100, but when I send a request to https, everything is normal.
Latest versions of REST in Pawn I have been getting this error:
[11] <FAILED> file "rip.ext.so": /lib/i386-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by /home/clientes/OGP_User_Files/whmcs/5138/csgo/addons/sourcemod/extensions/rip.ext.so)
As I understand I would have to update GLIBC to version 2.28 or higher.
Currently where I host my servers runs on Ubuntu 18.04 LTS operating system, any solution for those who use this version of Ubuntu?
Or just updating Ubuntu to 20.04 or using older versions of REST in Pawn anyway?
Failing to build httpclient.cpp at HTTPRequest::BuildHeaders
Line 106 in f50b9e4
/home/peak/alliedmodders/sourcemod/extensions/sm-ripext/httpclient.cpp:48:56: error: no member named 'chars' in 'std::__cxx11::basic_string<char>'
snprintf(header, sizeof(header), "%s: %s", iter->key.chars(), iter->value.c_str());
~~~~~~~~~ ^
1 error generated.```
Please add new JSON handles that can store variables with Boolean, Integer, Float, String types.
I have found that after a file has been uploaded, the file never gets freed and is locked by SRCDS. You cannot delete the file until you restart the server.
I thought HTTPClient might not have been being closed, so I tried deleting the handle after it finished the upload, but that didn't fix it. I'm not sure if this would cause crashes down the line if you upload a bunch of files or not.
I cloned the project, added a function to test some things related to issue #22 and after I compiled the extension and put it on the local dev server I realized that the requests where never done. I thought it's maybe something on my part or my compiler, however downloaded the latest released version and same thing.
I've modified the test script to print some logs, and it seems no error is giving while executing methods like .Get, .Post as the log after them gets printed. Also checked on my local access.log, and there is no request that has been made.
Here is the test file used: https://pastebin.com/Xn3vBG8z
And this is my console:
sm plugins unload_all
[SM] All plugins have been unloaded.
sm plugins refresh
CGameEventManager::AddListener: event 'teamplay_win_panel' unknown.
CGameEventManager::AddListener: event 'teamplay_restart_round' unknown.
CGameEventManager::AddListener: event 'arena_win_panel' unknown.
LOADED PLUGIN RIPEXT
Initialized all requests
[SM] The plugin list has been refreshed and reloaded.
sm
SourceMod Menu:
Usage: sm <command> [arguments]
cmds - List console commands
config - Set core configuration options
credits - Display credits listing
cvars - View convars created by a plugin
exts - Manage extensions
plugins - Manage Plugins
prof - Profiling
version - Display version information
sm version
SourceMod Version Information:
SourceMod Version: 1.10.0.6488
SourcePawn Engine: 1.10.0.6488, jit-x86 (build 1.10.0.6488)
SourcePawn API: v1 = 5, v2 = 12
Compiled on: Apr 30 2020 16:35:23
Built from: https://github.com/alliedmodders/sourcemod/commit/afb40f1d
Build ID: 6488:afb40f1d
http://www.sourcemod.net/
I have not yet tested it on Linux, so I do not know if this is OS related, but that's my suspicion.
After sending a GET request, we receive a response that contains ~25'000 characters. it comes with status code 200 but when fetching the data (response.Data
), we obtain errors like these (it varies):
Exception reported: Invalid JSON in line 1, column 16014: premature end of input
Exception reported: Invalid JSON in line 1, column 16016: invalid escape
The column varies between 16014 and 16016 for this error to occur and the error message between the two above.
Is there a size limit to the JSON object? Can we bypass it?
Any other idea on why it occurs?
The error seems to come from this and this lines in jansson/src/load.c
Plugin don't working on windows, he don't execute callback function!
Hello.
Im trying something and I cannot understand if its my code or the extension that is not working as it should.
Im doing an API request where it should return me some JSON data. The problem is, Im getting some errors:
L 09/16/2021 - 12:41:21: [SM] Exception reported: Invalid JSON in line 1, column 86: ':' expected near end of file
L 09/16/2021 - 12:41:21: [SM] Blaming: csgopanel_gametracker.smx
L 09/16/2021 - 12:41:21: [SM] Call stack trace:
L 09/16/2021 - 12:41:21: [SM] [0] HTTPResponse.Data.get
L 09/16/2021 - 12:41:21: [SM] [1] Line 47, h:\coding\csgopanel_sm\scripting\include\gametracker/httpcallbacks.sp::httpcallback_getgametracker
(but sometimes error message is different) :
L 09/16/2021 - 13:59:14: [SM] Exception reported: Invalid JSON in line 1, column 85: premature end of input near '"points'
L 09/16/2021 - 13:59:14: [SM] Blaming: csgopanel_gametracker.smx
L 09/16/2021 - 13:59:15: [SM] Call stack trace:
L 09/16/2021 - 13:59:15: [SM] [0] HTTPResponse.Data.get
L 09/16/2021 - 13:59:15: [SM] [1] Line 47, h:\coding\csgopanel_sm\scripting\include\gametracker/httpcallbacks.sp::httpcallback_getgametracker
This is my code (where the exception occurs).
public void httpcallback_getgametracker(HTTPResponse response, any userid, const char[] error) {
int client = GetClientOfUserId(userid);
if (!(IsClientConnected(client) && !IsFakeClient(client) && !IsClientSourceTV(client))) {
return;
}
if (response.Status != HTTPStatus_OK && response.Status != HTTPStatus_Created) {
LogError("\nError on request \" get/gametracker \" (%i)\nError: %s", response.Status, error);
return;
}
JSONObject user_data = view_as<JSONObject>(response.Data); // ERROR HERE
// ...
}
I do not understand the error because, testing this endpoint on a software like Postman, it gives me valid JSON
Example:
Setup:
1.3.1 (latest)
css
1.10.0.6510
windows
Thanks in advance.
That's not really important, but I think that's worth to mention. With empty base url the returned handle is valid, but if we use this handle with simple Get, it returns status code 0 with empty error message. That's bit confusing while debugging.
Example plugin
#include <sourcemod>
#include <ripext>
public void OnPluginStart()
{
HTTPClient httpClient = new HTTPClient("");
PrintToServer("Hande valid: %d", (httpClient != null));
httpClient.Get("Test", GetCallback);
}
public void GetCallback(HTTPResponse response, any value, const char[] error)
{
PrintToServer("Status: %d, Error: %s", response.Status, error);
}
Output is
sm plugins load test
Hande valid: 1
Status: 0, Error:
[SM] Unable to load extension "rip.ext": libvstdlib_srv.so: cannot open shared object file: No such file or directory.
I couldn't find libvstdlib_srv.so but I found libvstdlib_s.so.
We really need ability to upload files via POST request . Curl allow doing that, so please, can you implement this?
Support for user auth like "-u" in curl
GET
function should also accept a json object for data just like any other functions does.
This way we can make sure we can't forget to urlencode our parameters before doing the query and also, it keeps the look of the link parameter much cleaner.
Sometimes certain web apps accept raw HTTP POST data only. It would be great if we could send raw data as well.
Oh do i have an interesting bug for you!
void DeleteZone(int client, int zoneID) {
//Mark as deleted
for (int i = 0; i < g_zones.Length; i++) {
Zone zone = view_as<Zone>(g_zones.Get(i));
if (zone.id == zoneID) {
zone.id = -1;
break;
}
}
//Send request
char buffer[128];
Format(buffer, sizeof buffer, "zones/%i/", zoneID);
PrintToServer("Buffer: %s", buffer);
g_timer_client.Delete(buffer, OnDeleteZone);
}
Looks pretty normal right? Lets say we give it zoneID of 10
It should call a: DELETE http://api.domain.com/timer/zones/10
Except it just truncates the entire buffer apparently, on my web server logs it actually just calls: DELETE http://api.domain.com/timer/
Like it just lost the buffer somewhere along the way. It's honestly very bizarre.
Here is the code of the plugin and where it calls the method; https://github.com/mvonsm/timer/blob/development/addons/sourcemod/scripting/timer-map.sp#L788
Also instead of calling DeleteZone() on line 788 and instead put g_timer_client.Get("zones/10, OnDeleteZone);
it works. It seems like it breaks when the call is made in a Void that gets called
I dont understand why it does it, maybe you can compile a version that outputs the URL its going to call for me and we can see if it actually gets lost before CURL calls it or something else.
Edit: so if i do this instead, the calls works. Apparently Format() breaks it?
void DeleteZone(int client, int zoneID) {
//Mark as deleted
for (int i = 0; i < g_zones.Length; i++) {
Zone zone = view_as<Zone>(g_zones.Get(i));
if (zone.id == zoneID) {
zone.id = -1;
break;
}
}
g_timer_client.Delete("zones/10", OnDeleteZone, client);
}
https://crash.limetech.org/eqo3npik5kk2
Game: TF2
Extension version: 1.0.1
When does response from the backend on NodeJS, Rest In Pawn cannot read this integer float values through JSONObject.GetFloat()
.
> JSON.stringify({"float": 1.0})
'{"float":1}'
But JSONObject.GetFloat()
works in the case of
> JSON.stringify({"float": 1.1})
'{"float":1.1}'
I suggest to make reading of integers even as float.
Hi, we've been experiencing some rare unexplainable crashes with ripext on CS:GO Windows. Since the extension is used by a handful of plugins, I'm unable to say what code exactly could be triggering it, but nonetheless here are some crashdumps.
1.2.2 crash: https://crash.limetech.org/xn4a6jzeep7h
1.2.1 crash: https://crash.limetech.org/abtnqbzt7ruc
hi, sorry maybe its like the other issue from matix but cant get it work
on my web server i already use this
$jsonString = file_get_contents("php://input");
$myFile = "player-".date('his', time()).".json";
file_put_contents($myFile,$jsonString);
and plugin using this
HTTPClient httpClient;
httpClient = new HTTPClient(APIURL);
JSONObject player = new JSONObject();
player.SetString("id", authid);
player.SetString("ip", ip_address);
httpClient.Post("api.php", player, OnPlayerLoad, client);
delete player;
but i still got blank on my web server..
but if i use curl from my gameserver, its working fine
curl -d '{"id":"327mm1327821378","ip":"123.123.123.11"}' http://website.com/api.php
i can see json file on my web
get empty file in the callback.
file is actually downloaded, if i create a timer to get the file later would be ok.
i think this callback should be after file write, right?
In oldest RiP version (1.0.7 for example), if web server returned a non-JSON response, RiP just returns null
when we try access to HTTPResponse.Data
.
In newest versions, this behavior is changed: if web server is returned a non-JSON response, RiP throws exception Invalid JSON in line -1, column -1: wrong arguments
. This "breaking change" is undocumented nowhere.
This is expected change?
Lines 27 to 32 in 85aa333
applicaton/json - really? New media content type :D
How to remove this error:
[RIPEXT] HTTP request failed: Cert verify failed: BADCERT_NOT_TRUSTED
Hello, i'm trying out this plugin for the first time and got it to work...but something seems to be wrong.
PHP file:
$body = file_get_contents('php://input');
file_put_contents("post.json", $body, FILE_APPEND | LOCK_EX);
post.json file:
23ad458000^@{"headshot": true, "attackerblind": false, "thrusmoke": false, "assistedflash": false, "assist": 0, "penetrated": 0, "team_attacker": 3, "team_victim": 2, "weapon": "glock", "victim": "Paul", "attacker": "Colin"}
Now...why the hell does it post with this "23ad458000^@" ?
Plugin file:
public void EventPlayerDeath(Event event, const char[] name, bool dontBroadcast)
int victim = GetClientOfUserId(GetEventInt(event, "userid"));
JSONObject Obj = new JSONObject();
Obj.SetString("victim", victim_name);
httpClient = new HTTPClient("https://*********");
httpClient.Post("file.php", Obj, HTTPCallback);
void HTTPCallback(HTTPResponse response, any value) {
if (response.Status != HTTPStatus_Created) {
PrintToServer("Error 01");
return;
}
if (response.Data == null)
{
PrintToServer("Error 02");
return;
}
}
Thanks for any help on this!
See #8, and this came up in IRC today.
I think the best behaviour here would be for RIP to compile with CURL_CA_BUNDLE
undefined on all platforms, then implement its own search path logic and set CURLOPT_CAINFO
appropriately at run time.
The current hardcoded path is incorrect on RHEL-based Linuxes, and doesn't handle the OS store being completely inaccessible because SRCDS is chrooted.
I think a reasonable set of search paths to start with would be:
BuildPath(Path_SM, "configs/cacert.pem")
(So that people can drop in their own.)/etc/ssl/certs/ca-certificates.crt
(The current value, from wherever you built the config.)/etc/ssl/certs/ca-bundle.crt
(The RHEL / CentOS / Fedora default.)RIP should take the first one that exists and is readable.
I created simple debugging script in PHP for check if rest in pawn sending POST data to target HTTP but can't see any POST data in apache logs i see request from my csgo server.
https://pastebin.com/0e2ecBdk
Output JSON file:
[[],[],[]]
Plugin:
https://pastebin.com/5zbUtY8U
Hey!
I'm using this plugin as a way to interact with a webserver. However, I'm trying to download files and realize that I'm hitting a 404 each time I'm trying to download an image. It appears that when it's trying to download, it appends an additional /
to the end of the image, per my server logs: GET /static/img/logos/RVpYn.png/ 404
Would it be possible to remove this trailing slash when attempting to download files? I realize that this hits every request that's made (I think it's right here?) calls BuildURL
, however I don't think downloading files really need this trailing slash as it more often than not 404s.
I've some weird issue with RIPExt (1.2.3) and Caddy (2.3 and 2.4).
GET requests (as example) works fine, but when I've trying to use POST requests I always get 0 as response code with Operation timed out
as error. Full error: HTTP Status Code: 0, Error: Operation timed out after 30015 milliseconds with 0 bytes received
What I tested:
nginx and Caddy as webservers in combination with php7.4 and php8.0 with/out JIT enabled. It works fine with nginx and any php versions, but caddy won't work. To confirm this, I rented another vserver by a different hoster and location. Same results.
My Caddyfile:
domain.tld {
php_fastcgi unix//run/php/php8.0-fpm.sock
root * /path/to/public/folder
rewrite * /index.php?{query}
encode zstd gzip
}
But(!) Caddy seems not the root cause, because POST requests works fine with Insomnia, but not with https://reqbin.com/.
So, reqbin and ripext in combination with caddy as webserver won't work. I'm still not sure where is the issue, but it seems related to curl.
I was trying to set up an HTTPClient using a string from a convar, but I ended up errors like:
HTTP request failed: Could not resolve host: http{weird character}
HTTP request failed: <url> malformed
I assumed the reason might be due to using a stack allocated string, instead of a string literal, so I've made a small test case which show cases both:
#include <sourcemod>
#include <ripext>
#define BASE_URL "http://echo.jsontest.com"
HTTPClient dynamicHttpClient;
HTTPClient literalHttpClient;
public void OnPluginStart()
{
char baseUrl[32];
strcopy(baseUrl, sizeof(baseUrl), BASE_URL);
dynamicHttpClient = new HTTPClient(baseUrl);
literalHttpClient = new HTTPClient(BASE_URL);
dynamicHttpClient.Get("/immediate/get/dynamic/client", GetEcho);
literalHttpClient.Get("/immediate/get/literal/client", GetEcho);
CreateTimer(10.0, Tick);
}
public Action Tick(Handle timer, any data)
{
dynamicHttpClient.Get("/delayed/get/dynamic/client", GetEcho);
literalHttpClient.Get("/delayed/get/literal/client", GetEcho);
}
public void GetEcho(HTTPResponse response, any data)
{
char json[128];
response.Data.ToString(json, sizeof(json), JSON_INDENT(2));
PrintToServer(json);
}
It outputs
{
"dynamic": "client",
"immediate": "get"
}
{
"immediate": "get",
"literal": "client"
}
L 07/27/2017 - 22:10:21: [RIPEXT] HTTP request failed: <url> malformed
{
"delayed": "get",
"literal": "client"
}
The client using the literal as baseurl works fine, but as soon as you change to something dynamically allocated, it doesn't work.
I'm guessing that baseUrl in CreateClient should be copied before being used to create HTTPClient, instead of being passed as-is.
For now, I'm working around it by creating a new HTTPClient for each request and deleting it in the callback, but if there's an error in the request, I can't delete the handle. At least without yet another work around, like a timer.
Is possiable make support for sync http reqeust?
In some cases, it's useful.
For example, I wanna a plugin load all data OnPluginStart.
before, we use SQL sync query to load items data.
but sometimes sync query fail, I had to change to thread query.
https://github.com/Kxnrl/Store
If we can make support for sync http request,
will be helpful for such plugins.
Similar to Issue#12, we are looking to communicate with a local API that runs in HTTPS with a self-signed certificate.
When making the request to the API, we instantly receive an error with status code 0:
Error: Cert verify failed: BADCERT_CN_MISMATCH
Following recommendations from Issue#12, we have tried to add our certificate in the ca-bundle.crt
but it does not fix the issue.
Any idea on how to make it work?
Thanks in advance.
For my API, I need to format the URL suffix in the requests because I read the parameters from a file (Like the number of the server). If I do format the suffix then for some reason, the request will fail. Example:
char url_sufix[512];
Format(url_sufix, sizeof(url_sufix), "/getTasks/%s", servernum);
httpClient.Get(url_sufix, OnJobReceived);
But If I write the exact string to it then it works. Example:
httpClient.Get("/getTasks/9", OnJobReceived);
The "servernum" variable is not empty for sure, because I can print to chat the "url_suffix" content and it works fine.
What can I do about it?
I'd like the HTTPClient to have a way for creating custom SSL certificate validation. Similar to this .NET related issue: StackOverflow link
This code example (all certificates allowed):
HTTPClient.ServerCertificateValidationCallback = delegate { return true; };
I will check the code if I can do it myself...
I'm having an issue finding if a key exists without the plugin erroring out and not proceeding to the rest of the plugin.
Essentially what I'm trying to do is find out if my API responds with an {"error":"Incorrect credentials"} or some other error message. I want to see if that key exists. I tried turning the JSONObject to a string and just doing a StrContains() on it, but that in my mind doesn't seem like the cleanest nor the best way to do it, and it didn't seem to work either.
What I'm trying to essentially accomplish is the following:
public SomeResponseCallback (HTTPResponse response, any data)
{
JSONObject info = view_as<JSONObject>(response.Data);
if (info.Contains("error"))
{
//report error
}
//if no error found continue
}
What would the best way of going about this be? I wasn't able to see a viable function for this, but maybe I'm overlooking the obvious.
It would be nice to have a convar like ripext_version
or something similar.
Why?
By default the User-Agent
is sm-ripext/<VERSION>
, but I want to add a custom User-Agent with the version of this extension as additional information.
My goal is a User-Agent like MetaMod/<Version> SourceMod/<Version> RIPExt/<Version> [...]
which includes some useful informations and for probably better "debugging".
Hi, i cant use this extension on my server. Technical support for hosting where I rent the game server states that the extension visits the directories above the server folder and should not do this. How to be? And what actions are performed in the folder: /etc/ssl/certs/
L 08/22/2017 - 16:34:39: [RIPEXT] HTTP request failed: Error reading ca cert file /etc/ssl/certs/ca-certificates.crt - mbedTLS: (-0x3E00) PK - Read/write of file failed
Can u help?
Server crash when a folder doesn't exist, where the file should be stored.
Working example (from AM thread):
#include <sourcemod>
#include <ripext>
HTTPClient httpClient;
public void OnPluginStart()
{
httpClient = new HTTPClient("https://nghttp2.org/httpbin");
char sImagePath[PLATFORM_MAX_PATH];
BuildPath(Path_SM, sImagePath, sizeof(sImagePath), "data/image.jpg");
httpClient.DownloadFile("image/jpeg", sImagePath, OnImageDownloaded);
}
void OnImageDownloaded(HTTPStatus status, any value)
{
if (status != HTTPStatus_OK) {
// Download failed
return;
}
PrintToServer("Download complete");
}
Not working example (I changed data/image.jpg
to data2/image.jpg
for reproduzing the crash):
#include <sourcemod>
#include <ripext>
HTTPClient httpClient;
public void OnPluginStart()
{
httpClient = new HTTPClient("https://nghttp2.org/httpbin");
char sImagePath[PLATFORM_MAX_PATH];
BuildPath(Path_SM, sImagePath, sizeof(sImagePath), "data2/image.jpg");
httpClient.DownloadFile("image/jpeg", sImagePath, OnImageDownloaded);
}
void OnImageDownloaded(HTTPStatus status, any value)
{
if (status != HTTPStatus_OK) {
// Download failed
return;
}
PrintToServer("Download complete");
}
Please add a feature to allow the ability to set the network interface on the curl command.
Using special characters on SetString fails, or at least GetString cannot find the set key. I posted the issue also to AlliedModders thread.
Here's an example:
`JSONObject obj = new JSONObject();
obj.SetString("test", "ð");
decl String:test[10];
obj.GetString("test", test, sizeof(test));
[SM] Native "JSONObject.GetString" reported: Could not retrieve value for key 'test'`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.