mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-08 09:10:11 +08:00
Merge remote-tracking branch 'origin/master'
# Conflicts: # mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/cryptor/ECDHJvm.kt
This commit is contained in:
commit
e8854d8327
@ -10,19 +10,17 @@ package net.mamoe.mirai.console
|
||||
*/
|
||||
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.alsoLogin
|
||||
import net.mamoe.mirai.api.http.MiraiHttpAPIServer
|
||||
import net.mamoe.mirai.api.http.generateSessionKey
|
||||
import net.mamoe.mirai.contact.sendMessage
|
||||
import net.mamoe.mirai.console.plugins.PluginManager
|
||||
import net.mamoe.mirai.console.plugins.loadAsConfig
|
||||
import net.mamoe.mirai.console.plugins.withDefaultWrite
|
||||
import net.mamoe.mirai.console.plugins.withDefaultWriteSave
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.alsoLogin
|
||||
import net.mamoe.mirai.contact.sendMessage
|
||||
import net.mamoe.mirai.utils.SimpleLogger
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider
|
||||
import java.io.File
|
||||
import java.security.Security
|
||||
import java.util.*
|
||||
import java.util.concurrent.LinkedBlockingQueue
|
||||
import kotlin.concurrent.thread
|
||||
@ -307,10 +305,6 @@ class MiraiConsoleLoader {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
Security.removeProvider("BC")
|
||||
Security.addProvider(BouncyCastleProvider())
|
||||
Security.addProvider(org.bouncycastle.jce.provider.BouncyCastleProvider())
|
||||
//Security.addProvider(BouncyCastle)
|
||||
MiraiConsoleUI.start()
|
||||
MiraiConsole.start()
|
||||
Runtime.getRuntime().addShutdownHook(thread(start = false) {
|
||||
|
@ -12,6 +12,8 @@
|
||||
package net.mamoe.mirai.event
|
||||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.channels.ReceiveChannel
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.contact.isAdministrator
|
||||
import net.mamoe.mirai.contact.isOperator
|
||||
@ -125,6 +127,17 @@ inline fun <R> Bot.subscribeFriendMessages(crossinline listeners: MessageSubscri
|
||||
}.run(listeners)
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回一个指定事件的接收通道
|
||||
*/
|
||||
inline fun <reified E : Event> Bot.incoming(): ReceiveChannel<E> {
|
||||
return Channel<E>(8).apply {
|
||||
subscribeAlways<E> {
|
||||
send(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 消息事件的处理器.
|
||||
|
@ -43,13 +43,12 @@ actual fun ECDH() = ECDH(ECDH.generateKeyPair())
|
||||
actual class ECDH actual constructor(actual val keyPair: ECDHKeyPair) {
|
||||
actual companion object {
|
||||
private var isECDHAvailable = true
|
||||
|
||||
init {
|
||||
if (kotlin.runCatching {
|
||||
Security.addProvider(BouncyCastleProvider())
|
||||
generateKeyPair() // try if it is working
|
||||
}.exceptionOrNull() == null) {
|
||||
isECDHAvailable = true
|
||||
}
|
||||
isECDHAvailable = kotlin.runCatching {
|
||||
Security.addProvider(BouncyCastleProvider())
|
||||
generateKeyPair() // try if it is working
|
||||
}.isSuccess
|
||||
}
|
||||
|
||||
actual fun generateKeyPair(): ECDHKeyPair {
|
||||
|
Loading…
Reference in New Issue
Block a user