mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 13:12:17 +08:00
Shamrock
: Allow modification of active WebSocket listening address
Signed-off-by: WhiteChi <whitechi73@outlook.com>
This commit is contained in:
parent
c67b49790f
commit
b76ef7efb3
@ -21,7 +21,7 @@ import org.java_websocket.WebSocket
|
||||
import org.java_websocket.handshake.ClientHandshake
|
||||
import java.net.URI
|
||||
|
||||
internal class WebSocketService(port: Int): WebSocketTransmitServlet(port) {
|
||||
internal class WebSocketService(host: String, port: Int): WebSocketTransmitServlet(host, port) {
|
||||
private val eventJobList = mutableSetOf<Job>()
|
||||
|
||||
override fun submitFlowJob(job: Job) {
|
||||
|
@ -32,8 +32,9 @@ import java.util.Collections
|
||||
import kotlin.concurrent.timer
|
||||
|
||||
internal abstract class WebSocketTransmitServlet(
|
||||
host:String,
|
||||
port: Int
|
||||
) : BaseTransmitServlet, WebSocketServer(InetSocketAddress(port)) {
|
||||
) : BaseTransmitServlet, WebSocketServer(InetSocketAddress(host, port)) {
|
||||
protected val eventReceivers: MutableList<WebSocket> = Collections.synchronizedList(mutableListOf<WebSocket>())
|
||||
|
||||
override val address: String
|
||||
|
@ -118,9 +118,9 @@ internal class XposedEntry: IXposedHookLoadPackage {
|
||||
|
||||
log("Process Name = " + MobileQQ.getMobileQQ().qqProcessName.apply {
|
||||
// if (!contains("msf", ignoreCase = true)) return // 非MSF进程 退出
|
||||
if (contains("peak")) {
|
||||
PlatformUtils.killProcess(ctx, this)
|
||||
}
|
||||
//if (contains("peak")) {
|
||||
// PlatformUtils.killProcess(ctx, this)
|
||||
//}
|
||||
})
|
||||
|
||||
PlatformUtils.isTim()
|
||||
|
@ -70,7 +70,17 @@ internal class InitRemoteService : IAction {
|
||||
private fun startWebSocketServer() {
|
||||
GlobalScope.launch {
|
||||
try {
|
||||
val server = WebSocketService(ShamrockConfig.getActiveWebSocketConfig()?.port ?: 5700)
|
||||
val config = ShamrockConfig.getActiveWebSocketConfig() ?: return@launch
|
||||
config.address ?: kotlin.run {
|
||||
LogCenter.log("WebSocketServer地址不合法", Level.ERROR)
|
||||
return@launch
|
||||
}
|
||||
config.port ?: kotlin.run {
|
||||
LogCenter.log("WebSocketServer端口不合法", Level.ERROR)
|
||||
return@launch
|
||||
}
|
||||
require(config.port in 0 .. 65536) { "WebSocketServer端口不合法" }
|
||||
val server = WebSocketService(config.address, config.port!!)
|
||||
server.start()
|
||||
} catch (e: Throwable) {
|
||||
LogCenter.log(e.stackTraceToString(), Level.ERROR)
|
||||
|
Loading…
x
Reference in New Issue
Block a user