Filter out pings that do not specify if they're leaf. Do not crawl leafs
This commit is contained in:
@@ -106,6 +106,12 @@ public class HostCache {
|
|||||||
switch(payload.type) {
|
switch(payload.type) {
|
||||||
case "Ping" :
|
case "Ping" :
|
||||||
println "Ping"
|
println "Ping"
|
||||||
|
if (payload.leaf == null) {
|
||||||
|
println "WARN: ping didn't specify if leaf"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
payload.leaf = Boolean.parseBoolean(payload.leaf.toString())
|
||||||
|
if (!payload.leaf)
|
||||||
hostPool.addUnverified(new Host(destination: sender))
|
hostPool.addUnverified(new Host(destination: sender))
|
||||||
respond(session, sender, payload)
|
respond(session, sender, payload)
|
||||||
break
|
break
|
||||||
@@ -124,12 +130,8 @@ public class HostCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def respond(session, destination, ping) {
|
def respond(session, destination, ping) {
|
||||||
if (ping.leaf == null) {
|
|
||||||
println "WARN: ping didn't specify if it were a leaf"
|
def pongs = hostPool.getVerified(toReturn, ping.leaf)
|
||||||
return
|
|
||||||
}
|
|
||||||
boolean leaf = Boolean.parseBoolean(ping.leaf.toString())
|
|
||||||
def pongs = hostPool.getVerified(toReturn, leaf)
|
|
||||||
pongs = pongs.stream().map({ x -> x.destination.toBase64() }).collect(Collectors.toList())
|
pongs = pongs.stream().map({ x -> x.destination.toBase64() }).collect(Collectors.toList())
|
||||||
|
|
||||||
def pong = [type:"Pong", version: 1, pongs: pongs]
|
def pong = [type:"Pong", version: 1, pongs: pongs]
|
||||||
|
|||||||
Reference in New Issue
Block a user