diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9ee2a06..ed658b5 100755 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,5 +19,5 @@ jobs: uses: softprops/action-gh-release@v1 with: tag_name: ${{ github.ref_name }} - files: Clash_for_Magisk-v*.zip + files: Clash_for_KernelSU-v*.zip generate_release_notes: true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..383c926 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +Clash_for_KernelSU-v3.0.zip +.DS_Store \ No newline at end of file diff --git a/META-INF/com/google/android/update-binary b/META-INF/com/google/android/update-binary deleted file mode 100755 index 28b48e5..0000000 --- a/META-INF/com/google/android/update-binary +++ /dev/null @@ -1,33 +0,0 @@ -#!/sbin/sh - -################# -# Initialization -################# - -umask 022 - -# echo before loading util_functions -ui_print() { echo "$1"; } - -require_new_magisk() { - ui_print "*******************************" - ui_print " Please install Magisk v20.4+! " - ui_print "*******************************" - exit 1 -} - -######################### -# Load util_functions.sh -######################### - -OUTFD=$2 -ZIPFILE=$3 - -mount /data 2>/dev/null - -[ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk -. /data/adb/magisk/util_functions.sh -[ $MAGISK_VER_CODE -lt 20400 ] && require_new_magisk - -install_module -exit 0 diff --git a/META-INF/com/google/android/updater-script b/META-INF/com/google/android/updater-script deleted file mode 100755 index 492be83..0000000 --- a/META-INF/com/google/android/updater-script +++ /dev/null @@ -1 +0,0 @@ -#MAGISK \ No newline at end of file diff --git a/README.md b/README.md index 0c16c34..dd08a62 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Clash for Magisk +# Clash for KernelSU

- Clash + Clash
Clash

Proxy Transparan for android.

