From d33100307f6b0ea534a253dc4ae0bd9b57ab477d Mon Sep 17 00:00:00 2001 From: Sven Date: Sat, 1 Aug 2026 00:25:20 +0200 Subject: [PATCH 1/4] Use composite build --- build.gradle.kts | 4 ++-- libs/Utilities-OG | 1 - settings.gradle.kts | 8 +------- 3 files changed, 3 insertions(+), 10 deletions(-) delete mode 160000 libs/Utilities-OG diff --git a/build.gradle.kts b/build.gradle.kts index a20eefe..5f8c222 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -54,8 +54,8 @@ dependencies { compileOnly( files("libs/AnnouncerPlus-1.4.1.jar") ) // Import AnnouncerPlus API (binary-compatible with AnnouncerPlus-OG API). - compileOnlyApi(project(":libs:Utilities-OG")) // Import TrueOG Network Utilities-OG Java API (from source). - compileOnlyApi(project(":libs:Vanish-OG")) // Import TrueOG Network Vanish-OG Java API (from source). + compileOnlyApi("net.trueog.utilities-og:Utilities-OG") // Import TrueOG Network Utilities-OG Java API (from source). + compileOnlyApi("de.myzelyam.vanishog:Vanish-OG") // Import TrueOG Network Vanish-OG Java API (from source). compileOnly("net.luckperms:api:5.5") // Import LuckPerms API. compileOnly( "io.github.miniplaceholders:miniplaceholders-api:2.2.3" diff --git a/libs/Utilities-OG b/libs/Utilities-OG deleted file mode 160000 index b5a370e..0000000 --- a/libs/Utilities-OG +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b5a370e124173e433136fd7aaa0f0cc9661128d0 diff --git a/settings.gradle.kts b/settings.gradle.kts index b4cc8f2..9c7b182 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -4,10 +4,4 @@ ProcessBuilder("sh", "bootstrap.sh").directory(rootDir).inheritIO().start().let if (it.waitFor() != 0) throw GradleException("bootstrap.sh failed") } -file("libs") - .listFiles() - ?.filter { it.isDirectory && !it.name.startsWith(".") } - ?.forEach { dir -> - include(":libs:${dir.name}") - project(":libs:${dir.name}").projectDir = dir - } +file("libs").listFiles()?.filter { it.isDirectory && !it.name.startsWith(".") }?.forEach { dir -> includeBuild(dir) } -- 2.47.3 From 8bd3fa9cfc99e1517c8eaade6c286fb07e7b537e Mon Sep 17 00:00:00 2001 From: Sven Date: Sat, 1 Aug 2026 00:25:27 +0200 Subject: [PATCH 2/4] Update Kotlin to 2.4.10 --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 5f8c222..9acf55c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ plugins { id("com.diffplug.spotless") version "8.1.0" // Import Spotless plugin. id("com.gradleup.shadow") version "8.3.9" // Import Shadow plugin. eclipse // Import Eclipse plugin. - kotlin("jvm") version "2.1.21" // Import Kotlin JVM plugin. + kotlin("jvm") version "2.4.10" // Import Kotlin JVM plugin. } /* ---------------------------- Java / Kotlin -------------------------- */ -- 2.47.3 From e1f3422ebdab8e51ed69893c08df055c9a57ae62 Mon Sep 17 00:00:00 2001 From: Sven Date: Sat, 1 Aug 2026 00:26:05 +0200 Subject: [PATCH 3/4] Support wildcard domain blocklists --- .../skbotnl/chatog/util/BlocklistManager.kt | 25 ++++++++----- .../nl/skbotnl/chatog/util/DomainTrie.kt | 37 +++++++++++++++++++ src/main/resources/config.yml | 6 +-- 3 files changed, 56 insertions(+), 12 deletions(-) create mode 100644 src/main/kotlin/nl/skbotnl/chatog/util/DomainTrie.kt diff --git a/src/main/kotlin/nl/skbotnl/chatog/util/BlocklistManager.kt b/src/main/kotlin/nl/skbotnl/chatog/util/BlocklistManager.kt index 75f37f7..4e74561 100755 --- a/src/main/kotlin/nl/skbotnl/chatog/util/BlocklistManager.kt +++ b/src/main/kotlin/nl/skbotnl/chatog/util/BlocklistManager.kt @@ -1,7 +1,8 @@ package nl.skbotnl.chatog.util +import java.io.IOException import java.net.URI -import java.util.concurrent.TimeUnit +import kotlin.time.Duration.Companion.days import kotlinx.coroutines.delay import kotlinx.coroutines.launch import nl.skbotnl.chatog.ChatOG.Companion.config @@ -10,16 +11,16 @@ import nl.skbotnl.chatog.ChatOG.Companion.scope internal class BlocklistManager { private val lock = Any() - private val blockList = mutableListOf() + private val blockedDomainTrie = DomainTrie() init { plugin.logger.info("Loading the blocklists...") refresh() - plugin.logger.info("Loaded the blocklists!") scope.launch { while (true) { - delay(TimeUnit.DAYS.toMillis(1)) + delay(1.days) + plugin.logger.info("Refreshing the blocklists...") refresh() } } @@ -27,15 +28,21 @@ internal class BlocklistManager { private fun refresh() { synchronized(lock) { - blockList.clear() + blockedDomainTrie.clear() config.blocklist.blocklists.forEach { blocklist -> - URI(blocklist).toURL().openStream().use { input -> - input.bufferedReader().use { bufferedReader -> - bufferedReader.lines().forEach { if (!it.startsWith("#")) blockList.add(it) } + try { + URI(blocklist).toURL().openStream().use { input -> + input.bufferedReader().use { bufferedReader -> + bufferedReader.lines().forEach { if (!it.startsWith("#")) blockedDomainTrie.insert(it) } + } } + } catch (_: IOException) { + plugin.logger.severe("Failed to load the blocklists") + return } } } + plugin.logger.info("Loaded the blocklists!") } private val urlRegex = Regex("(?:https?://)?([a-zA-Z0-9.-]+\\.[a-zA-Z]{2,})") @@ -43,6 +50,6 @@ internal class BlocklistManager { fun checkUrl(url: String): Boolean { val match = urlRegex.find(url) ?: return false val baseUrl = match.groups[1]?.value ?: return false - return synchronized(lock) { blockList.contains(baseUrl) } + return synchronized(lock) { blockedDomainTrie.contains(baseUrl) } } } diff --git a/src/main/kotlin/nl/skbotnl/chatog/util/DomainTrie.kt b/src/main/kotlin/nl/skbotnl/chatog/util/DomainTrie.kt new file mode 100644 index 0000000..a98b5e7 --- /dev/null +++ b/src/main/kotlin/nl/skbotnl/chatog/util/DomainTrie.kt @@ -0,0 +1,37 @@ +package nl.skbotnl.chatog.util + +class DomainTrie { + class Node : HashMap() + + private val root = Node() + + fun insert(domain: String) { + var node = root + val labels = domain.split('.').asReversed() + labels.forEachIndexed { index, label -> + node = + if (index == labels.lastIndex) { + Node().also { node[label] = it } + } else { + val child = node[label] + if (child != null) { + if (child.isEmpty()) return // Terminal node, subdomains already handled + child + } else { + Node().also { node[label] = it } + } + } + } + } + + fun contains(domain: String): Boolean { + var node = root + for (label in domain.split('.').asReversed()) { + node = node[label] ?: return false + if (node.isEmpty()) return true + } + return false + } + + fun clear() = root.clear() +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index f09f14f..5bc3741 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -4,10 +4,10 @@ prefix: [Chat-OG] blocklist: enabled: true - # Only blocklists with just a list of domains + # Only wildcard domain blocklists are supported blocklists: - - https://raw.githubusercontent.com/hagezi/dns-blocklists/main/domains/multi.txt - - https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/nsfw-onlydomains.txt + - https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/wildcard/multi-onlydomains.txt + - https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/wildcard/nsfw-onlydomains.txt # ---Redis--- redis: -- 2.47.3 From 04b23d559b42a6ae28068bd9129709ac2f7789a2 Mon Sep 17 00:00:00 2001 From: Sven Date: Sat, 1 Aug 2026 00:26:59 +0200 Subject: [PATCH 4/4] Completely remove Utilities-OG submodule --- .gitmodules | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 9449a59..0150a95 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "libs/Utilities-OG"] - path = libs/Utilities-OG - url = https://github.com/true-og/Utilities-OG [submodule "libs/Vanish-OG"] path = libs/Vanish-OG url = https://github.com/true-og/Vanish-OG -- 2.47.3