Compare commits

..

4 Commits

Author SHA1 Message Date
Zlatin Balevsky
a5d442d320 Release 0.0.13 for keyword search fix 2019-06-07 06:37:23 +01:00
Zlatin Balevsky
3f9ee887d6 prevent NPE in toString 2019-06-07 06:31:29 +01:00
Zlatin Balevsky
4a9e6d3b6b prevent npe in keyword searches 2019-06-07 06:14:40 +01:00
Zlatin Balevsky
80f2cc5f99 logging and toString() 2019-06-07 06:07:02 +01:00
8 changed files with 29 additions and 12 deletions

View File

@@ -34,7 +34,7 @@ class Cli {
Core core
try {
core = new Core(props, home, "0.0.12")
core = new Core(props, home, "0.0.13")
} catch (Exception bad) {
bad.printStackTrace(System.out)
println "Failed to initialize core, exiting"

View File

@@ -248,7 +248,7 @@ public class Core {
}
}
Core core = new Core(props, home, "0.0.12")
Core core = new Core(props, home, "0.0.13")
core.startServices()
// ... at the end, sleep or execute script

View File

@@ -24,7 +24,7 @@ class EventBus {
}
private void publishInternal(Event e) {
log.fine "publishing event $e of type ${e.getClass().getSimpleName()}"
log.fine "publishing event $e of type ${e.getClass().getSimpleName()} event $e"
def currentHandlers
final def clazz = e.getClass()
synchronized(this) {

View File

@@ -157,8 +157,11 @@ abstract class Connection implements Closeable {
protected void handleSearch(def search) {
UUID uuid = UUID.fromString(search.uuid)
if (search.infohash != null)
byte [] infohash = null
if (search.infohash != null) {
search.keywords = null
infohash = Base64.decode(search.infohash)
}
Destination replyTo = new Destination(search.replyTo)
TrustLevel trustLevel = trustService.getLevel(replyTo)
@@ -182,7 +185,7 @@ abstract class Connection implements Closeable {
SearchEvent searchEvent = new SearchEvent(searchTerms : search.keywords,
searchHash : Base64.decode(search.infohash),
searchHash : infohash,
uuid : uuid)
QueryEvent event = new QueryEvent ( searchEvent : searchEvent,
replyTo : replyTo,

View File

@@ -13,4 +13,8 @@ class QueryEvent extends Event {
Persona originator
Destination receivedOn
String toString() {
"searchEvent: $searchEvent firstHop:$firstHop, replyTo:${replyTo.toBase32()}" +
"originator: ${originator.getHumanReadableName()} receivedOn: ${receivedOn.toBase32()}"
}
}

View File

@@ -1,10 +1,18 @@
package com.muwire.core.search
import com.muwire.core.Event
import com.muwire.core.InfoHash
class SearchEvent extends Event {
List<String> searchTerms
byte [] searchHash
UUID uuid
String toString() {
def infoHash = null
if (searchHash != null)
infoHash = new InfoHash(searchHash)
"searchTerms: $searchTerms searchHash:$infoHash, uuid:$uuid"
}
}

View File

@@ -77,13 +77,15 @@ public class InfoHash {
public String toString() {
String rv = "InfoHash[root:"+Base32.encode(root) + " hashList:";
List<String> b32HashList = new ArrayList<>(hashList.length / SIZE);
byte [] tmp = new byte[SIZE];
for (int i = 0; i < hashList.length / SIZE; i++) {
System.arraycopy(hashList, SIZE * i, tmp, 0, SIZE);
b32HashList.add(Base32.encode(tmp));
List<String> b64HashList = new ArrayList<>();
if (hashList != null) {
byte [] tmp = new byte[SIZE];
for (int i = 0; i < hashList.length / SIZE; i++) {
System.arraycopy(hashList, SIZE * i, tmp, 0, SIZE);
b64HashList.add(Base32.encode(tmp));
}
}
rv += b32HashList.toString();
rv += b64HashList.toString();
rv += "]";
return rv;
}

View File

@@ -1,5 +1,5 @@
group = com.muwire
version = 0.0.12
version = 0.0.13
groovyVersion = 2.4.15
slf4jVersion = 1.7.25
spockVersion = 1.1-groovy-2.4