1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-09 19:05:41 +02:00

relay: remove request from some function arguments (issue #2066)

This commit is contained in:
Sébastien Helleu
2024-01-31 08:57:20 +01:00
parent 83567fd871
commit 89aeb03a13
7 changed files with 91 additions and 122 deletions
File diff suppressed because it is too large Load Diff
+3 -14
View File
@@ -22,19 +22,9 @@
#define RELAY_API_PROTOCOL_CALLBACK(__command) \
int \
relay_api_protocol_cb_##__command ( \
struct t_relay_client *client, \
struct t_relay_http_request *request)
relay_api_protocol_cb_##__command (struct t_relay_client *client)
struct t_relay_api_protocol_ctxt
{
struct t_relay_client *client;
struct t_relay_http_request *request;
char *resource;
};
typedef int (t_relay_api_cmd_func)(struct t_relay_client *client,
struct t_relay_http_request *request);
typedef int (t_relay_api_cmd_func)(struct t_relay_client *client);
struct t_relay_api_protocol_cb
{
@@ -59,8 +49,7 @@ extern int relay_api_protocol_signal_upgrade_cb (const void *pointer,
const char *signal,
const char *type_data,
void *signal_data);
extern void relay_api_protocol_recv_http (struct t_relay_client *client,
struct t_relay_http_request *request);
extern void relay_api_protocol_recv_http (struct t_relay_client *client);
extern void relay_api_protocol_recv_json (struct t_relay_client *client,
const char *json);
+2 -3
View File
@@ -133,10 +133,9 @@ relay_api_unhook_signals (struct t_relay_client *client)
*/
void
relay_api_recv_http (struct t_relay_client *client,
struct t_relay_http_request *request)
relay_api_recv_http (struct t_relay_client *client)
{
relay_api_protocol_recv_http (client, request);
relay_api_protocol_recv_http (client);
}
/*
+1 -3
View File
@@ -21,7 +21,6 @@
#define WEECHAT_PLUGIN_RELAY_API_H
struct t_relay_client;
struct t_relay_http_request;
enum t_relay_status;
#define RELAY_API_VERSION_MAJOR 0
@@ -65,8 +64,7 @@ struct t_relay_api_data
extern enum t_relay_api_colors relay_api_search_colors (const char *colors);
extern void relay_api_hook_signals (struct t_relay_client *client);
extern void relay_api_unhook_signals (struct t_relay_client *client);
extern void relay_api_recv_http (struct t_relay_client *client,
struct t_relay_http_request *request);
extern void relay_api_recv_http (struct t_relay_client *client);
extern void relay_api_recv_json (struct t_relay_client *client,
const char *json);
extern void relay_api_close_connection (struct t_relay_client *client);
+7 -9
View File
@@ -530,8 +530,7 @@ relay_http_add_to_body (struct t_relay_http_request *request,
*/
int
relay_http_get_auth_status (struct t_relay_client *client,
struct t_relay_http_request *request)
relay_http_get_auth_status (struct t_relay_client *client)
{
const char *auth, *client_totp, *pos;
char *relay_password, *totp_secret, *info_totp_args, *info_totp;
@@ -552,7 +551,7 @@ relay_http_get_auth_status (struct t_relay_client *client,
goto end;
}
auth = weechat_hashtable_get (request->headers, "authorization");
auth = weechat_hashtable_get (client->http_req->headers, "authorization");
if (!auth || (weechat_strncasecmp (auth, "basic ", 6) != 0))
{
rc = -1;
@@ -625,7 +624,7 @@ relay_http_get_auth_status (struct t_relay_client *client,
NULL, NULL, NULL);
if (totp_secret && totp_secret[0])
{
client_totp = weechat_hashtable_get (request->headers, "x-weechat-totp");
client_totp = weechat_hashtable_get (client->http_req->headers, "x-weechat-totp");
if (!client_totp || !client_totp[0])
{
rc = -3;
@@ -674,12 +673,11 @@ end:
*/
int
relay_http_check_auth (struct t_relay_client *client,
struct t_relay_http_request *request)
relay_http_check_auth (struct t_relay_client *client)
{
int rc;
rc = relay_http_get_auth_status (client, request);
rc = relay_http_get_auth_status (client);
switch (rc)
{
case 0: /* authentication OK */
@@ -778,7 +776,7 @@ relay_http_process_websocket (struct t_relay_client *client)
/* handshake from client is valid, auth is mandatory for "api" protocol */
if (client->protocol == RELAY_PROTOCOL_API)
{
if (relay_http_check_auth (client, client->http_req))
if (relay_http_check_auth (client))
{
relay_client_set_status (client, RELAY_STATUS_CONNECTED);
}
@@ -852,7 +850,7 @@ relay_http_process_request (struct t_relay_client *client)
{
#ifdef HAVE_CJSON
if (client->protocol == RELAY_PROTOCOL_API)
relay_api_recv_http (client, client->http_req);
relay_api_recv_http (client);
#endif /* HAVE_CJSON */
}
}
+1 -2
View File
@@ -75,8 +75,7 @@ extern void relay_http_request_reinit (struct t_relay_http_request *request);
extern struct t_relay_http_request *relay_http_request_alloc ();
extern int relay_http_parse_method_path (struct t_relay_http_request *request,
const char *method_path);
extern int relay_http_check_auth (struct t_relay_client *client,
struct t_relay_http_request *request);
extern int relay_http_check_auth (struct t_relay_client *client);
extern void relay_http_recv (struct t_relay_client *client, const char *data);
extern int relay_http_send (struct t_relay_client *client,
int return_code, const char *message,
File diff suppressed because it is too large Load Diff