Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ExternalControlActivity : Activity(), CoroutineScope by MainScope() {
val intervalMs = java.util.concurrent.TimeUnit.MINUTES.toMillis(updateInterval)

create(type, name).also {
patch(it, name, url, intervalMs)
patch(it, name, url, intervalMs, null)
}
}
startActivity(PropertiesActivity::class.intent.setUUID(uuid))
Expand Down Expand Up @@ -103,4 +103,4 @@ class ExternalControlActivity : Activity(), CoroutineScope by MainScope() {
@Suppress("DEPRECATION")
overridePendingTransition(0, 0)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class PropertiesActivity : BaseActivity<PropertiesDesign>() {

if (!canceled && profile != original) {
withProfile {
patch(profile.uuid, profile.name, profile.source, profile.interval)
patch(profile.uuid, profile.name, profile.source, profile.interval, profile.ageSecretKey)
}
}
}
Expand Down Expand Up @@ -92,7 +92,7 @@ class PropertiesActivity : BaseActivity<PropertiesDesign>() {
try {
withProcessing { updateStatus ->
withProfile {
patch(profile.uuid, profile.name, profile.source, profile.interval)
patch(profile.uuid, profile.name, profile.source, profile.interval, profile.ageSecretKey)

coroutineScope {
commit(profile.uuid) {
Expand Down
42 changes: 37 additions & 5 deletions app/src/main/res/drawable/ic_toggle_all.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,41 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="1024"
android:viewportHeight="1024">
<path
android:fillColor="#000000"
android:pathData="M277.3,554.7h469.3a192,192 0,1 1,0 384h-469.3a192,192 0,1 1,0 -384zM746.7,85.3a192,192 0,1 1,0 384h-469.3a192,192 0,0 1,0 -384h469.3zM746.7,810.7a64,64 0,1 1,0 -128,64 64,0 0,1 0,128zM277.3,640a106.7,106.7 0,1 0,0 213.3h469.3a106.7,106.7 0,1 0,0 -213.3h-469.3zM746.7,170.7h-469.3a106.7,106.7 0,0 0,0 213.3h469.3a106.7,106.7 0,1 0,0 -213.3zM277.3,341.3a64,64 0,1 1,0 -128,64 64,0 0,1 0,128z" />
android:viewportWidth="24"
android:viewportHeight="24">

<group
android:pivotX="12"
android:pivotY="12"
android:scaleX="0.92"
android:scaleY="0.92">
<path
android:fillColor="#00000000"
android:pathData="M8,3 L4,7l4,4"
android:strokeColor="#000000"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="2" />
<path
android:fillColor="#00000000"
android:pathData="M4,7h16"
android:strokeColor="#000000"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="2" />
<path
android:fillColor="#00000000"
android:pathData="m16,21 l4,-4 -4,-4"
android:strokeColor="#000000"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="2" />
<path
android:fillColor="#00000000"
android:pathData="M20,17H4"
android:strokeColor="#000000"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="2" />
</group>
</vector>
44 changes: 37 additions & 7 deletions app/src/main/res/drawable/ic_toggle_off.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,41 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="21.021898dp"
android:viewportWidth="1170"
android:viewportHeight="1024">

<path
android:fillColor="#000000"
android:pathData="M658.3,512q0,-59.4 -23.1,-113.4T572.6,305.1 479.1,242.6 365.7,219.4t-113.4,23.1T158.9,305.1 96.3,398.6 73.1,512t23.1,113.4T158.9,718.9t93.4,62.6T365.7,804.6t113.4,-23.1T572.6,718.9t62.6,-93.4T658.3,512zM1097.1,512q0,-59.4 -23.1,-113.4T1011.4,305.1t-93.4,-62.6T804.6,219.4h-220.6q68,51.4 107.7,128t39.7,164.6 -39.7,164.6 -107.7,128h220.6q59.4,0 113.4,-23.1T1011.4,718.9t62.6,-93.4T1097.1,512zM1170.3,512q0,74.3 -29.1,142t-78,116.6 -116.6,78 -142,29.1L365.7,877.7q-74.3,0 -142,-29.1t-116.6,-78 -78,-116.6T0,512t29.1,-142 78,-116.6 116.6,-78T365.7,146.3h438.9q74.3,0 142,29.1t116.6,78 78,116.6 29.1,142z" />
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<group
android:pivotX="12"
android:pivotY="12"
android:scaleX="0.92"
android:scaleY="0.92">
<path
android:fillColor="#00000000"
android:pathData="M18.36,6.64A9,9 0,0 1,20.77 15"
android:strokeColor="#000000"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="2" />
<path
android:fillColor="#00000000"
android:pathData="M6.16,6.16a9,9 0,1 0,12.68 12.68"
android:strokeColor="#000000"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="2" />
<path
android:fillColor="#00000000"
android:pathData="M12,2v4"
android:strokeColor="#000000"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="2" />
<path
android:fillColor="#00000000"
android:pathData="m2,2 l20,20"
android:strokeColor="#000000"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="2" />
</group>
</vector>
30 changes: 23 additions & 7 deletions app/src/main/res/drawable/ic_toggle_on.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="21.021898dp"
android:viewportWidth="1170"
android:viewportHeight="1024">

<path
android:fillColor="#000000"
android:pathData="M0,512q0,-74.3 29.1,-142t78,-116.6 116.6,-78T365.7,146.3h438.9q74.3,0 142,29.1t116.6,78 78,116.6 29.1,142 -29.1,142 -78,116.6 -116.6,78 -142,29.1L365.7,877.7q-74.3,0 -142,-29.1t-116.6,-78 -78,-116.6T0,512zM804.6,804.6q59.4,0 113.4,-23.1T1011.4,718.9t62.6,-93.4T1097.1,512t-23.1,-113.4T1011.4,305.1t-93.4,-62.6T804.6,219.4t-113.4,23.1T597.7,305.1 535.1,398.6 512,512t23.1,113.4T597.7,718.9t93.4,62.6T804.6,804.6z" />
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<group
android:pivotX="12"
android:pivotY="12"
android:scaleX="0.92"
android:scaleY="0.92">
<path
android:fillColor="#00000000"
android:pathData="M12,2v10"
android:strokeColor="#000000"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="2" />
<path
android:fillColor="#00000000"
android:pathData="M18.4,6.6a9,9 0,1 1,-12.77 0.04"
android:strokeColor="#000000"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="2" />
</group>
</vector>
1 change: 1 addition & 0 deletions core/src/foss/golang/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ require (
github.com/klauspost/reedsolomon v1.12.3 // indirect
github.com/mdlayher/netlink v1.7.2 // indirect
github.com/mdlayher/socket v0.5.1 // indirect
github.com/metacubex/age v0.0.0-20260603010618-28d156b4ea78 // indirect
github.com/metacubex/amneziawg-go v0.0.0-20251104174305-5a0e9f7e361d // indirect
github.com/metacubex/ascon v0.1.0 // indirect
github.com/metacubex/bart v0.26.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions core/src/foss/golang/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ github.com/mdlayher/netlink v1.7.2 h1:/UtM3ofJap7Vl4QWCPDGXY8d3GIY2UGSDbK+QWmY8/
github.com/mdlayher/netlink v1.7.2/go.mod h1:xraEF7uJbxLhc5fpHL4cPe221LI2bdttWlU+ZGLfQSw=
github.com/mdlayher/socket v0.5.1 h1:VZaqt6RkGkt2OE9l3GcC6nZkqD3xKeQLyfleW/uBcos=
github.com/mdlayher/socket v0.5.1/go.mod h1:TjPLHI1UgwEv5J1B5q0zTZq12A/6H7nKmtTanQE37IQ=
github.com/metacubex/age v0.0.0-20260603010618-28d156b4ea78 h1:LqWr0vb9zDNuQS+jJd4fnRYk/SEI7KJ7TDe/L4WFK48=
github.com/metacubex/age v0.0.0-20260603010618-28d156b4ea78/go.mod h1:BTBG/iVY7rg3qq5WdVCg0GFk58CSvCDSbjy8I7kEx/c=
github.com/metacubex/amneziawg-go v0.0.0-20251104174305-5a0e9f7e361d h1:vAJ0ZT4aO803F1uw2roIA9yH7Sxzox34tVVyye1bz6c=
github.com/metacubex/amneziawg-go v0.0.0-20251104174305-5a0e9f7e361d/go.mod h1:MsM/5czONyXMJ3PRr5DbQ4O/BxzAnJWOIcJdLzW6qHY=
github.com/metacubex/ascon v0.1.0 h1:6ZWxmXYszT1XXtwkf6nxfFhc/OTtQ9R3Vyj1jN32lGM=
Expand Down
23 changes: 19 additions & 4 deletions core/src/main/cpp/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ Java_com_github_kr328_clash_core_bridge_Bridge_nativeLoad(JNIEnv *env, jobject t

JNIEXPORT void JNICALL
Java_com_github_kr328_clash_core_bridge_Bridge_nativeFetchAndValid(JNIEnv *env, jobject thiz,
jobject callback,
jstring path,
jstring url, jboolean force) {
jobject callback,
jstring path,
jstring url, jboolean force) {
TRACE_METHOD();

jobject _completable = new_global(callback);
Expand All @@ -238,6 +238,21 @@ Java_com_github_kr328_clash_core_bridge_Bridge_nativeFetchAndValid(JNIEnv *env,
fetchAndValid(_completable, _path, _url, force);
}

JNIEXPORT void JNICALL
Java_com_github_kr328_clash_core_bridge_Bridge_nativeSetAgeSecretKey(JNIEnv *env, jobject thiz,
jstring key) {
TRACE_METHOD();

if (key == NULL) {
setAgeSecretKey(NULL);
return;
}

scoped_string _key = get_string(key);

setAgeSecretKey(_key);
}

JNIEXPORT jstring JNICALL
Java_com_github_kr328_clash_core_bridge_Bridge_nativeQueryProviders(JNIEnv *env, jobject thiz) {
TRACE_METHOD();
Expand Down Expand Up @@ -526,4 +541,4 @@ Java_com_github_kr328_clash_core_bridge_Bridge_nativeCoreVersion(JNIEnv *env, jo
char* Version = make_String(GIT_VERSION);

return new_string(Version);
}
}
1 change: 1 addition & 0 deletions core/src/main/golang/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ require (
github.com/klauspost/reedsolomon v1.12.3 // indirect
github.com/mdlayher/netlink v1.7.2 // indirect
github.com/mdlayher/socket v0.5.1 // indirect
github.com/metacubex/age v0.0.0-20260603010618-28d156b4ea78 // indirect
github.com/metacubex/amneziawg-go v0.0.0-20251104174305-5a0e9f7e361d // indirect
github.com/metacubex/ascon v0.1.0 // indirect
github.com/metacubex/bart v0.26.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/golang/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ github.com/mdlayher/netlink v1.7.2 h1:/UtM3ofJap7Vl4QWCPDGXY8d3GIY2UGSDbK+QWmY8/
github.com/mdlayher/netlink v1.7.2/go.mod h1:xraEF7uJbxLhc5fpHL4cPe221LI2bdttWlU+ZGLfQSw=
github.com/mdlayher/socket v0.5.1 h1:VZaqt6RkGkt2OE9l3GcC6nZkqD3xKeQLyfleW/uBcos=
github.com/mdlayher/socket v0.5.1/go.mod h1:TjPLHI1UgwEv5J1B5q0zTZq12A/6H7nKmtTanQE37IQ=
github.com/metacubex/age v0.0.0-20260603010618-28d156b4ea78 h1:LqWr0vb9zDNuQS+jJd4fnRYk/SEI7KJ7TDe/L4WFK48=
github.com/metacubex/age v0.0.0-20260603010618-28d156b4ea78/go.mod h1:BTBG/iVY7rg3qq5WdVCg0GFk58CSvCDSbjy8I7kEx/c=
github.com/metacubex/amneziawg-go v0.0.0-20251104174305-5a0e9f7e361d h1:vAJ0ZT4aO803F1uw2roIA9yH7Sxzox34tVVyye1bz6c=
github.com/metacubex/amneziawg-go v0.0.0-20251104174305-5a0e9f7e361d/go.mod h1:MsM/5czONyXMJ3PRr5DbQ4O/BxzAnJWOIcJdLzW6qHY=
github.com/metacubex/ascon v0.1.0 h1:6ZWxmXYszT1XXtwkf6nxfFhc/OTtQ9R3Vyj1jN32lGM=
Expand Down
13 changes: 12 additions & 1 deletion core/src/main/golang/native/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,15 @@ func writeOverride(slot C.int, content C.c_string) {
//export clearOverride
func clearOverride(slot C.int) {
config.ClearOverride(config.OverrideSlot(slot))
}
}

//export setAgeSecretKey
func setAgeSecretKey(key C.c_string) {
if key == nil {
config.SetGlobalSecretKeys()
return
}

k := C.GoString(key)
config.SetGlobalSecretKeys(k)
}
7 changes: 7 additions & 0 deletions core/src/main/golang/native/config/age.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package config

import "github.com/metacubex/mihomo/component/age"

func SetGlobalSecretKeys(secretKeys ...string) {
age.SetGlobalSecretKeys(secretKeys...)
}
4 changes: 4 additions & 0 deletions core/src/main/java/com/github/kr328/clash/core/Clash.kt
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,8 @@ object Clash {
})
}
}

fun setAgeSecretKey(key: String?) {
Bridge.nativeSetAgeSecretKey(key)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ object Bridge {
external fun nativeSubscribeLogcat(callback: LogcatInterface)
external fun nativeCoreVersion(): String

external fun nativeSetAgeSecretKey(key: String?)

private external fun nativeInit(home: String, versionName: String, sdkVersion: Int)

init {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ data class Proxy(
RejectDrop(false),
Compatible(false),
Pass(false),
PassRule(false),

Shadowsocks(false),
ShadowsocksR(false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,23 @@ class PropertiesDesign(context: Context) : Design<PropertiesDesign.Request>(cont
}
}

fun inputAgeSecretKey() {
launch {
val ageSecretKey = context.requestModelTextInput(
initial = profile.ageSecretKey ?: "",
title = context.getText(R.string.age_secret_key),
hint = context.getText(R.string.age_secret_key_hint),
error = context.getText(R.string.age_secret_key_error),
validator = ValidatorAgeSecretKey
)

val newKey = ageSecretKey.ifBlank { null }
if (newKey != profile.ageSecretKey) {
profile = profile.copy(ageSecretKey = newKey)
}
}
}

fun inputInterval() {
launch {
var minutes = TimeUnit.MILLISECONDS.toMinutes(profile.interval)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ val ValidatorHttpUrl: Validator = {

val ValidatorAutoUpdateInterval: Validator = {
it.isEmpty() || (it.toLongOrNull() ?: 0) >= 15
}

val ValidatorAgeSecretKey: Validator = {
it.isEmpty() || it.startsWith("AGE-SECRET-KEY-", ignoreCase = true)
}
10 changes: 10 additions & 0 deletions design/src/main/res/drawable/ic_baseline_key.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M21,10h-8.35C11.83,7.67 9.61,6 7,6c-3.31,0 -6,2.69 -6,6s2.69,6 6,6c2.61,0 4.83,-1.67 5.65,-4H13l2,2l2,-2l2,2l4,-4.04L21,10zM7,15c-1.65,0 -3,-1.35 -3,-3c0,-1.65 1.35,-3 3,-3s3,1.35 3,3C10,13.65 8.65,15 7,15z" />
</vector>
10 changes: 10 additions & 0 deletions design/src/main/res/layout/design_properties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@
app:text="@{profile.source}"
app:title="@string/url" />

<com.github.kr328.clash.design.view.ActionTextField
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginVertical="@dimen/properties_element_margin_vertical"
android:onClick="@{() -> self.inputAgeSecretKey()}"
app:icon="@drawable/ic_baseline_key"
app:placeholder="@string/age_secret_key_hint"
app:text="@{profile.ageSecretKey}"
app:title="@string/age_secret_key" />

<com.github.kr328.clash.design.view.ActionTextField
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
5 changes: 4 additions & 1 deletion design/src/main/res/values-ja-rJP/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
<string name="accept_http_content">http(s) のみを許可</string>
<string name="at_least_15_minutes">15分以上か空白にしてください</string>
<string name="should_not_be_blank">空白にはできません</string>
<string name="age_secret_key">Age 秘密鍵</string>
<string name="age_secret_key_hint">AGE-SECRET-KEY-… (任意)</string>
<string name="age_secret_key_error">形式が無効です。キーは AGE-SECRET-KEY- で始まる必要があります</string>
<string name="detail">詳細</string>
<string name="update">更新</string>
<string name="edit">編集</string>
Expand Down Expand Up @@ -253,4 +256,4 @@
<string name="override_destination">Override Destination</string>
<string name="import_from_qr_no_permission">カメラのアクセスが制限されています。設定から有効にしてください。</string>
<string name="import_from_qr_exception">システムで予期しない例外が発生しました。</string>
</resources>
</resources>
5 changes: 4 additions & 1 deletion design/src/main/res/values-ko-rKR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
<string name="accept_http_content">http(s) 연결만 허용</string>
<string name="at_least_15_minutes">최소 15분 이상 또는 공백</string>
<string name="should_not_be_blank">이 필드는 공백이 허용되지 않습니다.</string>
<string name="age_secret_key">Age 비밀 키</string>
<string name="age_secret_key_hint">AGE-SECRET-KEY-… (선택 사항)</string>
<string name="age_secret_key_error">형식이 올바르지 않습니다. 키는 AGE-SECRET-KEY-로 시작해야 합니다</string>
<string name="detail">자세히</string>
<string name="update">업데이트</string>
<string name="edit">편집</string>
Expand Down Expand Up @@ -253,4 +256,4 @@
<string name="override_destination">Override Destination</string>
<string name="import_from_qr_no_permission">카메라 접근이 제한되었습니다. 설정에서 허용해 주세요.</string>
<string name="import_from_qr_exception">처리되지 않은 시스템 예외가 발생했습니다.</string>
</resources>
</resources>
Loading
Loading