forked from cory/tildefriends
Report which method was not found.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4311 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
8e6f1284e1
commit
dd61a6ecc3
22
src/ssb.c
22
src/ssb.c
@ -763,9 +763,11 @@ void tf_ssb_connection_rpc_send_error(tf_ssb_connection_t* connection, uint8_t f
|
|||||||
tf_free((void*)stack);
|
tf_free((void*)stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tf_ssb_connection_rpc_send_error_method_not_allowed(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number)
|
void tf_ssb_connection_rpc_send_error_method_not_allowed(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, const char* name)
|
||||||
{
|
{
|
||||||
tf_ssb_connection_rpc_send_error(connection, flags, request_number, "method is not in list of allowed methods");
|
char buffer[1024];
|
||||||
|
snprintf(buffer, sizeof(buffer), "method '%s' is not in list of allowed methods", name);
|
||||||
|
tf_ssb_connection_rpc_send_error(connection, flags, request_number, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _utf8_len(uint8_t ch)
|
static int _utf8_len(uint8_t ch)
|
||||||
@ -1449,6 +1451,17 @@ static bool _tf_ssb_name_equals(JSContext* context, JSValue object, const char**
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void _tf_ssb_name_to_string(JSContext* context, JSValue object, char* buffer, size_t size)
|
||||||
|
{
|
||||||
|
JSValue name = JS_GetPropertyStr(context, object, "name");
|
||||||
|
JSValue json_val = JS_JSONStringify(context, name, JS_NULL, JS_NewInt32(context, 2));
|
||||||
|
const char* value = JS_ToCString(context, json_val);
|
||||||
|
snprintf(buffer, size, "%s", value);
|
||||||
|
JS_FreeCString(context, value);
|
||||||
|
JS_FreeValue(context, json_val);
|
||||||
|
JS_FreeValue(context, name);
|
||||||
|
}
|
||||||
|
|
||||||
static void _tf_ssb_connection_rpc_recv(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, const uint8_t* message, size_t size)
|
static void _tf_ssb_connection_rpc_recv(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, const uint8_t* message, size_t size)
|
||||||
{
|
{
|
||||||
connection->ssb->rpc_in++;
|
connection->ssb->rpc_in++;
|
||||||
@ -1507,7 +1520,9 @@ static void _tf_ssb_connection_rpc_recv(tf_ssb_connection_t* connection, uint8_t
|
|||||||
}
|
}
|
||||||
else if (!_tf_ssb_name_equals(context, val, (const char*[]) { "Error", NULL }))
|
else if (!_tf_ssb_name_equals(context, val, (const char*[]) { "Error", NULL }))
|
||||||
{
|
{
|
||||||
tf_ssb_connection_rpc_send_error_method_not_allowed(connection, flags, -request_number);
|
char buffer[256];
|
||||||
|
_tf_ssb_name_to_string(context, val, buffer, sizeof(buffer));
|
||||||
|
tf_ssb_connection_rpc_send_error_method_not_allowed(connection, flags, -request_number, buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2075,6 +2090,7 @@ tf_ssb_t* tf_ssb_create(uv_loop_t* loop, JSContext* context, const char* db_path
|
|||||||
{
|
{
|
||||||
tf_ssb_t* ssb = tf_malloc(sizeof(tf_ssb_t));
|
tf_ssb_t* ssb = tf_malloc(sizeof(tf_ssb_t));
|
||||||
memset(ssb, 0, sizeof(*ssb));
|
memset(ssb, 0, sizeof(*ssb));
|
||||||
|
ssb->verbose = true;
|
||||||
if (context)
|
if (context)
|
||||||
{
|
{
|
||||||
ssb->context = context;
|
ssb->context = context;
|
||||||
|
@ -154,7 +154,7 @@ void tf_ssb_remove_rpc_callback(tf_ssb_t* ssb, const char** name, tf_ssb_rpc_cal
|
|||||||
void tf_ssb_connection_rpc_send(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, const uint8_t* message, size_t size, tf_ssb_rpc_callback_t* callback, tf_ssb_callback_cleanup_t* cleanup, void* user_data);
|
void tf_ssb_connection_rpc_send(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, const uint8_t* message, size_t size, tf_ssb_rpc_callback_t* callback, tf_ssb_callback_cleanup_t* cleanup, void* user_data);
|
||||||
void tf_ssb_connection_rpc_send_json(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, JSValue message, tf_ssb_rpc_callback_t* callback, tf_ssb_callback_cleanup_t* cleanup, void* user_data);
|
void tf_ssb_connection_rpc_send_json(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, JSValue message, tf_ssb_rpc_callback_t* callback, tf_ssb_callback_cleanup_t* cleanup, void* user_data);
|
||||||
void tf_ssb_connection_rpc_send_error(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, const char* error);
|
void tf_ssb_connection_rpc_send_error(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, const char* error);
|
||||||
void tf_ssb_connection_rpc_send_error_method_not_allowed(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number);
|
void tf_ssb_connection_rpc_send_error_method_not_allowed(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, const char* name);
|
||||||
void tf_ssb_connection_add_request(tf_ssb_connection_t* connection, int32_t request_number, tf_ssb_rpc_callback_t* callback, tf_ssb_callback_cleanup_t* cleanup, void* user_data, tf_ssb_connection_t* dependent_connection);
|
void tf_ssb_connection_add_request(tf_ssb_connection_t* connection, int32_t request_number, tf_ssb_rpc_callback_t* callback, tf_ssb_callback_cleanup_t* cleanup, void* user_data, tf_ssb_connection_t* dependent_connection);
|
||||||
void tf_ssb_connection_remove_request(tf_ssb_connection_t* connection, int32_t request_number);
|
void tf_ssb_connection_remove_request(tf_ssb_connection_t* connection, int32_t request_number);
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ static void _tf_ssb_rpc_tunnel_connect(tf_ssb_connection_t* connection, uint8_t
|
|||||||
tf_ssb_t* ssb = tf_ssb_connection_get_ssb(connection);
|
tf_ssb_t* ssb = tf_ssb_connection_get_ssb(connection);
|
||||||
if (!_get_global_setting_bool(ssb, "room", true))
|
if (!_get_global_setting_bool(ssb, "room", true))
|
||||||
{
|
{
|
||||||
tf_ssb_connection_rpc_send_error_method_not_allowed(connection, flags, -request_number);
|
tf_ssb_connection_rpc_send_error_method_not_allowed(connection, flags, -request_number, "tunnel.connect");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,7 +366,7 @@ static void _tf_ssb_rpc_room_attendants(tf_ssb_connection_t* connection, uint8_t
|
|||||||
tf_ssb_t* ssb = tf_ssb_connection_get_ssb(connection);
|
tf_ssb_t* ssb = tf_ssb_connection_get_ssb(connection);
|
||||||
if (!_get_global_setting_bool(ssb, "room", true))
|
if (!_get_global_setting_bool(ssb, "room", true))
|
||||||
{
|
{
|
||||||
tf_ssb_connection_rpc_send_error_method_not_allowed(connection, flags, -request_number);
|
tf_ssb_connection_rpc_send_error_method_not_allowed(connection, flags, -request_number, "room.attendants");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user