mirror of
https://github.com/LamGC/ScalaBot.git
synced 2025-04-29 22:27:31 +00:00
feat(extension): Maven 仓库搜索器将使用全局代理下载扩展包.
改动后, 配置的全局代理将适用于 MavenRepositoryExtensionFinder.
This commit is contained in:
parent
13472d952e
commit
692fe5b8f9
@ -7,6 +7,7 @@ import mu.KotlinLogging
|
|||||||
import net.lamgc.scalabot.util.ArtifactSerializer
|
import net.lamgc.scalabot.util.ArtifactSerializer
|
||||||
import net.lamgc.scalabot.util.ProxyTypeSerializer
|
import net.lamgc.scalabot.util.ProxyTypeSerializer
|
||||||
import org.eclipse.aether.artifact.Artifact
|
import org.eclipse.aether.artifact.Artifact
|
||||||
|
import org.eclipse.aether.repository.Proxy
|
||||||
import org.telegram.telegrambots.bots.DefaultBotOptions
|
import org.telegram.telegrambots.bots.DefaultBotOptions
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.nio.charset.StandardCharsets
|
import java.nio.charset.StandardCharsets
|
||||||
@ -58,7 +59,17 @@ internal data class ProxyConfig(
|
|||||||
val type: DefaultBotOptions.ProxyType = DefaultBotOptions.ProxyType.NO_PROXY,
|
val type: DefaultBotOptions.ProxyType = DefaultBotOptions.ProxyType.NO_PROXY,
|
||||||
val host: String = "127.0.0.1",
|
val host: String = "127.0.0.1",
|
||||||
val port: Int = 1080
|
val port: Int = 1080
|
||||||
)
|
) {
|
||||||
|
|
||||||
|
fun toAetherProxy(): Proxy? {
|
||||||
|
return if (type == DefaultBotOptions.ProxyType.HTTP) {
|
||||||
|
Proxy(Proxy.TYPE_HTTP, host, port)
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
internal data class MetricsConfig(
|
internal data class MetricsConfig(
|
||||||
val enable: Boolean = false,
|
val enable: Boolean = false,
|
||||||
|
@ -25,7 +25,10 @@ internal class ExtensionLoader(
|
|||||||
private val finders: Set<ExtensionPackageFinder> = setOf(
|
private val finders: Set<ExtensionPackageFinder> = setOf(
|
||||||
FileNameFinder,
|
FileNameFinder,
|
||||||
MavenMetaInformationFinder,
|
MavenMetaInformationFinder,
|
||||||
MavenRepositoryExtensionFinder(LocalRepository("${System.getProperty("user.home")}/.m2/repository"))
|
MavenRepositoryExtensionFinder(
|
||||||
|
LocalRepository("${System.getProperty("user.home")}/.m2/repository"),
|
||||||
|
proxy = Const.config.proxy.toAetherProxy()
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
fun getExtensions(): Set<LoadedExtensionEntry> {
|
fun getExtensions(): Set<LoadedExtensionEntry> {
|
||||||
|
Loading…
Reference in New Issue
Block a user