Skip to content
Snippets Groups Projects
Commit 6f4fc6ad authored by Cédric Moreau's avatar Cédric Moreau
Browse files

[fix] Have a maximum endpoint length

parent 199d94b8
No related branches found
No related tags found
No related merge requests found
...@@ -49,7 +49,8 @@ export class PeerParser extends GenericParser { ...@@ -49,7 +49,8 @@ export class PeerParser extends GenericParser {
'BAD_PORT': 155, 'BAD_PORT': 155,
'BAD_FINGERPRINT': 156, 'BAD_FINGERPRINT': 156,
'BAD_BLOCK': 157, 'BAD_BLOCK': 157,
'NO_IP_GIVEN': 158 'NO_IP_GIVEN': 158,
'TOO_LONG_ENDPOINT': 159
}; };
if(!err){ if(!err){
// Version // Version
...@@ -66,6 +67,14 @@ export class PeerParser extends GenericParser { ...@@ -66,6 +67,14 @@ export class PeerParser extends GenericParser {
if(!obj.block) if(!obj.block)
err = {code: codes.BAD_BLOCK, message: "Incorrect Block field"}; err = {code: codes.BAD_BLOCK, message: "Incorrect Block field"};
} }
if(!err){
// Endpoint length
for (const ep of (obj.endpoints || [])) {
if (!err && ep.length > 255) {
err = {code: codes.TOO_LONG_ENDPOINT, message: "An endpoint has maximum 255 characters length."}
}
}
}
// Basic Merkled API requirements // Basic Merkled API requirements
let bma = obj.getBMA(); let bma = obj.getBMA();
if(!err){ if(!err){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment