mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 13:12:17 +08:00
Shamrock
: A60's PING-PONG
This commit is contained in:
parent
2c3466b4c3
commit
bffb7caf04
@ -249,6 +249,11 @@ object ShamrockConfig {
|
|||||||
return preferences.getBoolean("enable_auto_start", false)
|
return preferences.getBoolean("enable_auto_start", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun enableAliveReply(ctx: Context): Boolean {
|
||||||
|
val preferences = ctx.getSharedPreferences("config", 0)
|
||||||
|
return preferences.getBoolean("alive_reply", false)
|
||||||
|
}
|
||||||
|
|
||||||
fun allowShell(ctx: Context): Boolean {
|
fun allowShell(ctx: Context): Boolean {
|
||||||
val preferences = ctx.getSharedPreferences("config", 0)
|
val preferences = ctx.getSharedPreferences("config", 0)
|
||||||
return preferences.getBoolean("shell", false)
|
return preferences.getBoolean("shell", false)
|
||||||
@ -259,6 +264,11 @@ object ShamrockConfig {
|
|||||||
preferences.edit().putBoolean("enable_auto_start", v).apply()
|
preferences.edit().putBoolean("enable_auto_start", v).apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setAliveReply(ctx: Context, v: Boolean) {
|
||||||
|
val preferences = ctx.getSharedPreferences("config", 0)
|
||||||
|
preferences.edit().putBoolean("alive_reply", v).apply()
|
||||||
|
}
|
||||||
|
|
||||||
fun setShellStatus(ctx: Context, v: Boolean) {
|
fun setShellStatus(ctx: Context, v: Boolean) {
|
||||||
val preferences = ctx.getSharedPreferences("config", 0)
|
val preferences = ctx.getSharedPreferences("config", 0)
|
||||||
preferences.edit().putBoolean("shell", v).apply()
|
preferences.edit().putBoolean("shell", v).apply()
|
||||||
@ -304,12 +314,13 @@ object ShamrockConfig {
|
|||||||
"inject_packet" to preferences.getBoolean("inject_packet", false),
|
"inject_packet" to preferences.getBoolean("inject_packet", false),
|
||||||
"debug" to preferences.getBoolean("debug", false),
|
"debug" to preferences.getBoolean("debug", false),
|
||||||
"anti_qq_trace" to preferences.getBoolean("anti_qq_trace", true),
|
"anti_qq_trace" to preferences.getBoolean("anti_qq_trace", true),
|
||||||
"auto_clear" to preferences.getBoolean("auto_clear", false),
|
//"auto_clear" to preferences.getBoolean("auto_clear", false),
|
||||||
"ssl_private_pwd" to preferences.getString("ssl_private_pwd", ""),
|
"ssl_private_pwd" to preferences.getString("ssl_private_pwd", ""),
|
||||||
"key_store" to preferences.getString("key_store", ""),
|
"key_store" to preferences.getString("key_store", ""),
|
||||||
"enable_self_msg" to preferences.getBoolean("enable_self_msg", false),
|
"enable_self_msg" to preferences.getBoolean("enable_self_msg", false),
|
||||||
"echo_number" to preferences.getBoolean("echo_number", false),
|
"echo_number" to preferences.getBoolean("echo_number", false),
|
||||||
"shell" to preferences.getBoolean("shell", false),
|
"shell" to preferences.getBoolean("shell", false),
|
||||||
|
"alive_reply" to preferences.getBoolean("alive_reply", false),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,17 +85,6 @@ fun LabFragment() {
|
|||||||
ShamrockConfig.pushUpdate(ctx)
|
ShamrockConfig.pushUpdate(ctx)
|
||||||
return@Function true
|
return@Function true
|
||||||
}
|
}
|
||||||
|
|
||||||
Function(
|
|
||||||
title = LocalString.antiTrace,
|
|
||||||
desc = LocalString.antiTraceDesc,
|
|
||||||
descColor = it,
|
|
||||||
isSwitch = ShamrockConfig.isAntiTrace(ctx)
|
|
||||||
) {
|
|
||||||
ShamrockConfig.setAntiTrace(ctx, it)
|
|
||||||
ShamrockConfig.pushUpdate(ctx)
|
|
||||||
return@Function true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,13 +113,12 @@ fun LabFragment() {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
Function(
|
Function(
|
||||||
title = LocalString.injectPacket,
|
title = "自回复测试",
|
||||||
desc = LocalString.injectPacketDesc,
|
desc = "发送[ping],机器人发送一个具有调试信息的返回。",
|
||||||
descColor = color,
|
descColor = color,
|
||||||
isSwitch = ShamrockConfig.isInjectPacket(ctx)
|
isSwitch = ShamrockConfig.enableAliveReply(ctx)
|
||||||
) {
|
) {
|
||||||
ShamrockConfig.setInjectPacket(ctx, it)
|
ShamrockConfig.setAliveReply(ctx, it)
|
||||||
ShamrockConfig.pushUpdate(ctx)
|
|
||||||
return@Function true
|
return@Function true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +155,50 @@ fun LabFragment() {
|
|||||||
scope.toast(ctx, LocalString.restartSysToast)
|
scope.toast(ctx, LocalString.restartSysToast)
|
||||||
return@Function true
|
return@Function true
|
||||||
}
|
}
|
||||||
|
}.onFailure {
|
||||||
|
AppRuntime.log("无法启用附加选项,LSPosed模块未激活或者不支持XSharedPreferences", Level.WARN)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ActionBox(
|
||||||
|
modifier = Modifier.padding(top = 12.dp),
|
||||||
|
painter = painterResource(id = R.drawable.sharp_lock_24),
|
||||||
|
title = "安全性设置"
|
||||||
|
) { color ->
|
||||||
|
Column {
|
||||||
|
Divider(
|
||||||
|
modifier = Modifier,
|
||||||
|
color = GlobalColor.Divider,
|
||||||
|
thickness = 0.2.dp
|
||||||
|
)
|
||||||
|
|
||||||
|
Function(
|
||||||
|
title = LocalString.injectPacket,
|
||||||
|
desc = LocalString.injectPacketDesc,
|
||||||
|
descColor = color,
|
||||||
|
isSwitch = ShamrockConfig.isInjectPacket(ctx)
|
||||||
|
) {
|
||||||
|
ShamrockConfig.setInjectPacket(ctx, it)
|
||||||
|
ShamrockConfig.pushUpdate(ctx)
|
||||||
|
return@Function true
|
||||||
|
}
|
||||||
|
|
||||||
|
Function(
|
||||||
|
title = LocalString.antiTrace,
|
||||||
|
desc = LocalString.antiTraceDesc,
|
||||||
|
descColor = color,
|
||||||
|
isSwitch = ShamrockConfig.isAntiTrace(ctx)
|
||||||
|
) {
|
||||||
|
ShamrockConfig.setAntiTrace(ctx, it)
|
||||||
|
ShamrockConfig.pushUpdate(ctx)
|
||||||
|
return@Function true
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin.runCatching {
|
||||||
|
ctx.getSharedPreferences("shared_config", Context.MODE_WORLD_READABLE)
|
||||||
|
}.onSuccess {
|
||||||
Function(
|
Function(
|
||||||
title = "反检测加强",
|
title = "反检测加强",
|
||||||
desc = "可能导致某些设备频繁闪退",
|
desc = "可能导致某些设备频繁闪退",
|
||||||
@ -178,11 +209,8 @@ fun LabFragment() {
|
|||||||
scope.toast(ctx, LocalString.restartToast)
|
scope.toast(ctx, LocalString.restartToast)
|
||||||
return@Function true
|
return@Function true
|
||||||
}
|
}
|
||||||
}.onFailure {
|
|
||||||
AppRuntime.log("无法启用附加选项,LSPosed模块未激活或者不支持XSharedPreferences", Level.WARN)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionBox(
|
ActionBox(
|
||||||
|
5
app/src/main/res/drawable/sharp_lock_24.xml
Normal file
5
app/src/main/res/drawable/sharp_lock_24.xml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<vector android:height="24dp" android:tint="#9D9D9D"
|
||||||
|
android:viewportHeight="24" android:viewportWidth="24"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M20,8h-3L17,6.21c0,-2.61 -1.91,-4.94 -4.51,-5.19C9.51,0.74 7,3.08 7,6v2L4,8v14h16L20,8zM12,17c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2zM9,8L9,6c0,-1.66 1.34,-3 3,-3s3,1.34 3,3v2L9,8z"/>
|
||||||
|
</vector>
|
@ -1,6 +1,7 @@
|
|||||||
package moe.fuqiuluo.shamrock.remote.service.config
|
package moe.fuqiuluo.shamrock.remote.service.config
|
||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import com.tencent.mmkv.MMKV
|
||||||
import kotlinx.serialization.decodeFromString
|
import kotlinx.serialization.decodeFromString
|
||||||
import kotlinx.serialization.encodeToString
|
import kotlinx.serialization.encodeToString
|
||||||
import moe.fuqiuluo.shamrock.tools.GlobalJson5
|
import moe.fuqiuluo.shamrock.tools.GlobalJson5
|
||||||
@ -65,7 +66,7 @@ internal object ShamrockConfig {
|
|||||||
putString( "ssl_alias", intent.getStringExtra("ssl_alias")) // 证书别名
|
putString( "ssl_alias", intent.getStringExtra("ssl_alias")) // 证书别名
|
||||||
putInt( "ssl_port", intent.getIntExtra("ssl_port", 5701)) // 主动HTTP端口
|
putInt( "ssl_port", intent.getIntExtra("ssl_port", 5701)) // 主动HTTP端口
|
||||||
|
|
||||||
putBoolean("auto_clear", intent.getBooleanExtra("auto_clear", false)) // 自动清理
|
putBoolean("alive_reply", intent.getBooleanExtra("alive_reply", false)) // 自回复测试
|
||||||
|
|
||||||
putBoolean("enable_self_msg", intent.getBooleanExtra("enable_self_msg", false)) // 推送自己发的消息
|
putBoolean("enable_self_msg", intent.getBooleanExtra("enable_self_msg", false)) // 推送自己发的消息
|
||||||
putBoolean("shell", intent.getBooleanExtra("shell", false)) // 开启Shell接口
|
putBoolean("shell", intent.getBooleanExtra("shell", false)) // 开启Shell接口
|
||||||
@ -75,6 +76,13 @@ internal object ShamrockConfig {
|
|||||||
updateConfig()
|
updateConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val mmkv: MMKV
|
||||||
|
get() = MMKVFetcher.mmkvWithId("shamrock_config")
|
||||||
|
|
||||||
|
fun aliveReply(): Boolean {
|
||||||
|
return mmkv.getBoolean("alive_reply", false)
|
||||||
|
}
|
||||||
|
|
||||||
fun allowTempSession(): Boolean {
|
fun allowTempSession(): Boolean {
|
||||||
return Config.allowTempSession
|
return Config.allowTempSession
|
||||||
}
|
}
|
||||||
@ -88,12 +96,10 @@ internal object ShamrockConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun enableSelfMsg(): Boolean {
|
fun enableSelfMsg(): Boolean {
|
||||||
val mmkv = MMKVFetcher.mmkvWithId("shamrock_config")
|
|
||||||
return mmkv.getBoolean("enable_self_msg", false)
|
return mmkv.getBoolean("enable_self_msg", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun openWebSocketClient(): Boolean {
|
fun openWebSocketClient(): Boolean {
|
||||||
val mmkv = MMKVFetcher.mmkvWithId("shamrock_config")
|
|
||||||
return mmkv.getBoolean("ws_client", false)
|
return mmkv.getBoolean("ws_client", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +108,6 @@ internal object ShamrockConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun openWebSocket(): Boolean {
|
fun openWebSocket(): Boolean {
|
||||||
val mmkv = MMKVFetcher.mmkvWithId("shamrock_config")
|
|
||||||
return mmkv.getBoolean("ws", false)
|
return mmkv.getBoolean("ws", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,37 +120,30 @@ internal object ShamrockConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun useCQ(): Boolean {
|
fun useCQ(): Boolean {
|
||||||
val mmkv = MMKVFetcher.mmkvWithId("shamrock_config")
|
|
||||||
return mmkv.getBoolean("use_cqcode", false)
|
return mmkv.getBoolean("use_cqcode", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun allowWebHook(): Boolean {
|
fun allowWebHook(): Boolean {
|
||||||
val mmkv = MMKVFetcher.mmkvWithId("shamrock_config")
|
|
||||||
return mmkv.getBoolean("http", false)
|
return mmkv.getBoolean("http", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getWebHookAddress(): String {
|
fun getWebHookAddress(): String {
|
||||||
val mmkv = MMKVFetcher.mmkvWithId("shamrock_config")
|
|
||||||
return mmkv.getString("http_addr", "") ?: ""
|
return mmkv.getString("http_addr", "") ?: ""
|
||||||
}
|
}
|
||||||
|
|
||||||
fun forceTablet(): Boolean {
|
fun forceTablet(): Boolean {
|
||||||
val mmkv = MMKVFetcher.mmkvWithId("shamrock_config")
|
|
||||||
return mmkv.getBoolean("tablet", true)
|
return mmkv.getBoolean("tablet", true)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getPort(): Int {
|
fun getPort(): Int {
|
||||||
val mmkv = MMKVFetcher.mmkvWithId("shamrock_config")
|
|
||||||
return mmkv.getInt("port", 5700)
|
return mmkv.getInt("port", 5700)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isInjectPacket(): Boolean {
|
fun isInjectPacket(): Boolean {
|
||||||
val mmkv = MMKVFetcher.mmkvWithId("shamrock_config")
|
|
||||||
return mmkv.getBoolean("inject_packet", false)
|
return mmkv.getBoolean("inject_packet", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isDebug(): Boolean {
|
fun isDebug(): Boolean {
|
||||||
val mmkv = MMKVFetcher.mmkvWithId("shamrock_config")
|
|
||||||
return mmkv.getBoolean("debug", false)
|
return mmkv.getBoolean("debug", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +152,6 @@ internal object ShamrockConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getKeyStorePath(): File? {
|
fun getKeyStorePath(): File? {
|
||||||
val mmkv = MMKVFetcher.mmkvWithId("shamrock_config")
|
|
||||||
mmkv.getString("key_store", null)?.let {
|
mmkv.getString("key_store", null)?.let {
|
||||||
return File(it)
|
return File(it)
|
||||||
}
|
}
|
||||||
@ -162,52 +159,42 @@ internal object ShamrockConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun sslPwd(): CharArray? {
|
fun sslPwd(): CharArray? {
|
||||||
val mmkv = MMKVFetcher.mmkvWithId("shamrock_config")
|
|
||||||
return mmkv.getString("ssl_pwd", null)?.toCharArray()
|
return mmkv.getString("ssl_pwd", null)?.toCharArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sslPrivatePwd(): String? {
|
fun sslPrivatePwd(): String? {
|
||||||
val mmkv = MMKVFetcher.mmkvWithId("shamrock_config")
|
|
||||||
return mmkv.getString("ssl_private_pwd", null)
|
return mmkv.getString("ssl_private_pwd", null)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sslAlias(): String? {
|
fun sslAlias(): String? {
|
||||||
val mmkv = MMKVFetcher.mmkvWithId("shamrock_config")
|
|
||||||
return mmkv.getString("ssl_alias", null)
|
return mmkv.getString("ssl_alias", null)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getSslPort(): Int {
|
fun getSslPort(): Int {
|
||||||
val mmkv = MMKVFetcher.mmkvWithId("shamrock_config")
|
|
||||||
return mmkv.getInt("ssl_port", getPort())
|
return mmkv.getInt("ssl_port", getPort())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isDev(): Boolean {
|
fun isDev(): Boolean {
|
||||||
val mmkv = MMKVFetcher.mmkvWithId("shamrock_config")
|
|
||||||
return mmkv.getBoolean("dev", false)
|
return mmkv.getBoolean("dev", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
operator fun set(key: String, value: String) {
|
operator fun set(key: String, value: String) {
|
||||||
val mmkv = MMKVFetcher.mmkvWithId("shamrock_config")
|
|
||||||
mmkv.putString(key, value)
|
mmkv.putString(key, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
operator fun set(key: String, value: Boolean) {
|
operator fun set(key: String, value: Boolean) {
|
||||||
val mmkv = MMKVFetcher.mmkvWithId("shamrock_config")
|
|
||||||
mmkv.putBoolean(key, value)
|
mmkv.putBoolean(key, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
operator fun set(key: String, value: Int) {
|
operator fun set(key: String, value: Int) {
|
||||||
val mmkv = MMKVFetcher.mmkvWithId("shamrock_config")
|
|
||||||
mmkv.putInt(key, value)
|
mmkv.putInt(key, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
operator fun set(key: String, value: Long) {
|
operator fun set(key: String, value: Long) {
|
||||||
val mmkv = MMKVFetcher.mmkvWithId("shamrock_config")
|
|
||||||
mmkv.putLong(key, value)
|
mmkv.putLong(key, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
operator fun set(key: String, value: Float) {
|
operator fun set(key: String, value: Float) {
|
||||||
val mmkv = MMKVFetcher.mmkvWithId("shamrock_config")
|
|
||||||
mmkv.putFloat(key, value)
|
mmkv.putFloat(key, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,7 +203,6 @@ internal object ShamrockConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun allowShell(): Boolean {
|
fun allowShell(): Boolean {
|
||||||
val mmkv = MMKVFetcher.mmkvWithId("shamrock_config")
|
|
||||||
return mmkv.getBoolean("shell", false)
|
return mmkv.getBoolean("shell", false)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,6 +7,7 @@ import com.tencent.qqnt.kernel.nativeinterface.*
|
|||||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import moe.fuqiuluo.qqinterface.servlet.MsgSvc
|
||||||
import moe.fuqiuluo.qqinterface.servlet.TicketSvc
|
import moe.fuqiuluo.qqinterface.servlet.TicketSvc
|
||||||
import moe.fuqiuluo.qqinterface.servlet.msg.convert.toCQCode
|
import moe.fuqiuluo.qqinterface.servlet.msg.convert.toCQCode
|
||||||
import moe.fuqiuluo.qqinterface.servlet.transfile.RichProtoSvc
|
import moe.fuqiuluo.qqinterface.servlet.transfile.RichProtoSvc
|
||||||
@ -65,6 +66,10 @@ internal object AioListener: IKernelMsgListener {
|
|||||||
val rawMsg = record.elements.toCQCode(record.chatType, record.peerUin.toString())
|
val rawMsg = record.elements.toCQCode(record.chatType, record.peerUin.toString())
|
||||||
if (rawMsg.isEmpty()) return
|
if (rawMsg.isEmpty()) return
|
||||||
|
|
||||||
|
if (ShamrockConfig.aliveReply() && rawMsg == "ping") {
|
||||||
|
MessageHelper.sendMessageWithoutMsgId(record.chatType, record.peerUin.toString(), "pong", { _, _ -> })
|
||||||
|
}
|
||||||
|
|
||||||
//if (rawMsg.contains("forward")) {
|
//if (rawMsg.contains("forward")) {
|
||||||
// LogCenter.log(record.extInfoForUI.decodeToString(), Level.WARN)
|
// LogCenter.log(record.extInfoForUI.decodeToString(), Level.WARN)
|
||||||
//}
|
//}
|
||||||
@ -141,10 +146,7 @@ internal object AioListener: IKernelMsgListener {
|
|||||||
time = record.msgTime
|
time = record.msgTime
|
||||||
)
|
)
|
||||||
|
|
||||||
val rawMsg = record.elements.toCQCode(record.chatType, record.peerUin.toString())
|
LogCenter.log("预发送消息($msgHash | ${record.msgSeq} | ${record.msgId})")
|
||||||
if (rawMsg.isEmpty()) return@launch
|
|
||||||
|
|
||||||
LogCenter.log("发送消息($msgHash | ${record.msgSeq} | ${record.msgId}): $rawMsg")
|
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
LogCenter.log(e.stackTraceToString(), Level.WARN)
|
LogCenter.log(e.stackTraceToString(), Level.WARN)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user