mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-23 22:30:47 +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 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.MiraiHttpAPIServer
|
||||||
import net.mamoe.mirai.api.http.generateSessionKey
|
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.PluginManager
|
||||||
import net.mamoe.mirai.console.plugins.loadAsConfig
|
import net.mamoe.mirai.console.plugins.loadAsConfig
|
||||||
import net.mamoe.mirai.console.plugins.withDefaultWrite
|
import net.mamoe.mirai.console.plugins.withDefaultWrite
|
||||||
import net.mamoe.mirai.console.plugins.withDefaultWriteSave
|
import net.mamoe.mirai.console.plugins.withDefaultWriteSave
|
||||||
import net.mamoe.mirai.Bot
|
import net.mamoe.mirai.contact.sendMessage
|
||||||
import net.mamoe.mirai.alsoLogin
|
|
||||||
import net.mamoe.mirai.utils.SimpleLogger
|
import net.mamoe.mirai.utils.SimpleLogger
|
||||||
import org.bouncycastle.jce.provider.BouncyCastleProvider
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.security.Security
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.LinkedBlockingQueue
|
import java.util.concurrent.LinkedBlockingQueue
|
||||||
import kotlin.concurrent.thread
|
import kotlin.concurrent.thread
|
||||||
@ -307,10 +305,6 @@ class MiraiConsoleLoader {
|
|||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
Security.removeProvider("BC")
|
|
||||||
Security.addProvider(BouncyCastleProvider())
|
|
||||||
Security.addProvider(org.bouncycastle.jce.provider.BouncyCastleProvider())
|
|
||||||
//Security.addProvider(BouncyCastle)
|
|
||||||
MiraiConsoleUI.start()
|
MiraiConsoleUI.start()
|
||||||
MiraiConsole.start()
|
MiraiConsole.start()
|
||||||
Runtime.getRuntime().addShutdownHook(thread(start = false) {
|
Runtime.getRuntime().addShutdownHook(thread(start = false) {
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
package net.mamoe.mirai.event
|
package net.mamoe.mirai.event
|
||||||
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.channels.Channel
|
||||||
|
import kotlinx.coroutines.channels.ReceiveChannel
|
||||||
import net.mamoe.mirai.Bot
|
import net.mamoe.mirai.Bot
|
||||||
import net.mamoe.mirai.contact.isAdministrator
|
import net.mamoe.mirai.contact.isAdministrator
|
||||||
import net.mamoe.mirai.contact.isOperator
|
import net.mamoe.mirai.contact.isOperator
|
||||||
@ -125,6 +127,17 @@ inline fun <R> Bot.subscribeFriendMessages(crossinline listeners: MessageSubscri
|
|||||||
}.run(listeners)
|
}.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 class ECDH actual constructor(actual val keyPair: ECDHKeyPair) {
|
||||||
actual companion object {
|
actual companion object {
|
||||||
private var isECDHAvailable = true
|
private var isECDHAvailable = true
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (kotlin.runCatching {
|
isECDHAvailable = kotlin.runCatching {
|
||||||
Security.addProvider(BouncyCastleProvider())
|
Security.addProvider(BouncyCastleProvider())
|
||||||
generateKeyPair() // try if it is working
|
generateKeyPair() // try if it is working
|
||||||
}.exceptionOrNull() == null) {
|
}.isSuccess
|
||||||
isECDHAvailable = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
actual fun generateKeyPair(): ECDHKeyPair {
|
actual fun generateKeyPair(): ECDHKeyPair {
|
||||||
|
Loading…
Reference in New Issue
Block a user