Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a plugin update checker #1120

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion LavalinkServer/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,12 @@ dependencies {
implementation(libs.kotlin.reflect)
implementation(libs.logback)
implementation(libs.sentry.logback)
implementation(libs.semver)
implementation(libs.oshi) {
// This version of SLF4J does not recognise Logback 1.2.3
exclude(group = "org.slf4j", module = "slf4j-api")
}

testImplementation(libs.spring.boot.test)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import java.io.FileOutputStream
import java.io.InputStream
import java.net.URL
import java.net.URLClassLoader
import java.net.HttpURLConnection
import java.nio.channels.Channels
import java.util.*
import java.util.jar.JarFile
import io.github.z4kn4fein.semver.toVersion

@SpringBootApplication
class PluginManager(val config: PluginsConfig) {
Expand Down Expand Up @@ -83,6 +85,37 @@ class PluginManager(val config: PluginsConfig) {
val file = File(directory, declaration.canonicalJarName)
downloadJar(file, url)
}

checkPluginForUpdates(declaration)
}
}

private fun checkPluginForUpdates(declaration: Declaration) {
val splitPath = declaration.url.split('/')

val baseSplitPath = splitPath.dropLast(2)
val basePath = baseSplitPath.joinToString("/") + "/maven-metadata.xml"

val connection = URL(basePath).openConnection() as HttpURLConnection
connection.inputStream.bufferedReader().use {
val lines = it.readLines()
for (line in lines) {
val regex = "<latest>(.*?)</latest>".toRegex()
val match = regex.find(line)
val latest = match?.groups?.get(1)?.value
if (latest != null) {
val latestVersion = latest.toVersion()
val currentVersion = declaration.version.toVersion()

if(latestVersion > currentVersion) {
log.warn("A newer version of ${declaration.name} was found: $latestVersion. " +
"The current version is $currentVersion.")
} else {
log.info("Plugin ${declaration.name} is up to date")
}
break
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion docs/api/rest.md
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ When `identifier` is used, Lavalink will try to resolve the identifier as a sing

Response:

[Player](#Player) object
[Player](#player) object

<details markdown="1">
<summary>Example Payload</summary>
Expand Down
11 changes: 9 additions & 2 deletions docs/changelog/v3.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
## v3.7.13
!!! danger
This is the last Lavalink `v3` release, see [here](https://github.com/lavalink-devs/Lavalink/discussions/1100) for more info.

* Updated Lavaplayer to [`1.5.6`](https://github.com/lavalink-devs/lavaplayer/releases/tag/1.5.6)
* Updated koe to [`2.0.3-rc2`](https://github.com/KyokoBot/koe/releases/tag/2.0.3-rc2) & use voice gateway v8 in [#1098](https://github.com/lavalink-devs/Lavalink/pull/1098)

## v3.7.12
* Updated Lavaplayer to [`1.5.4`](https://github.com/lavalink-devs/lavaplayer/releases/tag/1.5.4)
* Updated Koe to [`2.0.1`](https://github.com/KyokoBot/koe/releases/tag/2.0.1) (fixes the `IndexOutOfBoundsException` when playing a YouTube track)

!!! warning

The default Youtube source is now deprecated and won't receive further updates. Please use https://github.com/lavalink-devs/youtube-source#plugin instead.
The default Youtube source is now deprecated and won't receive further updates. Please use https://github.com/lavalink-devs/youtube-source#plugin instead.

## v3.7.11
* Fixed not being able to seek when player is paused
Expand Down Expand Up @@ -42,7 +49,7 @@

!!! info

Lavalink Docker images are now found in the GitHub Container Registry instead of DockerHub
Lavalink Docker images are now found in the GitHub Container Registry instead of DockerHub

## v3.7.4

Expand Down
6 changes: 6 additions & 0 deletions docs/changelog/v4.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v4.0.8
* Updated koe to [`2.0.3-rc2`](https://github.com/KyokoBot/koe/releases/tag/2.0.3-rc2) & use voice gateway `v8` in [#1097](https://github.com/lavalink-devs/Lavalink/pull/1097)
* Updated Lavaplayer to [`2.2.2`](https://github.com/lavalink-devs/lavaplayer/releases/tag/2.2.2) in [#1105](https://github.com/lavalink-devs/Lavalink/pull/1105)
* Allow usage of non-allocating frame buffers in [#1095](https://github.com/lavalink-devs/Lavalink/pull/1095)
* Added shutdown handling to close sessions cleanly in [#1102](https://github.com/lavalink-devs/Lavalink/pull/1102)

## v4.0.7
* Updated Lavaplayer to [`2.2.1`](https://github.com/lavalink-devs/lavaplayer/releases/tag/2.2.1)
* Updated spring-boot to `3.3.0` & spring-websocket to `6.1.9`
Expand Down
5 changes: 3 additions & 2 deletions docs/getting-started/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ In general there are 6 log levels: `TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR` and
```yaml title="application.yml"
logging:
level:
# Set this to DEBUG to enable more detailed logging. Please note that this will log probably spam your console.
root: INFO
# Set this to DEBUG to enable more detailed logging from Lavalink
lavalink: DEBUG
# Set this to TRACE to see all WebSocket messages
# Set this to TRACE to see all WebSocket messages sent
lavalink.server.io.SocketContext: TRACE
# Log all track exceptions (COMMON, SUSPICIOUS & FAULT)
com.sedmelluq.discord.lavaplayer.tools.ExceptionTools: DEBUG
# Log YouTube Plugin stuff (only needed if you have issues with YouTube)
dev.lavalink.youtube: DEBUG

# This will log all requests to the REST API
request:
Expand Down
4 changes: 4 additions & 0 deletions docs/overrides/main.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{%- block extrahead -%}
<meta name="darkreader" content="">
{%- endblock -%}

{% extends "base.html" %}

{% block announce %}
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ fun VersionCatalogBuilder.common() {
library("logback", "ch.qos.logback", "logback-classic").version("1.5.6")
library("sentry-logback", "io.sentry", "sentry-logback").version("7.10.0")
library("oshi", "com.github.oshi", "oshi-core").version("6.4.11")
library("semver", "io.github.z4kn4fein", "semver").version("2.0.0")
}

fun VersionCatalogBuilder.other() {
Expand Down
Loading