GithubHelp home page GithubHelp logo

erikminekus / sm-ripext Goto Github PK

View Code? Open in Web Editor NEW
135.0 20.0 37.0 24.49 MB

SourceMod REST in Pawn Extension

Home Page: https://forums.alliedmods.net/showthread.php?t=298024

License: GNU General Public License v3.0

Python 1.24% C++ 22.38% SourcePawn 0.10% Pawn 0.01% CMake 0.75% C 49.51% Makefile 12.53% D 0.33% DTrace 0.01% Perl 2.22% Roff 5.83% M4 1.54% Shell 2.49% VBScript 0.05% DIGITAL Command Language 0.76% Batchfile 0.21% Raku 0.03% JavaScript 0.01% SmPL 0.01% Dockerfile 0.02%
cpp sourcemod sourcepawn sourcemod-extension

sm-ripext's People

Contributors

asherkin avatar crazyhackgut avatar erikminekus avatar gunslinger23 avatar jimppan avatar kxnrl avatar peakks avatar wend4r avatar zakharya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sm-ripext's Issues

Post request return http status 100

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.

Upload files via POST

We really need ability to upload files via POST request . Curl allow doing that, so please, can you implement this?

Failing request with formatted text

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?

About sync method

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.

Memory leak in FromFile

sm-ripext/json_natives.cpp

Lines 863 to 875 in 59dfe43

json_t *object = json_load_file(realpath, 0, &error);
if (object == NULL)
{
pContext->ThrowNativeError("Invalid JSON in line %d, column %d: %s", error.line, error.column, error.text);
return BAD_HANDLE;
}
Handle_t hndlObject = handlesys->CreateHandle(htJSONObject, object, pContext->GetIdentity(), myself->GetIdentity(), NULL);
if (hndlObject == BAD_HANDLE)
{
pContext->ThrowNativeError("Could not create object handle.");
return BAD_HANDLE;
}

If handle can't be created, object should be destroyed.

NodeJS: float certain values as an integer

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.

Valid handle with empty baseURL

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:

PUT Error

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)
*********&#1928;***************************    %******************ܠ******************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) 

Extension not making requests on windows?

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.

'Operation timed out' with POST requests and Caddy (Webserver)

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.

HTTPResponse.Data throws exception "Invalid JSON"

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:

  • ripext version: 1.3.1 (latest)
  • game: css
  • sourcemod version: 1.10.0.6510
  • server os: windows

Thanks in advance.

Send input data with GET request

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.

Support POST requests for UploadFile method

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.

Downloading some files hangs at the very beginning

Issue description

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.

Steps to reproduce the issue

  1. Try to download any of given below files via HTTPClient.DownloadFile in <sourcemod>/data location
  2. Observe returned in callback function error

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

What's the expected result?

Fully downloaded file located in <sourcemod>/data directory

What's the actual result?

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

Additional details

  • All tests were made with plugin written in SM1.10 using ripext v1.2.3

UploadFile not freeing file after upload completed.

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.

BADCERT_NOT_TRUSTED

How to remove this error:
[RIPEXT] HTTP request failed: Cert verify failed: BADCERT_NOT_TRUSTED

JSONObject.SetString and special characters not working?

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'`

DELETE getting truncated?

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);
}

[Feature request] Custom SSL certificate validation

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...

Problems with trailing slashes

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.

non-JSON response causes the exception

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?

Extend JSON

Please add new JSON handles that can store variables with Boolean, Integer, Float, String types.

Response.Data seems to be limited to ~16000 characters

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

Potential memory leak

sm-ripext/httpthread.cpp

Lines 42 to 46 in 55e1f01

response->body = (char *)realloc(response->body, response->size + total + 1);
if (response->body == NULL)
{
return 0;
}

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.

Version GLIBC_2.28 not found

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?

Fails to build, no member 'chars'

Failing to build httpclient.cpp at HTTPRequest::BuildHeaders

snprintf(header, sizeof(header), "%s: %s", iter->key.chars(), iter->value.c_str());
with error:

/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.```

HTTP request failed using non-literal strings

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.

Finding if a key exists within a response.

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.

No libvstdlib_srv.so file.

[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.

Segmentation fault in libc (using sm rip ext)

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

Crash when folder doesn't exist

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");
}

Handle CA certificate store better

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:

  1. BuildPath(Path_SM, "configs/cacert.pem") (So that people can drop in their own.)
  2. /etc/ssl/certs/ca-certificates.crt (The current value, from wherever you built the config.)
  3. /etc/ssl/certs/ca-bundle.crt (The RHEL / CentOS / Fedora default.)

RIP should take the first one that exists and is readable.

RIPExt version convar

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".

POST result empty json

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

Error "HTTP request failed"

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?

Post data

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!

Custom SSL Certificate validation

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.