From e0074d8b74f9e62df913a3817fc4cecf7cac2c69 Mon Sep 17 00:00:00 2001 From: Jesper Jensen Date: Tue, 5 Oct 2021 23:07:06 +0200 Subject: Respond correctly no unknown query method --- src/proto.c | 15 +++++++++++++-- src/query.c | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/proto.c b/src/proto.c index 8a6f0e8..cde232b 100644 --- a/src/proto.c +++ b/src/proto.c @@ -485,8 +485,19 @@ int handle_packet(struct dht* dht, time_t now, enum commandType type, char* tran rc = handle_request(&dht->self, query, packet, packet_len, &cursor, end-cursor-1); if(rc == QUERY_EUNK) { - dbg("DISCARD: Unknown query method"); - return 0; + // The y key should have value e + *(cursor-4) = 'e'; + // The r key is called e for errors + *(cursor-1) = 'e'; + + // Now create the payload + rc = snprintf(cursor, end-cursor, "li204e14:Unknown Methode"); + if(rc < 0) + fatal("No space for response"); + cursor += rc; + assert(cursor < end); + + // Use the normal finalize flow } else if(rc != 0) fatal("Error handling request"); rc = snprintf(cursor, end-cursor, "e"); diff --git a/src/query.c b/src/query.c index 5645271..806c691 100644 --- a/src/query.c +++ b/src/query.c @@ -75,6 +75,7 @@ int handle_request(struct nodeid* self, const char* method, const char* packet, if(rc < 0) return QUERY_EBADQ; *response += rc; + }else if(strcmp(method, "get_peers") == 0) { } else { return QUERY_EUNK; } -- cgit v1.2.3