summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesper Jensen <jesper@slashwin.dk>2021-10-05 23:07:06 +0200
committerJesper Jensen <jesper@slashwin.dk>2021-10-05 23:07:06 +0200
commite0074d8b74f9e62df913a3817fc4cecf7cac2c69 (patch)
tree46696da2ad28b316e75543bc79d63cc3e8ad3d4c /src
parent6e6829ad209550fbac0e363f9421c1fba78915b5 (diff)
Respond correctly no unknown query method
Diffstat (limited to 'src')
-rw-r--r--src/proto.c15
-rw-r--r--src/query.c1
2 files changed, 14 insertions, 2 deletions
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;
}