@@ -9,27 +9,24 @@
[![ANDROID](https://img.shields.io/badge/Android-3DDC84?style=for-the-badge&logo=android&logoColor=white)]() -[![RELEASES](https://img.shields.io/github/downloads/taamarin/ClashforMagisk/total.svg?style=for-the-badge)](https://github.com/taamarin/ClashforMagisk/releases) -[![TELEGRAM CHANNEL](https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white)](https://t.me/nothing_taamarin) -[![TELEGRAM](https://img.shields.io/badge/Telegram%20-Grups%20-blue?style=for-the-badge)](https://t.me/taamarin) -[![MAGISK](https://img.shields.io/badge/Magisk%20-v20.4+-brightgreen?style=for-the-badge)](https://github.com/topjohnwu/Magisk) +[![RELEASES](https://img.shields.io/github/downloads/Dreamail/ClashforKernelSU/total.svg?style=for-the-badge)](https://github.com/Dreamail/ClashforKernelSU/releases) [![API](https://img.shields.io/badge/API-19%2B-brightgreen.svg?style=for-the-badge)](https://android-arsenal.com/api?level=19) - - + +
-A fork of [ClashForMagisk](https://github.com/kalasutra/Clash_For_Magisk) +A fork of [ClashForMagisk](https://github.com/taamarin/ClashforMagisk) -This is a Clash module for Magisk, and includes binaries for arm, arm64, x86, x64. +This is a Clash module for KernelSU, and includes binaries for arm, arm64. -## Manager Apps CFM +## Manager Apps - [ClashForMagisk_Manager](https://t.me/taamarin/26137) EN - [ClashForMagisk_Manager](https://t.me/MagiskChangeKing/159) CN ## Install -You can download the release [installer zip](https://github.com/taamarin/ClashforMagisk/releases) file and install it via the Magisk Manager App. +You can download the release [installer zip](https://github.com/Dreamail/ClashforKernelSU/releases) file and install it via the KernelSU manager App. #### Config - Clash config files `/data/clash/*` @@ -43,7 +40,7 @@ You can download the release [installer zip](https://github.com/taamarin/Clashfo ### Normal usage ( Default and Recommended ) ##### Manage service start / stop - Clash service is auto-run after system boot up by default. -- You can use Magisk Manager App to manage it. Be patient to wait it take effect (about 3 second). +- You can use KernelSU manager App to manage it. Be patient to wait it take effect (about 3 second). ### Advanced usage > MODDIR= "/data/clash" @@ -51,10 +48,10 @@ You can download the release [installer zip](https://github.com/taamarin/Clashfo ##### Change proxy mode - Clash uses `TPROXY` transparent proxy `TCP + UDP` by default, if it detects that the device does not support `TPROXY`, it will automatically use `REDIRECT` to proxy only `TCP` -- Open `${MODDIR}/scripts/clash.config` file line [14-15](https://github.com/taamarin/ClashforMagisk/blob/master/scripts/clash.config#L14-#L15), modify the value of `network_mode` to `TCP` or `MIXED `to use `REDIRECT` to proxy `TCP`, and `UDP` will not be proxied when `TUN` is not enabled in the Clash kernel +- Open `${MODDIR}/scripts/clash.config` file line [14-15](https://github.com/Dreamail/ClashforKernelSU/blob/master/scripts/clash.config#L14-#L15), modify the value of `network_mode` to `TCP` or `MIXED `to use `REDIRECT` to proxy `TCP`, and `UDP` will not be proxied when `TUN` is not enabled in the Clash kernel ##### Bypass transparent proxy when connected to Wi-Fi or open a hotspot -Clash default transparent proxy local and hotspot, line [17-21](https://github.com/taamarin/ClashforMagisk/blob/master/scripts/clash.config#L17-#L21) +Clash default transparent proxy local and hotspot, line [17-21](https://github.com/Dreamail/ClashforKernelSU/blob/master/scripts/clash.config#L17-#L21) - Open the `${MODDIR}/scripts/clash.config` file, modify the `ignore_out_list` array and add the `wlan+` element, the transparent proxy will `bypass` the `WLAN`, and the hotspot will not be affected @@ -62,7 +59,7 @@ Clash default transparent proxy local and hotspot, line [17-21](https://github.c ##### Select which packages to proxy - If you expect all Apps proxy by Clash with transparent proxy EXCEPT specific Apps, write down bypass at the first line then these Apps' packages separated as above in file `/data/clash/packages.list` -- clash.config line [11-12](https://github.com/taamarin/ClashforMagisk/blob/master/scripts/clash.config#L11-#L12) +- clash.config line [11-12](https://github.com/Dreamail/ClashforKernelSU/blob/master/scripts/clash.config#L11-#L12) - `blacklist` & `whitelits`, not working on `fake-ip` - dns: @@ -87,7 +84,7 @@ Clash default transparent proxy local and hotspot, line [17-21](https://github.c ##### subscription you can use SubScription -- open `/data/clash/clash.config` line [29-34](https://github.com/taamarin/ClashforMagisk/blob/master/scripts/clash.config#L29-#L34) +- open `/data/clash/clash.config` line [29-34](https://github.com/Dreamail/ClashforKernelSU/blob/master/scripts/clash.config#L29-#L34) - update_interval="interval contab" - Subcript_url="your_link" - auto_updateSubcript="true" @@ -98,7 +95,7 @@ ${MODDIR}/scripts/clash.tool -s ``` ##### Config Online -- **clash.config** line [36-37](https://github.com/taamarin/ClashforMagisk/blob/master/scripts/clash.config#L36-#L37), If true, +- **clash.config** line [36-37](https://github.com/Dreamail/ClashforKernelSU/blob/master/scripts/clash.config#L36-#L37), If true, - use it to download the subscription configuration, when starting Clash , So no need to type `${MODDIR}/scripts/clash.tool -s` anymore ##### Change Clash kernel @@ -108,28 +105,26 @@ You can use Clash.Premium and Clash.Meta - Clash Premium - `/data/clash/kernel/lib/Clash.Premium` -you can download the Kernel automatically, for the settings in the **clash.config** line [79-103](https://github.com/taamarin/ClashforMagisk/blob/master/scripts/clash.config#L79-#L103) +you can download the Kernel automatically, for the settings in the **clash.config** line [79-103](https://github.com/Dreamail/ClashforKernelSU/blob/master/scripts/clash.config#L79-#L103) ```shell ${MODDIR}/scripts/clash.tool -k ``` ##### GeoSite, GeoIP, and Mmdb -- settings are in clash.config line [105-116](https://github.com/taamarin/ClashforMagisk/blob/master/scripts/clash.config#L105-#L116) +- settings are in clash.config line [105-116](https://github.com/Dreamail/ClashforKernelSU/blob/master/scripts/clash.config#L105-#L116) - if true, will be updated every day at 00.00 - you can change the URL ## Uninstall -- Uninstall the module via Magisk Manager App. +- Uninstall the module via KernelSU manager App. - You can clean Clash data dir by running command ```shell -rm -rf /data/clash && rm -rf /data/adb/service.d/clash_service.sh +rm -rf /data/clash ``` -## Tutorial Clash For Magisk - > Tutorial [Tap Here](https://telegra.ph/%F0%9D%93%92%F0%9D%93%B5%F0%9D%93%AA%F0%9D%93%BC%F0%9D%93%B1%F0%9D%93%95%F0%9D%93%B8%F0%9D%93%BB%F0%9D%93%9C%F0%9D%93%AA%F0%9D%93%B0%F0%9D%93%B2%F0%9D%93%BC%F0%9D%93%B4-11-28) - ## Credits This is a repo fork + - [taamarin/ClashforMagisk](https://github.com/taamarin/ClashforMagisk) - [kalasutra/Clash_for_magisk](https://github.com/kalasutra/Clash_For_Magisk) - [CHIZI-0618/box4magisk](https://github.com/CHIZI-0618/box4magisk) - [Asterisk4Magisk/Xray4Magisk](https://github.com/Asterisk4Magisk/Xray4Magisk) diff --git a/binary/arm.tar.bz2 b/binary/arm.tar.bz2 index 23a39ef..1978e14 100755 Binary files a/binary/arm.tar.bz2 and b/binary/arm.tar.bz2 differ diff --git a/binary/arm64.tar.bz2 b/binary/arm64.tar.bz2 index d63d7aa..694fb29 100755 Binary files a/binary/arm64.tar.bz2 and b/binary/arm64.tar.bz2 differ diff --git a/binary/x64.tar.bz2 b/binary/x64.tar.bz2 deleted file mode 100755 index 0a63f98..0000000 Binary files a/binary/x64.tar.bz2 and /dev/null differ diff --git a/binary/x86.tar.bz2 b/binary/x86.tar.bz2 deleted file mode 100755 index f220bb9..0000000 Binary files a/binary/x86.tar.bz2 and /dev/null differ diff --git a/build.sh b/build.sh index dcaee51..e592ee2 100755 --- a/build.sh +++ b/build.sh @@ -1,3 +1,3 @@ #!/bin/sh -zip -r -o -X -ll Clash_for_Magisk-$(cat module.prop | grep 'version=' | awk -F '=' '{print $2}').zip ./ -x '.git/*' -x 'build.sh' -x 'docs/*' -x 'CHANGELOG.md' -x 'README.md' -x 'update.json' -x '.github/*' \ No newline at end of file +zip -r -o -X -ll Clash_for_KernelSU-$(cat module.prop | grep 'version=' | awk -F '=' '{print $2}').zip ./ -x '.git/*' -x 'build.sh' -x 'docs/*' -x 'CHANGELOG.md' -x 'README.md' -x 'update.json' -x '.github/*' \ No newline at end of file diff --git a/customize.sh b/customize.sh index eb05644..8f94976 100755 --- a/customize.sh +++ b/customize.sh @@ -6,32 +6,27 @@ architecture="" uid="0" gid="3005" clash_data_dir="/data/clash" -modules_dir="/data/adb/modules" +modules_dir="/data/adb/ksu/modules" bin_path="/system/bin/" dns_path="/system/etc" -clash_adb_dir="/data/adb" -clash_service_dir="/data/adb/service.d" -busybox_data_dir="/data/adb/magisk/busybox" ca_path="${dns_path}/security/cacerts" clash_data_dir_kernel="${clash_data_dir}/kernel" +clash_data_dir_tools="${clash_data_dir}/tools" clash_data_sc="${clash_data_dir}/scripts" mod_config="${clash_data_sc}/clash.config" yacd_dir="${clash_data_dir}/dashboard" latest=$(date +%Y%m%d%H%M) if $BOOTMODE; then - ui_print "- Installing from Magisk app" + ui_print "- Installing from KernelSU manager" else ui_print "*********************************************************" ui_print "! Install from recovery is NOT supported" ui_print "! Some recovery has broken implementations, install with such recovery will finally cause CFM modules not working" - ui_print "! Please install from Magisk app" + ui_print "! Please install from KernelSU manager" abort "*********************************************************" fi -# check Magisk -ui_print "- Magisk version: $MAGISK_VER ($MAGISK_VER_CODE)" - # check android if [ "$API" -lt 19 ]; then ui_print "! Unsupported sdk: $API" @@ -47,7 +42,7 @@ else ui_print "- Device platform: $ARCH" fi -ui_print "- Installing Clash for Magisk" +ui_print "- Installing Clash for KernelSU" if [ -d "${clash_data_dir}" ] ; then ui_print "- Backup Clash" @@ -63,6 +58,7 @@ fi ui_print "- Create folder Clash." mkdir -p ${clash_data_dir} mkdir -p ${clash_data_dir_kernel} +mkdir -p ${clash_data_dir_tools} mkdir -p ${MODPATH}${ca_path} mkdir -p ${clash_data_dir}/dashboard mkdir -p ${MODPATH}/system/bin @@ -99,11 +95,6 @@ ui_print "- Move Cert&Geo" mv ${clash_data_dir}/scripts/cacert.pem ${MODPATH}${ca_path} mv ${MODPATH}/geo/* ${clash_data_dir}/ -if [ ! -d /data/adb/service.d ] ; then - ui_print "- Make folder service" - mkdir -p /data/adb/service.d -fi - ui_print "- Create resolv.conf" if [ ! -f "${dns_path}/resolv.conf" ] ; then touch ${MODPATH}${dns_path}/resolv.conf @@ -120,7 +111,6 @@ fi unzip -j -o "${ZIPFILE}" 'service.sh' -d ${MODPATH} >&2 unzip -j -o "${ZIPFILE}" 'uninstall.sh' -d ${MODPATH} >&2 -unzip -j -o "${ZIPFILE}" 'clash_service.sh' -d ${clash_service_dir} >&2 ui_print "- Extract binary-$ARCH " tar -xjf ${MODPATH}/binary/${ARCH}.tar.bz2 -C ${clash_data_dir_kernel}/&& echo "- extar kernel Succes" || echo "- extar kernel gagal" @@ -129,6 +119,7 @@ mv ${clash_data_dir_kernel}/getpcaps ${MODPATH}${bin_path}/ mv ${clash_data_dir_kernel}/getcap ${MODPATH}${bin_path}/ mv ${clash_data_dir}/scripts/clash.config ${clash_data_dir}/ mv ${clash_data_dir}/scripts/dnstt/dnstt-client ${clash_data_dir_kernel}/ +mv ${clash_data_dir_kernel}/busybox ${clash_data_dir_tools}/ if [ ! -f "${bin_path}/ss" ] ; then mv ${clash_data_dir_kernel}/ss ${MODPATH}${bin_path}/ @@ -140,7 +131,6 @@ rm -rf ${MODPATH}/dashboard.zip rm -rf ${MODPATH}/scripts rm -rf ${MODPATH}/geo rm -rf ${MODPATH}/binary -rm -rf ${MODPATH}/clash_service.sh rm -rf ${clash_data_dir}/scripts/config.yaml rm -rf ${clash_data_dir}/scripts/dnstt rm -rf ${clash_data_dir_kernel}/curl @@ -149,7 +139,6 @@ sleep 1 ui_print "- Set Permissons" set_perm_recursive ${MODPATH} 0 0 0755 0644 -set_perm_recursive ${clash_service_dir} 0 0 0755 0755 set_perm_recursive ${clash_data_dir} ${uid} ${gid} 0755 0644 set_perm_recursive ${clash_data_dir}/scripts ${uid} ${gid} 0755 0755 set_perm_recursive ${clash_data_dir}/kernel ${uid} ${gid} 0755 0755 @@ -172,6 +161,6 @@ set_perm ${clash_data_dir}/scripts/start.sh 0 0 0755 set_perm ${clash_data_dir}/scripts/usage.sh 0 0 0755 set_perm ${clash_data_dir}/clash.config ${uid} ${gid} 0755 set_perm ${clash_data_dir}/kernel/dnstt-client 0 0 0755 -set_perm ${clash_service_dir}/clash_service.sh 0 0 0755 +set_perm ${clash_data_dir}/tools/busybox 0 0 0755 sleep 1 ui_print "- Installation is complete, reboot your device" diff --git a/module.prop b/module.prop index 04b5bcb..f8e2334 100755 --- a/module.prop +++ b/module.prop @@ -1,7 +1,7 @@ -id=ClashForMagisk -name=Clash for Magisk +id=ClashForKernelSU +name=Clash for KernelSU version=v3.0 versionCode=20230113 -author=t🌸amarin +author=t🌸amarin,Dreamail description= Use iptables to support Clash's transparent proxy. Hey, damn half-crippled Android!!! -updateJson=https://github.com/taamarin/ClashforMagisk/raw/master/update.json \ No newline at end of file +#updateJson=https://github.com/taamarin/ClashforMagisk/raw/master/update.json \ No newline at end of file diff --git a/scripts/clash.config b/scripts/clash.config index 823fbb8..5dbccef 100755 --- a/scripts/clash.config +++ b/scripts/clash.config @@ -2,7 +2,7 @@ # busybox path now=$(date +"%I.%M %p") -busybox_path="/data/adb/magisk/busybox" +busybox_path="/data/clash/tools/busybox" ipv6=$(grep "ipv6" /data/clash/template | ${busybox_path} awk -F ': ' '{print $2}' | head -1) run_usage="false" diff --git a/scripts/clash.service b/scripts/clash.service index 45014d2..35eedf4 100755 --- a/scripts/clash.service +++ b/scripts/clash.service @@ -152,7 +152,7 @@ start_clash() { replace_kernel echo $(date) > ${CFM_logs_file} echo "$(${Clash_bin_path} -v)" >> ${CFM_logs_file} - echo "Clash for Magisk v3.0" > /dev/null + echo "Clash for KernelSU v3.0" > /dev/null echo "CPU: % | RES: kb" >> ${CFM_logs_file} echo "━━━━━━━━━━━━━━━━━━━━━━━━━" >> ${CFM_logs_file} if [ "${ipv6}" = "false" ] ; then diff --git a/scripts/clash.tool b/scripts/clash.tool index 6ea231e..41ffb4a 100755 --- a/scripts/clash.tool +++ b/scripts/clash.tool @@ -35,8 +35,8 @@ update_file() { if [ -f ${file} ] ; then mv -f ${file} ${file_bak} fi - echo "/data/adb/magisk/busybox wget --no-check-certificate ${update_url} -o ${file}" - /data/adb/magisk/busybox wget --no-check-certificate ${update_url} -O ${file} 2>&1 + echo "${busybox_path} wget --no-check-certificate ${update_url} -o ${file}" + ${busybox_path} wget --no-check-certificate ${update_url} -O ${file} 2>&1 sleep 0.5 if [ -f "${file}" ] ; then echo "" @@ -110,7 +110,7 @@ port_detection() { update_kernel() { if [ "${use_premium}" == "false" ] ; then if [ "${meta_alpha}" == "false" ] ; then - tag_meta=$(/data/adb/magisk/busybox wget --no-check-certificate -qO- ${url_meta} | grep -oE "v[0-9]+\.[0-9]+\.[0-9]+" | head -1) + tag_meta=$(${busybox_path} wget --no-check-certificate -qO- ${url_meta} | grep -oE "v[0-9]+\.[0-9]+\.[0-9]+" | head -1) filename="${file_kernel}-${platform}-${arch}-${tag_meta}" update_file "${Clash_data_dir}/${file_kernel}.gz" "${url_meta}/download/${tag_meta}/${filename}.gz" if [ "$?" = "0" ] @@ -118,7 +118,7 @@ update_kernel() { flag=false fi else - tag_meta=$(/data/adb/magisk/busybox wget --no-check-certificate -qO- ${url_meta}/expanded_assets/${tag} | grep -oE "${tag_name}" | head -1) + tag_meta=$(${busybox_path} wget --no-check-certificate -qO- ${url_meta}/expanded_assets/${tag} | grep -oE "${tag_name}" | head -1) filename="${file_kernel}-${platform}-${arch}-${tag_meta}" update_file "${Clash_data_dir}/${file_kernel}.gz" "${url_meta}/download/${tag}/${filename}.gz" if [ "$?" = "0" ] @@ -127,7 +127,7 @@ update_kernel() { fi fi else - filename=$(/data/adb/magisk/busybox wget --no-check-certificate -qO- "${url_premium}/expanded_assets/premium" | grep -oE "clash-${platform}-${arch}-[0-9]+.[0-9]+.[0-9]+" | head -1) + filename=$(${busybox_path} wget --no-check-certificate -qO- "${url_premium}/expanded_assets/premium" | grep -oE "clash-${platform}-${arch}-[0-9]+.[0-9]+.[0-9]+" | head -1) update_file "${Clash_data_dir}/${file_kernel}.gz" "${url_premium}/download/premium/${filename}.gz" if [ "$?" = "0" ] ; then flag=false @@ -198,7 +198,7 @@ update_dashboard () { file_dasboard="${Clash_data_dir}/dashboard.zip" rm -rf ${Clash_data_dir}/dashboard/dist - /data/adb/magisk/busybox wget --no-check-certificate ${url_dashboard} -o ${file_dasboard} 2>&1 + ${busybox_path} wget --no-check-certificate ${url_dashboard} -o ${file_dasboard} 2>&1 unzip -o "${file_dasboard}" "yacd-gh-pages/*" -d ${Clash_data_dir}/dashboard >&2 mv -f ${Clash_data_dir}/dashboard/yacd-gh-pages ${Clash_data_dir}/dashboard/dist rm -rf ${file_dasboard} diff --git a/scripts/start.sh b/scripts/start.sh index c310577..6157dd1 100755 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -1,13 +1,9 @@ #!/system/bin/sh -moddir="/data/adb/modules/ClashForMagisk" -if [ -n "$(magisk -v | grep lite)" ] -then - moddir=/data/adb/lite_modules/ClashForMagisk -fi +moddir="/data/adb/ksu/modules/ClashForKernelSU" scripts_dir="/data/clash/scripts" -busybox_path="/data/adb/magisk/busybox" +busybox_path="/data/clash/tools/busybox" Clash_run_path="/data/clash/run" Clash_pid_file="${Clash_run_path}/clash.pid" diff --git a/scripts/usage.sh b/scripts/usage.sh index 864153f..116cb88 100755 --- a/scripts/usage.sh +++ b/scripts/usage.sh @@ -1,8 +1,10 @@ #!/system/bin/sh +busybox_path="/data/clash/tools/busybox" + getmemory(){ local clash_pid=$(cat /data/clash/run/clash.pid) - clash_alive=$(grep VmRSS /proc/${clash_pid}/status | /data/adb/magisk/busybox awk -F':' '{print $2}' | /data/adb/magisk/busybox awk '{print $1}') + clash_alive=$(grep VmRSS /proc/${clash_pid}/status | ${busybox_path} awk -F':' '{print $2}' | ${busybox_path} awk '{print $1}') if [ ${clash_alive} -ge 1024 ] ; then clash_res="$(expr ${clash_alive} / 1024)Mb" else diff --git a/clash_service.sh b/service.sh similarity index 100% rename from clash_service.sh rename to service.sh diff --git a/uninstall.sh b/uninstall.sh index 0f72b48..4ee9c14 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -2,7 +2,6 @@ Clash_data_dir="/data/clash" rm_data() { rm -rf ${Clash_data_dir} - rm -rf /data/adb/service.d/clash_service.sh } rm_data