From 6a01d97a8dcb88a0d0ef66e3485996a105b40539 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Wed, 12 Jun 2019 20:55:13 +0100 Subject: [PATCH] enable oob infohash in queries; send V2 search results --- .../com/muwire/core/files/FileManager.groovy | 4 +- .../muwire/core/search/ResultsEvent.groovy | 1 + .../muwire/core/search/ResultsParser.groovy | 44 +++++++++++++++++- .../muwire/core/search/ResultsSender.groovy | 25 +++++----- .../muwire/core/search/SearchManager.groovy | 2 +- .../muwire/core/upload/UploadManager.groovy | 46 +++++++++++++++++++ .../com/muwire/gui/MainFrameController.groovy | 5 +- 7 files changed, 109 insertions(+), 18 deletions(-) diff --git a/core/src/main/groovy/com/muwire/core/files/FileManager.groovy b/core/src/main/groovy/com/muwire/core/files/FileManager.groovy index 887e511e..424a53f5 100644 --- a/core/src/main/groovy/com/muwire/core/files/FileManager.groovy +++ b/core/src/main/groovy/com/muwire/core/files/FileManager.groovy @@ -108,7 +108,7 @@ class FileManager { found = rootToFiles.get new InfoHash(e.searchHash) found = filter(found, e.oobInfohash) if (found != null && !found.isEmpty()) - re = new ResultsEvent(results: found.asList(), uuid: e.uuid) + re = new ResultsEvent(results: found.asList(), uuid: e.uuid, searchEvent: e) } else { def names = index.search e.searchTerms Set files = new HashSet<>() @@ -117,7 +117,7 @@ class FileManager { files.each { sharedFiles.add fileToSharedFile[it] } files = filter(sharedFiles, e.oobInfohash) if (!sharedFiles.isEmpty()) - re = new ResultsEvent(results: sharedFiles.asList(), uuid: e.uuid) + re = new ResultsEvent(results: sharedFiles.asList(), uuid: e.uuid, searchEvent: e) } diff --git a/core/src/main/groovy/com/muwire/core/search/ResultsEvent.groovy b/core/src/main/groovy/com/muwire/core/search/ResultsEvent.groovy index 059310eb..2b0542ce 100644 --- a/core/src/main/groovy/com/muwire/core/search/ResultsEvent.groovy +++ b/core/src/main/groovy/com/muwire/core/search/ResultsEvent.groovy @@ -5,6 +5,7 @@ import com.muwire.core.SharedFile class ResultsEvent extends Event { + SearchEvent searchEvent SharedFile[] results UUID uuid } diff --git a/core/src/main/groovy/com/muwire/core/search/ResultsParser.groovy b/core/src/main/groovy/com/muwire/core/search/ResultsParser.groovy index 38e0cef4..91c4a986 100644 --- a/core/src/main/groovy/com/muwire/core/search/ResultsParser.groovy +++ b/core/src/main/groovy/com/muwire/core/search/ResultsParser.groovy @@ -12,8 +12,19 @@ class ResultsParser { public static UIResultEvent parse(Persona p, UUID uuid, def json) throws InvalidSearchResultException { if (json.type != "Result") throw new InvalidSearchResultException("not a result json") - if (json.version != 1) - throw new InvalidSearchResultException("unknown version $json.version") + switch(json.version) { + case 1: + return parseV1(p, uuid, json) + case 2: + return parseV2(p, uuid, json) + default: + throw new InvalidSearchResultException("unknown version $json.version") + + } + + } + + private static parseV1(Persona p, UUID uuid, def json) { if (json.name == null) throw new InvalidSearchResultException("name missing") if (json.size == null) @@ -52,4 +63,33 @@ class ResultsParser { throw new InvalidSearchResultException("parsing search result failed",e) } } + + privaHTTP/1.1 200 OK Cache-Control: max-age=0, private, must-revalidate, no-transform Set-Cookie: i_like_gitea=715c36bdad1d5f26; Path=/; HttpOnly; Secure; SameSite=Lax Set-Cookie: _csrf=dpD1bVVMfTX924CS2rEFxi0JDgU6MTc1MzIzNzk5MzgxNTYzMDIyNg; Path=/; Max-Age=86400; HttpOnly; Secure; SameSite=Lax X-Frame-Options: SAMEORIGIN Date: Wed, 23 Jul 2025 02:33:13 GMT Content-Type: text/plain; charset=utf-8 Connection: close Transfer-Encoding: chunked X-Cache-Status: HIT X-Cache-Age: 0 31fa From 6a01d97a8dcb88a0d0ef66e3485996a105b40539 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Wed, 12 Jun 2019 20:55:13 +0100 Subject: [PATCH] enable oob infohash in queries; send V2 search results --- .../com/muwire/core/files/FileManager.groovy | 4 +- .../muwire/core/search/ResultsEvent.groovy | 1 + .../muwire/core/search/ResultsParser.groovy | 44 +++++++++++++++++- .../muwire/core/search/ResultsSender.groovy | 25 +++++----- .../muwire/core/search/SearchManager.groovy | 2 +- .../muwire/core/upload/UploadManager.groovy | 46 +++++++++++++++++++ .../com/muwire/gui/MainFrameController.groovy | 5 +- 7 files changed, 109 insertions(+), 18 deletions(-) diff --git a/core/src/main/groovy/com/muwire/core/files/FileManager.groovy b/core/src/main/groovy/com/muwire/core/files/FileManager.groovy index 887e511e..424a53f5 100644 --- a/core/src/main/groovy/com/muwire/core/files/FileManager.groovy +++ b/core/src/main/groovy/com/muwire/core/files/FileManager.groovy @@ -108,7 +108,7 @@ class FileManager { found = rootToFiles.get new InfoHash(e.searchHash) found = filter(found, e.oobInfohash) if (found != null && !found.isEmpty()) - re = new ResultsEvent(results: found.asList(), uuid: e.uuid) + re = new ResultsEvent(results: found.asList(), uuid: e.uuid, searchEvent: e) } else { def names = index.search e.searchTerms Set files = new HashSet<>() @@ -117,7 +117,7 @@ class FileManager { files.each { sharedFiles.add fileToSharedFile[it] } files = filter(sharedFiles, e.oobInfohash) if (!sharedFiles.isEmpty()) - re = new ResultsEvent(results: sharedFiles.asList(), uuid: e.uuid) + re = new ResultsEvent(results: sharedFiles.asList(), uuid: e.uuid, searchEvent: e) } diff --git a/core/src/main/groovy/com/muwire/core/search/ResultsEvent.groovy b/core/src/main/groovy/com/muwire/core/search/ResultsEvent.groovy index 059310eb..2b0542ce 100644 --- a/core/src/main/groovy/com/muwire/core/search/ResultsEvent.groovy +++ b/core/src/main/groovy/com/muwire/core/search/ResultsEvent.groovy @@ -5,6 +5,7 @@ import com.muwire.core.SharedFile class ResultsEvent extends Event { + SearchEvent searchEvent SharedFile[] results UUID uuid } diff --git a/core/src/main/groovy/com/muwire/core/search/ResultsParser.groovy b/core/src/main/groovy/com/muwire/core/search/ResultsParser.groovy index 38e0cef4..91c4a986 100644 --- a/core/src/main/groovy/com/muwire/core/search/ResultsParser.groovy +++ b/core/src/main/groovy/com/muwire/core/search/ResultsParser.groovy @@ -12,8 +12,19 @@ class ResultsParser { public static UIResultEvent parse(Persona p, UUID uuid, def json) throws InvalidSearchResultException { if (json.type != "Result") throw new InvalidSearchResultException("not a result json") - if (json.version != 1) - throw new InvalidSearchResultException("unknown version $json.version") + switch(json.version) { + case 1: + return parseV1(p, uuid, json) + case 2: + return parseV2(p, uuid, json) + default: + throw new InvalidSearchResultException("unknown version $json.version") + + } + + } + + private static parseV1(Persona p, UUID uuid, def json) { if (json.name == null) throw new InvalidSearchResultException("name missing") if (json.size == null) @@ -52,4 +63,33 @@ class ResultsParser { throw new InvalidSearchResultException("parsing search result failed",e) } } + + priva 0