diff --git a/core/src/main/groovy/com/muwire/core/connection/Connection.groovy b/core/src/main/groovy/com/muwire/core/connection/Connection.groovy index 39a1cae9..957205bb 100644 --- a/core/src/main/groovy/com/muwire/core/connection/Connection.groovy +++ b/core/src/main/groovy/com/muwire/core/connection/Connection.groovy @@ -132,6 +132,7 @@ abstract class Connection implements Closeable { def ping = [:] ping.type = "Ping" ping.version = 1 + ping.uuid = UUID.randomUUID().toString() messages.put(ping) lastPingSentTime = System.currentTimeMillis() } @@ -160,11 +161,13 @@ abstract class Connection implements Closeable { messages.put(query) } - protected void handlePing() { + protected void handlePing(def ping) { log.fine("$name received ping") def pong = [:] pong.type = "Pong" pong.version = 1 + if (ping.uuid != null) + pong.uuid = ping.uuid pong.pongs = hostCache.getGoodHosts(10).collect { d -> d.toBase64() } messages.put(pong) } diff --git a/core/src/main/groovy/com/muwire/core/connection/PeerConnection.groovy b/core/src/main/groovy/com/muwire/core/connection/PeerConnection.groovy index be8e55ec..a133a4fd 100644 --- a/core/src/main/groovy/com/muwire/core/connection/PeerConnection.groovy +++ b/core/src/main/groovy/com/muwire/core/connection/PeerConnection.groovy @@ -53,7 +53,7 @@ class PeerConnection extends Connection { if (json.type == null) throw new Exception("missing json type") switch(json.type) { - case "Ping" : handlePing(); break; + case "Ping" : handlePing(json); break; case "Pong" : handlePong(json); break; case "Search": handleSearch(json); break default :