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:
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);
|
||||
}
|
||||
|
||||
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)
|
||||
@ -1449,6 +1451,17 @@ static bool _tf_ssb_name_equals(JSContext* context, JSValue object, const char**
|
||||
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)
|
||||
{
|
||||
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 }))
|
||||
{
|
||||
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));
|
||||
memset(ssb, 0, sizeof(*ssb));
|
||||
ssb->verbose = true;
|
||||
if (context)
|
||||
{
|
||||
ssb->context = context;
|
||||
|
Reference in New Issue
Block a user