Skip to content

Commit 862ff61

Browse files
committed
fix check enabling jda nas on supported platforms
1 parent c6cf95b commit 862ff61

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

LavalinkServer/src/main/java/lavalink/server/config/KoeConfiguration.kt

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package lavalink.server.config
22

3+
import com.sedmelluq.lava.common.natives.architecture.DefaultArchitectureTypes
4+
import com.sedmelluq.lava.common.natives.architecture.DefaultOperatingSystemTypes
5+
import com.sedmelluq.lava.common.natives.architecture.SystemType
36
import moe.kyokobot.koe.KoeOptions
47
import moe.kyokobot.koe.codec.udpqueue.UdpQueueFramePollerFactory
58
import org.slf4j.Logger
@@ -11,16 +14,29 @@ import org.springframework.context.annotation.Configuration
1114
class KoeConfiguration(val serverConfig: ServerConfig) {
1215

1316
private val log: Logger = LoggerFactory.getLogger(KoeConfiguration::class.java)
17+
private val supportedSystems = listOf(
18+
SystemType(DefaultArchitectureTypes.ARM, DefaultOperatingSystemTypes.LINUX),
19+
SystemType(DefaultArchitectureTypes.X86_64, DefaultOperatingSystemTypes.LINUX),
20+
SystemType(DefaultArchitectureTypes.X86_32, DefaultOperatingSystemTypes.LINUX),
21+
SystemType(DefaultArchitectureTypes.ARMv8_64, DefaultOperatingSystemTypes.LINUX),
22+
23+
SystemType(DefaultArchitectureTypes.X86_64, DefaultOperatingSystemTypes.WINDOWS),
24+
SystemType(DefaultArchitectureTypes.X86_32, DefaultOperatingSystemTypes.WINDOWS),
25+
26+
SystemType(DefaultArchitectureTypes.X86_64, DefaultOperatingSystemTypes.DARWIN),
27+
SystemType(DefaultArchitectureTypes.ARMv8_64, DefaultOperatingSystemTypes.DARWIN)
28+
)
1429

1530
@Bean
1631
fun koeOptions(): KoeOptions = KoeOptions.builder().apply {
17-
log.info("OS: " + System.getProperty("os.name") + ", Arch: " + System.getProperty("os.arch"))
18-
val os = System.getProperty("os.name")
19-
val arch = System.getProperty("os.arch")
32+
val systemType: SystemType? = try {
33+
SystemType(DefaultArchitectureTypes.detect(), DefaultOperatingSystemTypes.detect())
34+
} catch (e: IllegalArgumentException) {
35+
null
36+
}
37+
log.info("OS: ${systemType?.osType ?: "unknown"}, Arch: ${systemType?.architectureType ?: "unknown"}")
2038

21-
// Filter darwin m1 out
22-
val nasSupported = !os.contains("darwin", ignoreCase = true)
23-
&& !arch.equals("aarch64", ignoreCase = true)
39+
val nasSupported = supportedSystems.any { it.osType == systemType?.osType && it.architectureType == systemType?.architectureType }
2440

2541
if (nasSupported) {
2642
log.info("Enabling JDA-NAS")

0 commit comments

Comments
 (0)