Compare commits
70 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8282a9a474 | ||
|
|
dfa6d31673 | ||
|
|
89bbbc6864 | ||
|
|
a3e1b38201 | ||
|
|
4e3dc45f13 | ||
|
|
13d31cf708 | ||
|
|
62a7772b92 | ||
|
|
043648f998 | ||
|
|
3eb26e8061 | ||
|
|
5d6bd6466f | ||
|
|
4e766d9407 | ||
|
|
80f8aa22ee | ||
|
|
97714e8b25 | ||
|
|
50bf4170d9 | ||
|
|
79efa67df3 | ||
|
|
ac397393a0 | ||
|
|
b685165230 | ||
|
|
402221aaa2 | ||
|
|
f6d9ed11d9 | ||
|
|
c38a671d57 | ||
|
|
75af47aead | ||
|
|
8dafe3b0ec | ||
|
|
813198a21d | ||
|
|
68dd262fef | ||
|
|
5ef020db73 | ||
|
|
e3c9035903 | ||
|
|
7fc54c5295 | ||
|
|
00a78b5fb4 | ||
|
|
8cdaf30de0 | ||
|
|
f39b9cf933 | ||
|
|
9df1ff46c2 | ||
|
|
fcbbbdc698 | ||
|
|
3ba8355772 | ||
|
|
f6b97f82ae | ||
|
|
13ac20f273 | ||
|
|
6de89d7de4 | ||
|
|
c36df8cb4a | ||
|
|
530817b268 | ||
|
|
721dd20251 | ||
|
|
f2aa8851ae | ||
|
|
ec2890cab2 | ||
|
|
ca946c1b06 | ||
|
|
3bc3172723 | ||
|
|
82be4cc45f | ||
|
|
2c3f4ae8a8 | ||
|
|
891977408e | ||
|
|
5292f34e8d | ||
|
|
1c54db6bf3 | ||
|
|
a4b5f4abdb | ||
|
|
aa4ffbe4fb | ||
|
|
3d25298639 | ||
|
|
1765576d09 | ||
|
|
2dd45062f1 | ||
|
|
c6407984ac | ||
|
|
53af86238e | ||
|
|
b20d9edec2 | ||
|
|
5c3a0c576d | ||
|
|
6dcb466fd3 | ||
|
|
acbcec358b | ||
|
|
a923549ddf | ||
|
|
07bd21580b | ||
|
|
57ceb64a5e | ||
|
|
713e83d9d8 | ||
|
|
5e3b0e4929 | ||
|
|
0389b6eb29 | ||
|
|
8f22cbf746 | ||
|
|
1fcc412770 | ||
|
|
afa1b4f424 | ||
|
|
fa67940ec9 | ||
|
|
90bb670442 |
57
.github/release_template.md
vendored
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<div align=center>
|
||||||
|
|
||||||
|
[](https://img.shields.io/github/downloads/chen08209/FlClash/vVERSION/)
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
**Download based on your OS:**
|
||||||
|
|
||||||
|
<div align=left>
|
||||||
|
<table>
|
||||||
|
<thead align=left>
|
||||||
|
<tr>
|
||||||
|
<th>OS</th>
|
||||||
|
<th>Download</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody align=left>
|
||||||
|
<tr>
|
||||||
|
<td>Android</td>
|
||||||
|
<td>
|
||||||
|
<a href="https://github.com/chen08209/FlClash/releases/download/vVERSION/FlClash-VERSION-android-arm64-v8a.apk"><img src="https://img.shields.io/badge/APK-ARMv8-168039.svg?logo=android"></a><br>
|
||||||
|
<a href="https://github.com/chen08209/FlClash/releases/download/vVERSION/FlClash-VERSION-android-armeabi-v7a.apk"><img src="https://img.shields.io/badge/APK-ARMv7-45bf55.svg?logo=android"></a><br>
|
||||||
|
<a href="https://github.com/chen08209/FlClash/releases/download/vVERSION/FlClash-VERSION-android-x86_64.apk"><img src="https://img.shields.io/badge/APK-x64-96ed89.svg?logo=android"></a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Windows</td>
|
||||||
|
<td>
|
||||||
|
<a href="https://github.com/chen08209/FlClash/releases/download/vVERSION/FlClash-VERSION-windows-amd64-setup.exe"><img src="https://img.shields.io/badge/Setup-x64-2d7d9a.svg?logo=windows"></a><br>
|
||||||
|
<a href="https://github.com/chen08209/FlClash/releases/download/vVERSION/FlClash-VERSION-windows-amd64.zip"><img src="https://img.shields.io/badge/Portable-x64-67b7d1.svg?logo=windows"></a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>macOS (v10.15+)</td>
|
||||||
|
<td>
|
||||||
|
<a href="https://github.com/chen08209/FlClash/releases/download/vVERSION/FlClash-VERSION-macos-amd64.dmg"><img src="https://img.shields.io/badge/DMG-Universal-ea005e.svg?logo=apple"></a><br>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Linux</td>
|
||||||
|
<td>
|
||||||
|
<a href="https://github.com/chen08209/FlClash/releases/download/vVERSION/FlClash-VERSION-linux-amd64.AppImage"><img src="https://img.shields.io/badge/AppImage-x64-f84e29.svg?logo=linux"> </a><br>
|
||||||
|
<a href="https://github.com/chen08209/FlClash/releases/download/vVERSION/FlClash-VERSION-linux-amd64.deb"><img src="https://img.shields.io/badge/DebPackage-x64-FF9966.svg?logo=debian"> </a><br>
|
||||||
|
<a href="https://github.com/chen08209/FlClash/releases/download/vVERSION/FlClash-VERSION-linux-amd64.deb"><img src="https://img.shields.io/badge/RpmPackage-x64-F1B42F.svg?logo=redhat"> </a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div dir="ltr">
|
||||||
|
|
||||||
|
**List of all changes:** [ChangeLog](https://github.com/chen08209/FlClash/blob/main/CHANGELOG.md)
|
||||||
|
|
||||||
|
</div>
|
||||||
200
.github/workflows/build.yaml
vendored
Normal file
@@ -0,0 +1,200 @@
|
|||||||
|
name: build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- platform: android
|
||||||
|
os: ubuntu-latest
|
||||||
|
- platform: windows
|
||||||
|
os: windows-latest
|
||||||
|
arch: amd64
|
||||||
|
- platform: linux
|
||||||
|
os: ubuntu-latest
|
||||||
|
arch: amd64
|
||||||
|
- platform: macos
|
||||||
|
os: macos-13
|
||||||
|
arch: amd64
|
||||||
|
- platform: macos
|
||||||
|
os: macos-latest
|
||||||
|
arch: arm64
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Setup Mingw64
|
||||||
|
if: startsWith(matrix.platform,'windows')
|
||||||
|
uses: msys2/setup-msys2@v2
|
||||||
|
with:
|
||||||
|
msystem: mingw64
|
||||||
|
install: mingw-w64-x86_64-gcc
|
||||||
|
update: true
|
||||||
|
|
||||||
|
- name: Set Mingw64 Env
|
||||||
|
if: startsWith(matrix.platform,'windows')
|
||||||
|
run: |
|
||||||
|
echo "${{ runner.temp }}\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||||
|
|
||||||
|
- name: Check Matrix
|
||||||
|
run: |
|
||||||
|
echo "Running on ${{ matrix.os }}"
|
||||||
|
echo "Arch: ${{ runner.arch }}"
|
||||||
|
gcc --version
|
||||||
|
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Setup JAVA
|
||||||
|
if: startsWith(matrix.platform,'android')
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: 'zulu'
|
||||||
|
java-version: 17
|
||||||
|
|
||||||
|
- name: Setup NDK
|
||||||
|
if: startsWith(matrix.platform,'android')
|
||||||
|
uses: nttld/setup-ndk@v1
|
||||||
|
id: setup-ndk
|
||||||
|
with:
|
||||||
|
ndk-version: r26b
|
||||||
|
add-to-path: true
|
||||||
|
link-to-sdk: true
|
||||||
|
|
||||||
|
- name: Setup Android Signing
|
||||||
|
if: startsWith(matrix.platform,'android')
|
||||||
|
run: |
|
||||||
|
echo "${{ secrets.KEYSTORE }}" | base64 --decode > android/app/keystore.jks
|
||||||
|
echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> android/local.properties
|
||||||
|
echo "storePassword=${{ secrets.STORE_PASSWORD }}" >> android/local.properties
|
||||||
|
echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> android/local.properties
|
||||||
|
|
||||||
|
|
||||||
|
- name: Setup Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version-file: 'core/go.mod'
|
||||||
|
cache-dependency-path: |
|
||||||
|
core/go.sum
|
||||||
|
|
||||||
|
- name: Setup Flutter
|
||||||
|
uses: subosito/flutter-action@v2
|
||||||
|
with:
|
||||||
|
flutter-version: '3.x'
|
||||||
|
channel: 'stable'
|
||||||
|
cache: true
|
||||||
|
|
||||||
|
- name: Get Flutter Dependency
|
||||||
|
run: flutter pub get
|
||||||
|
|
||||||
|
- name: Setup
|
||||||
|
run: dart setup.dart ${{ matrix.platform }} ${{ matrix.arch && format('--arch {0}', matrix.arch) }}
|
||||||
|
|
||||||
|
- name: Upload
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: artifact-${{ matrix.platform }}${{ matrix.arch && format('-{0}', matrix.arch) }}
|
||||||
|
path: ./dist
|
||||||
|
overwrite: true
|
||||||
|
|
||||||
|
|
||||||
|
upload:
|
||||||
|
permissions: write-all
|
||||||
|
needs: [ build ]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
services:
|
||||||
|
telegram-bot-api:
|
||||||
|
image: aiogram/telegram-bot-api:latest
|
||||||
|
env:
|
||||||
|
TELEGRAM_API_ID: ${{ secrets.TELEGRAM_API_ID }}
|
||||||
|
TELEGRAM_API_HASH: ${{ secrets.TELEGRAM_API_HASH }}
|
||||||
|
ports:
|
||||||
|
- 8081:8081
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Download
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
path: ./dist/
|
||||||
|
pattern: artifact-*
|
||||||
|
merge-multiple: true
|
||||||
|
|
||||||
|
- name: Generate release.md
|
||||||
|
run: |
|
||||||
|
tags=($(git tag --merged $(git rev-parse HEAD) --sort=-creatordate))
|
||||||
|
preTag=$(curl --silent "https://api.github.com/repos/chen08209/FlClash/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")' || echo "")
|
||||||
|
currentTag=""
|
||||||
|
for ((i = 0; i <= ${#tags[@]}; i++)); do
|
||||||
|
if (( i < ${#tags[@]} )); then
|
||||||
|
tag=${tags[$i]}
|
||||||
|
else
|
||||||
|
tag=""
|
||||||
|
fi
|
||||||
|
if [ -n "$currentTag" ]; then
|
||||||
|
if [ "$(echo -e "$currentTag\n$preTag" | sort -V | head -n 1)" == "$currentTag" ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ -n "$currentTag" ]; then
|
||||||
|
if [ -n "$tag" ]; then
|
||||||
|
git log --pretty=format:"%B" "$tag..$currentTag" | awk 'NF {print "- " $0} !NF {print ""}' >> release.md
|
||||||
|
else
|
||||||
|
git log --pretty=format:"%B" "$currentTag" | awk 'NF {print "- " $0} !NF {print ""}' >> release.md
|
||||||
|
fi
|
||||||
|
echo "" >> release.md
|
||||||
|
fi
|
||||||
|
currentTag=$tag
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Push to telegram
|
||||||
|
env:
|
||||||
|
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
|
||||||
|
TAG: ${{ github.ref_name }}
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install requests
|
||||||
|
python release.py
|
||||||
|
|
||||||
|
- name: Patch release.md
|
||||||
|
run: |
|
||||||
|
version=$(echo "${{ github.ref_name }}" | sed 's/^v//')
|
||||||
|
sed "s|VERSION|$version|g" ./.github/release_template.md >> release.md
|
||||||
|
|
||||||
|
- name: Release
|
||||||
|
if: ${{ !contains(github.ref, '+') }}
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
files: ./dist/*
|
||||||
|
body_path: './release.md'
|
||||||
|
|
||||||
|
- name: Create Fdroid Source Dir
|
||||||
|
if: ${{ !contains(github.ref, '+') }}
|
||||||
|
run: |
|
||||||
|
mkdir -p ./tmp
|
||||||
|
cp ./dist/*android-arm64-v8a* ./tmp/ || true
|
||||||
|
echo "Files copied successfully"
|
||||||
|
|
||||||
|
- name: Push to fdroid repo
|
||||||
|
if: ${{ !contains(github.ref, '+') }}
|
||||||
|
uses: cpina/github-action-push-to-another-repository@v1.7.2
|
||||||
|
env:
|
||||||
|
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
|
||||||
|
with:
|
||||||
|
source-directory: ./tmp/
|
||||||
|
destination-github-username: chen08209
|
||||||
|
destination-repository-name: FlClash-fdroid-repo
|
||||||
|
user-name: 'github-actions[bot]'
|
||||||
|
user-email: 'github-actions[bot]@users.noreply.github.com'
|
||||||
|
target-branch: action-pr
|
||||||
|
commit-message: Update from ${{ github.ref_name }}
|
||||||
|
target-directory: /tmp/
|
||||||
124
.github/workflows/build.yml
vendored
@@ -1,124 +0,0 @@
|
|||||||
name: build
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- 'v*'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- platform: android
|
|
||||||
os: ubuntu-latest
|
|
||||||
- platform: windows
|
|
||||||
os: windows-latest
|
|
||||||
- platform: linux
|
|
||||||
os: ubuntu-latest
|
|
||||||
- platform: macos
|
|
||||||
os: macos-13
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Check Matrix
|
|
||||||
run: |
|
|
||||||
echo "Running on ${{ matrix.os }}"
|
|
||||||
echo "Arch: ${{ runner.arch }}"
|
|
||||||
gcc --version
|
|
||||||
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
|
|
||||||
- name: Setup JAVA
|
|
||||||
if: startsWith(matrix.platform,'android')
|
|
||||||
uses: actions/setup-java@v4
|
|
||||||
with:
|
|
||||||
distribution: 'zulu'
|
|
||||||
java-version: 17
|
|
||||||
|
|
||||||
- name: Setup NDK
|
|
||||||
if: startsWith(matrix.platform,'android')
|
|
||||||
uses: nttld/setup-ndk@v1
|
|
||||||
id: setup-ndk
|
|
||||||
with:
|
|
||||||
ndk-version: r26b
|
|
||||||
add-to-path: true
|
|
||||||
link-to-sdk: true
|
|
||||||
|
|
||||||
- name: Setup Android Signing
|
|
||||||
if: startsWith(matrix.platform,'android')
|
|
||||||
run: |
|
|
||||||
echo "${{ secrets.KEYSTORE }}" | base64 --decode > android/app/keystore.jks
|
|
||||||
echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> android/local.properties
|
|
||||||
echo "storePassword=${{ secrets.STORE_PASSWORD }}" >> android/local.properties
|
|
||||||
echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> android/local.properties
|
|
||||||
|
|
||||||
|
|
||||||
- name: Setup Go
|
|
||||||
uses: actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version-file: 'core/go.mod'
|
|
||||||
cache-dependency-path: |
|
|
||||||
core/go.sum
|
|
||||||
|
|
||||||
- name: Setup Flutter
|
|
||||||
uses: subosito/flutter-action@v2
|
|
||||||
with:
|
|
||||||
flutter-version: '3.x'
|
|
||||||
channel: 'stable'
|
|
||||||
cache: true
|
|
||||||
|
|
||||||
- name: Get Flutter Dependency
|
|
||||||
run: flutter pub get
|
|
||||||
|
|
||||||
- name: Setup
|
|
||||||
run: |
|
|
||||||
dart setup.dart ${{ matrix.platform }}
|
|
||||||
|
|
||||||
- name: Upload
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: artifact-${{ matrix.platform }}
|
|
||||||
path: ./dist
|
|
||||||
retention-days: 1
|
|
||||||
overwrite: true
|
|
||||||
|
|
||||||
|
|
||||||
upload-release:
|
|
||||||
if: ${{ !contains(github.ref, '+') }}
|
|
||||||
permissions: write-all
|
|
||||||
needs: [ build ]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Download
|
|
||||||
uses: actions/download-artifact@v4
|
|
||||||
with:
|
|
||||||
path: ./dist/
|
|
||||||
pattern: artifact-*
|
|
||||||
merge-multiple: true
|
|
||||||
|
|
||||||
- name: Pre Release
|
|
||||||
run: |
|
|
||||||
pip install gitchangelog pystache mustache markdown
|
|
||||||
pre=$(curl --silent "https://api.github.com/repos/chen08209/FlClash/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")' || echo "")
|
|
||||||
if [ -z "pre" ]; then
|
|
||||||
echo "init" > release.md
|
|
||||||
else
|
|
||||||
current="${{ github.ref_name }}"
|
|
||||||
echo -e "\n\n<details markdown=1><summary>All changes from $current to the latest commit:</summary>\n\n" >> release.md
|
|
||||||
gitchangelog "${pre}.." >> release.md 2>&1 || echo "Error in gitchangelog"
|
|
||||||
echo -e "\n\n</details>" >> release.md
|
|
||||||
fi
|
|
||||||
- name: Release
|
|
||||||
uses: softprops/action-gh-release@v2
|
|
||||||
with:
|
|
||||||
files: ./dist/*
|
|
||||||
body_path: './release.md'
|
|
||||||
45
.github/workflows/change.yaml
vendored
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
name: change
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'main'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
changelog:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Generate
|
||||||
|
run: |
|
||||||
|
tags=$(git tag --sort=creatordate)
|
||||||
|
previous=""
|
||||||
|
if [ ! -f CHANGELOG.md ]; then
|
||||||
|
echo "" > CHANGELOG.md
|
||||||
|
else
|
||||||
|
previous=$(grep -oP '^## \K.*' CHANGELOG.md | tail -n 1)
|
||||||
|
fi
|
||||||
|
for tag in $tags; do
|
||||||
|
if [ -n "$previous" ]; then
|
||||||
|
echo "## $tag" >> CHANGELOG.md
|
||||||
|
git log --pretty=format:"* %s (%h)" "$previous..$tag" >> CHANGELOG.md
|
||||||
|
echo -e "\n" >> CHANGELOG.md
|
||||||
|
fi
|
||||||
|
previous=$tag
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Commit
|
||||||
|
run: |
|
||||||
|
if !git diff --cached --quiet; then
|
||||||
|
git config --local user.email "action@github.com"
|
||||||
|
git config --local user.name "GitHub Action"
|
||||||
|
git add CHANGELOG.md
|
||||||
|
git commit -m "Update Changelog"
|
||||||
|
git push
|
||||||
|
fi
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
2
.gitmodules
vendored
@@ -1,7 +1,7 @@
|
|||||||
[submodule "core/Clash.Meta"]
|
[submodule "core/Clash.Meta"]
|
||||||
path = core/Clash.Meta
|
path = core/Clash.Meta
|
||||||
url = git@github.com:chen08209/Clash.Meta.git
|
url = git@github.com:chen08209/Clash.Meta.git
|
||||||
branch = FlClash
|
branch = FlClash-Alpha
|
||||||
[submodule "plugins/flutter_distributor"]
|
[submodule "plugins/flutter_distributor"]
|
||||||
path = plugins/flutter_distributor
|
path = plugins/flutter_distributor
|
||||||
url = git@github.com:chen08209/flutter_distributor.git
|
url = git@github.com:chen08209/flutter_distributor.git
|
||||||
|
|||||||
630
CHANGELOG.md
Normal file
@@ -0,0 +1,630 @@
|
|||||||
|
## v0.8.63
|
||||||
|
|
||||||
|
- Fix windows admin auto launch issues
|
||||||
|
|
||||||
|
- Add android vpn options
|
||||||
|
|
||||||
|
- Support proxies icon configuration
|
||||||
|
|
||||||
|
- Optimize android immersion display
|
||||||
|
|
||||||
|
- Fix some issues
|
||||||
|
|
||||||
|
## v0.8.62
|
||||||
|
|
||||||
|
- Optimize ip detection
|
||||||
|
|
||||||
|
- Support android vpn ipv6 inbound switch
|
||||||
|
|
||||||
|
- Support log export
|
||||||
|
|
||||||
|
- Optimize more details
|
||||||
|
|
||||||
|
- Fix android system dns issues
|
||||||
|
|
||||||
|
- Optimize dns default option
|
||||||
|
|
||||||
|
- Fix some issues
|
||||||
|
|
||||||
|
- Update readme
|
||||||
|
|
||||||
|
- Update README.md 2
|
||||||
|
|
||||||
|
- Update README.md 2
|
||||||
|
|
||||||
|
- Update README.md
|
||||||
|
|
||||||
|
## v0.8.60
|
||||||
|
|
||||||
|
- Fix build error2
|
||||||
|
|
||||||
|
- Fix build error
|
||||||
|
|
||||||
|
- Support desktop hotkey
|
||||||
|
|
||||||
|
- Support android ipv6 inbound
|
||||||
|
|
||||||
|
- Support android system dns
|
||||||
|
|
||||||
|
- fix some bugs
|
||||||
|
|
||||||
|
## v0.8.59
|
||||||
|
|
||||||
|
- Fix delete profile error
|
||||||
|
|
||||||
|
## v0.8.58
|
||||||
|
|
||||||
|
- Fix submit error 2
|
||||||
|
|
||||||
|
- Fix submit error
|
||||||
|
|
||||||
|
- Optimize DNS strategy
|
||||||
|
|
||||||
|
- Fix the problem that the tray is not displayed in some cases
|
||||||
|
|
||||||
|
- Optimize tray
|
||||||
|
|
||||||
|
- Update core
|
||||||
|
|
||||||
|
- Fix some error
|
||||||
|
|
||||||
|
## v0.8.57
|
||||||
|
|
||||||
|
- Fix tun update issues
|
||||||
|
|
||||||
|
- Add DNS override
|
||||||
|
- Fixed some bugs
|
||||||
|
- Optimize more detail
|
||||||
|
|
||||||
|
- Add Hosts override
|
||||||
|
|
||||||
|
## v0.8.56
|
||||||
|
|
||||||
|
- fix android tip error
|
||||||
|
- fix windows auto launch error
|
||||||
|
|
||||||
|
## v0.8.55
|
||||||
|
|
||||||
|
- Fix windows tray issues
|
||||||
|
|
||||||
|
- Optimize windows logic
|
||||||
|
|
||||||
|
- Optimize app logic
|
||||||
|
|
||||||
|
- Support windows administrator auto launch
|
||||||
|
|
||||||
|
- Support android close vpn
|
||||||
|
|
||||||
|
## v0.8.53
|
||||||
|
|
||||||
|
- Change flutter version
|
||||||
|
|
||||||
|
- Support profiles sort
|
||||||
|
|
||||||
|
- Support windows country flags display
|
||||||
|
|
||||||
|
- Optimize proxies page and profiles page columns
|
||||||
|
|
||||||
|
## v0.8.52
|
||||||
|
|
||||||
|
- Update flutter version
|
||||||
|
|
||||||
|
- Update version
|
||||||
|
|
||||||
|
- Update timeout time
|
||||||
|
|
||||||
|
- Update access control page
|
||||||
|
|
||||||
|
- Fix bug
|
||||||
|
|
||||||
|
## v0.8.51
|
||||||
|
|
||||||
|
- Optimize provider page
|
||||||
|
|
||||||
|
- Optimize delay test
|
||||||
|
|
||||||
|
- Support local backup and recovery
|
||||||
|
|
||||||
|
- Fix android tile service issues
|
||||||
|
|
||||||
|
## v0.8.49
|
||||||
|
|
||||||
|
- Fix linux core build error
|
||||||
|
|
||||||
|
- Add proxy-only traffic statistics
|
||||||
|
|
||||||
|
- Update core
|
||||||
|
|
||||||
|
- Optimize more details
|
||||||
|
|
||||||
|
- Merge pull request #140 from txyyh/main
|
||||||
|
|
||||||
|
- 添加自建 F-Droid 仓库相关 workflow
|
||||||
|
- Rename readme fingerprint
|
||||||
|
|
||||||
|
- Rename workflow deploy repo name
|
||||||
|
|
||||||
|
- Add download guide to README
|
||||||
|
|
||||||
|
- Add push release files to fdroid-repo
|
||||||
|
|
||||||
|
## v0.8.48
|
||||||
|
|
||||||
|
- Optimize proxies page
|
||||||
|
|
||||||
|
- Fix ua issues
|
||||||
|
|
||||||
|
- Optimize more details
|
||||||
|
|
||||||
|
## v0.8.47
|
||||||
|
|
||||||
|
- Fix windows build error
|
||||||
|
|
||||||
|
## v0.8.46
|
||||||
|
|
||||||
|
- Update app icon
|
||||||
|
|
||||||
|
- Fix desktop backup error
|
||||||
|
|
||||||
|
- Optimize request ua
|
||||||
|
|
||||||
|
- Change android icon
|
||||||
|
|
||||||
|
- Optimize dashboard
|
||||||
|
|
||||||
|
## v0.8.44
|
||||||
|
|
||||||
|
- Remove request validate certificate
|
||||||
|
|
||||||
|
- Sync core
|
||||||
|
|
||||||
|
## v0.8.43
|
||||||
|
|
||||||
|
- Fix windows error
|
||||||
|
|
||||||
|
## v0.8.42
|
||||||
|
|
||||||
|
- Fix setup.dart error
|
||||||
|
|
||||||
|
- Fix android system proxy not effective
|
||||||
|
|
||||||
|
- Add macos arm64
|
||||||
|
|
||||||
|
## v0.8.41
|
||||||
|
|
||||||
|
- Optimize proxies page
|
||||||
|
|
||||||
|
- Support mouse drag scroll
|
||||||
|
|
||||||
|
- Adjust desktop ui
|
||||||
|
|
||||||
|
- Revert "Fix android vpn issues"
|
||||||
|
|
||||||
|
- This reverts commit 891977408e6938e2acd74e9b9adb959c48c79988.
|
||||||
|
|
||||||
|
## v0.8.40
|
||||||
|
|
||||||
|
- Fix android vpn issues
|
||||||
|
|
||||||
|
- Fix android vpn issues
|
||||||
|
|
||||||
|
- Rollback partial modification
|
||||||
|
|
||||||
|
## v0.8.39
|
||||||
|
|
||||||
|
- Fix the problem that ui can't be synchronized when android vpn is occupied by an external
|
||||||
|
|
||||||
|
- Override default socksPort,port
|
||||||
|
|
||||||
|
## v0.8.38
|
||||||
|
|
||||||
|
- Fix fab issues
|
||||||
|
|
||||||
|
## v0.8.37
|
||||||
|
|
||||||
|
- Update version
|
||||||
|
|
||||||
|
- Fix the problem that vpn cannot be started in some cases
|
||||||
|
|
||||||
|
- Fix the problem that geodata url does not take effect
|
||||||
|
|
||||||
|
## v0.8.36
|
||||||
|
|
||||||
|
- Update ua
|
||||||
|
|
||||||
|
- Fix change outbound mode without check ip issues
|
||||||
|
|
||||||
|
- Separate android ui and vpn
|
||||||
|
|
||||||
|
- Fix url validate issues 2
|
||||||
|
|
||||||
|
- Add android hidden from the recent task
|
||||||
|
|
||||||
|
- Add geoip file
|
||||||
|
|
||||||
|
- Support modify geoData URL
|
||||||
|
|
||||||
|
## v0.8.35
|
||||||
|
|
||||||
|
- Fix url validate issues
|
||||||
|
|
||||||
|
- Fix check ip performance problem
|
||||||
|
|
||||||
|
- Optimize resources page
|
||||||
|
|
||||||
|
## v0.8.34
|
||||||
|
|
||||||
|
- Add ua selector
|
||||||
|
|
||||||
|
- Support modify test url
|
||||||
|
|
||||||
|
- Optimize android proxy
|
||||||
|
|
||||||
|
- Fix the error that async proxy provider could not selected the proxy
|
||||||
|
|
||||||
|
## v0.8.33
|
||||||
|
|
||||||
|
- Fix android proxy error
|
||||||
|
|
||||||
|
- Fix submit error
|
||||||
|
|
||||||
|
- Add windows tun
|
||||||
|
|
||||||
|
- Optimize android proxy
|
||||||
|
|
||||||
|
- Optimize change profile
|
||||||
|
|
||||||
|
- Update application ua
|
||||||
|
|
||||||
|
- Optimize delay test
|
||||||
|
|
||||||
|
## v0.8.32
|
||||||
|
|
||||||
|
- Fix android repeated request notification issues
|
||||||
|
|
||||||
|
## v0.8.31
|
||||||
|
|
||||||
|
- Fix memory overflow issues
|
||||||
|
|
||||||
|
## v0.8.30
|
||||||
|
|
||||||
|
- Optimize proxies expansion panel 2
|
||||||
|
|
||||||
|
- Fix android scan qrcode error
|
||||||
|
|
||||||
|
## v0.8.29
|
||||||
|
|
||||||
|
- Optimize proxies expansion panel
|
||||||
|
|
||||||
|
- Fix text error
|
||||||
|
|
||||||
|
## v0.8.28
|
||||||
|
|
||||||
|
- Optimize proxy
|
||||||
|
|
||||||
|
- Optimize delayed sorting performance
|
||||||
|
|
||||||
|
- Add expansion panel proxies page
|
||||||
|
|
||||||
|
- Support to adjust the proxy card size
|
||||||
|
|
||||||
|
- Support to adjust proxies columns number
|
||||||
|
|
||||||
|
- Fix autoRun show issues
|
||||||
|
|
||||||
|
- Fix Android 10 issues
|
||||||
|
|
||||||
|
- Optimize ip show
|
||||||
|
|
||||||
|
## v0.8.26
|
||||||
|
|
||||||
|
- Add intranet IP display
|
||||||
|
|
||||||
|
- Add connections page
|
||||||
|
|
||||||
|
- Add search in connections, requests
|
||||||
|
|
||||||
|
- Add keyword search in connections, requests, logs
|
||||||
|
|
||||||
|
- Add basic viewing editing capabilities
|
||||||
|
|
||||||
|
- Optimize update profile
|
||||||
|
|
||||||
|
## v0.8.25
|
||||||
|
|
||||||
|
- Update version
|
||||||
|
|
||||||
|
- Fix the problem of excessive memory usage in traffic usage.
|
||||||
|
|
||||||
|
- Add lightBlue theme color
|
||||||
|
|
||||||
|
- Fix start unable to update profile issues
|
||||||
|
|
||||||
|
- Fix flashback caused by process
|
||||||
|
|
||||||
|
## v0.8.23
|
||||||
|
|
||||||
|
- Add build version
|
||||||
|
|
||||||
|
- Optimize quick start
|
||||||
|
|
||||||
|
- Update system default option
|
||||||
|
|
||||||
|
## v0.8.22
|
||||||
|
|
||||||
|
- Update build.yml
|
||||||
|
|
||||||
|
- Fix android vpn close issues
|
||||||
|
|
||||||
|
- Add requests page
|
||||||
|
|
||||||
|
- Fix checkUpdate dark mode style error
|
||||||
|
|
||||||
|
- Fix quickStart error open app
|
||||||
|
|
||||||
|
- Add memory proxies tab index
|
||||||
|
|
||||||
|
- Support hidden group
|
||||||
|
|
||||||
|
- Optimize logs
|
||||||
|
|
||||||
|
- Fix externalController hot load error
|
||||||
|
|
||||||
|
## v0.8.21
|
||||||
|
|
||||||
|
- Add tcp concurrent switch
|
||||||
|
|
||||||
|
- Add system proxy switch
|
||||||
|
|
||||||
|
- Add geodata loader switch
|
||||||
|
|
||||||
|
- Add external controller switch
|
||||||
|
|
||||||
|
- Add auto gc on trim memory
|
||||||
|
|
||||||
|
- Fix android notification error
|
||||||
|
|
||||||
|
## v0.8.20
|
||||||
|
|
||||||
|
- Fix ipv6 error
|
||||||
|
|
||||||
|
- Fix android udp direct error
|
||||||
|
|
||||||
|
- Add ipv6 switch
|
||||||
|
|
||||||
|
- Add access all selected button
|
||||||
|
|
||||||
|
- Remove android low version splash
|
||||||
|
|
||||||
|
## v0.8.19
|
||||||
|
|
||||||
|
- Update version
|
||||||
|
|
||||||
|
- Add allowBypass
|
||||||
|
|
||||||
|
- Fix Android only pick .text file issues
|
||||||
|
|
||||||
|
## v0.8.18
|
||||||
|
|
||||||
|
- Fix search issues
|
||||||
|
|
||||||
|
## v0.8.17
|
||||||
|
|
||||||
|
- Fix LoadBalance, Relay load error
|
||||||
|
|
||||||
|
- Fix build.yml4
|
||||||
|
|
||||||
|
- Fix build.yml3
|
||||||
|
|
||||||
|
- Fix build.yml2
|
||||||
|
|
||||||
|
- Fix build.yml
|
||||||
|
|
||||||
|
- Add search function at access control
|
||||||
|
|
||||||
|
- Fix the issues with the profile add button to cover the edit button
|
||||||
|
|
||||||
|
- Adapt LoadBalance and Relay
|
||||||
|
|
||||||
|
- Add arm
|
||||||
|
|
||||||
|
- Fix android notification icon error
|
||||||
|
|
||||||
|
## v0.8.16
|
||||||
|
|
||||||
|
- Add one-click update all profiles
|
||||||
|
- Add expire show
|
||||||
|
|
||||||
|
## v0.8.15
|
||||||
|
|
||||||
|
- Temp remove tun mode
|
||||||
|
|
||||||
|
- Remove macos in workflow
|
||||||
|
|
||||||
|
- Change go version
|
||||||
|
|
||||||
|
## v0.8.14
|
||||||
|
|
||||||
|
- Update Version
|
||||||
|
|
||||||
|
- Fix tun unable to open
|
||||||
|
|
||||||
|
## v0.8.13
|
||||||
|
|
||||||
|
- Optimize delay test2
|
||||||
|
|
||||||
|
- Optimize delay test
|
||||||
|
|
||||||
|
- Add check ip
|
||||||
|
|
||||||
|
- add check ip request
|
||||||
|
|
||||||
|
## v0.8.12
|
||||||
|
|
||||||
|
- Fix the problem that the download of remote resources failed after GeodataMode was turned on, which caused the application to flash back.
|
||||||
|
|
||||||
|
- Fix edit profile error
|
||||||
|
|
||||||
|
- Fix quickStart change proxy error
|
||||||
|
|
||||||
|
- Fix core version
|
||||||
|
|
||||||
|
## v0.8.10
|
||||||
|
|
||||||
|
- Fix core version
|
||||||
|
|
||||||
|
## v0.8.9
|
||||||
|
|
||||||
|
- Update file_picker
|
||||||
|
|
||||||
|
- Add resources page
|
||||||
|
|
||||||
|
- Optimize more detail
|
||||||
|
|
||||||
|
- Add access selected sorted
|
||||||
|
|
||||||
|
- Fix notification duplicate creation issue
|
||||||
|
|
||||||
|
- Fix AccessControl click issue
|
||||||
|
|
||||||
|
## v0.8.7
|
||||||
|
|
||||||
|
- Fix Workflow
|
||||||
|
|
||||||
|
- Fix Linux unable to open
|
||||||
|
|
||||||
|
- Update README.md 3
|
||||||
|
|
||||||
|
- Create LICENSE
|
||||||
|
- Update README.md 2
|
||||||
|
|
||||||
|
- Update README.md
|
||||||
|
|
||||||
|
- Optimize workFlow
|
||||||
|
|
||||||
|
## v0.8.6
|
||||||
|
|
||||||
|
- optimize checkUpdate
|
||||||
|
|
||||||
|
## v0.8.5
|
||||||
|
|
||||||
|
- Fix submit error
|
||||||
|
|
||||||
|
## v0.8.4
|
||||||
|
|
||||||
|
- add WebDAV
|
||||||
|
|
||||||
|
- add Auto check updates
|
||||||
|
|
||||||
|
- Optimize more details
|
||||||
|
|
||||||
|
- optimize delayTest
|
||||||
|
|
||||||
|
## v0.8.2
|
||||||
|
|
||||||
|
- upgrade flutter version
|
||||||
|
|
||||||
|
## v0.8.1
|
||||||
|
|
||||||
|
- Update kernel
|
||||||
|
- Add import profile via QR code image
|
||||||
|
|
||||||
|
## v0.8.0
|
||||||
|
|
||||||
|
- Add compatibility mode and adapt clash scheme.
|
||||||
|
|
||||||
|
## v0.7.14
|
||||||
|
|
||||||
|
- update Version
|
||||||
|
|
||||||
|
- Reconstruction application proxy logic
|
||||||
|
|
||||||
|
## v0.7.13
|
||||||
|
|
||||||
|
- Fix Tab destroy error
|
||||||
|
|
||||||
|
## v0.7.12
|
||||||
|
|
||||||
|
- Optimize repeat healthcheck
|
||||||
|
|
||||||
|
## v0.7.11
|
||||||
|
|
||||||
|
- Optimize Direct mode ui
|
||||||
|
|
||||||
|
## v0.7.10
|
||||||
|
|
||||||
|
- Optimize Healthcheck
|
||||||
|
|
||||||
|
- Remove proxies position animation, improve performance
|
||||||
|
- Add Telegram Link
|
||||||
|
|
||||||
|
- Update healthcheck policy
|
||||||
|
|
||||||
|
- New Check URLTest
|
||||||
|
|
||||||
|
- Fix the problem of invalid auto-selection
|
||||||
|
|
||||||
|
## v0.7.8
|
||||||
|
|
||||||
|
- New Async UpdateConfig
|
||||||
|
|
||||||
|
- add changeProfileDebounce
|
||||||
|
|
||||||
|
- Update Workflow
|
||||||
|
|
||||||
|
- Fix ChangeProfile block
|
||||||
|
|
||||||
|
- Fix Release Message Error
|
||||||
|
|
||||||
|
## v0.7.7
|
||||||
|
|
||||||
|
- Update Selector 2
|
||||||
|
|
||||||
|
## v0.7.6
|
||||||
|
|
||||||
|
- Update Version
|
||||||
|
|
||||||
|
- Fix Proxies Select Error
|
||||||
|
|
||||||
|
## v0.7.5
|
||||||
|
|
||||||
|
- Fix the problem that the proxy group is empty in global mode.
|
||||||
|
|
||||||
|
- Fix the problem that the proxy group is empty in global mode.
|
||||||
|
|
||||||
|
## v0.7.4
|
||||||
|
|
||||||
|
- Add ProxyProvider2
|
||||||
|
|
||||||
|
## v0.7.3
|
||||||
|
|
||||||
|
- Add ProxyProvider
|
||||||
|
|
||||||
|
- Update Version
|
||||||
|
|
||||||
|
- Update ProxyGroup Sort
|
||||||
|
|
||||||
|
- Fix Android quickStart VpnService some problems
|
||||||
|
|
||||||
|
## v0.7.1
|
||||||
|
|
||||||
|
- Update version
|
||||||
|
|
||||||
|
- Set Android notification low importance
|
||||||
|
|
||||||
|
- Fix the issue that VpnService can't be closed correctly in special cases
|
||||||
|
|
||||||
|
- Fix the problem that TileService is not destroyed correctly in some cases
|
||||||
|
|
||||||
|
- Adjust tab animation defaults
|
||||||
|
|
||||||
|
- Add Telegram in README_zh_CN.md
|
||||||
|
|
||||||
|
- Add Telegram
|
||||||
|
|
||||||
|
## v0.7.0
|
||||||
|
|
||||||
|
- update mobile_scanner
|
||||||
|
|
||||||
|
- Initial commit
|
||||||
|
|
||||||
17
README.md
@@ -6,13 +6,9 @@
|
|||||||
|
|
||||||
## FlClash
|
## FlClash
|
||||||
|
|
||||||
<p style="text-align: left;">
|
[](https://github.com/chen08209/FlClash/releases/)[](https://github.com/chen08209/FlClash/releases/)[](LICENSE)
|
||||||
<img alt="stars" src="https://img.shields.io/github/stars/chen08209/FlClash?style=flat-square&logo=github"/>
|
|
||||||
<img alt="downloads" src="https://img.shields.io/github/downloads/chen08209/FlClash/total"/>
|
[](https://t.me/FlClash)
|
||||||
<a href="LICENSE">
|
|
||||||
<img alt="license" src="https://img.shields.io/github/license/chen08209/FlClash"/>
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
A multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free.
|
A multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free.
|
||||||
|
|
||||||
@@ -38,9 +34,9 @@ on Mobile:
|
|||||||
|
|
||||||
✨ Support subscription link, Dark mode
|
✨ Support subscription link, Dark mode
|
||||||
|
|
||||||
## Contact
|
## Download
|
||||||
|
|
||||||
[Telegram](https://t.me/+G-veVtwBOl4wODc1)
|
<a href="https://chen08209.github.io/FlClash-fdroid-repo/repo?fingerprint=789D6D32668712EF7672F9E58DEEB15FBD6DCEEC5AE7A4371EA72F2AAE8A12FD"><img alt="Get it on F-Droid" src="snapshots/get-it-on-fdroid.svg" width="200px"/></a> <a href="https://github.com/chen08209/FlClash/releases"><img alt="Get it on GitHub" src="snapshots/get-it-on-github.svg" width="200px"/></a>
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
@@ -96,9 +92,6 @@ on Mobile:
|
|||||||
```bash
|
```bash
|
||||||
dart .\setup.dart
|
dart .\setup.dart
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Star
|
## Star
|
||||||
|
|
||||||
|
|||||||
@@ -6,13 +6,10 @@
|
|||||||
|
|
||||||
## FlClash
|
## FlClash
|
||||||
|
|
||||||
<p style="text-align: left;">
|
[](https://github.com/chen08209/FlClash/releases/)[](https://github.com/chen08209/FlClash/releases/)[](LICENSE)
|
||||||
<img alt="stars" src="https://img.shields.io/github/stars/chen08209/FlClash?style=flat-square&logo=github"/>
|
|
||||||
<img alt="downloads" src="https://img.shields.io/github/downloads/chen08209/FlClash/total"/>
|
[](https://t.me/FlClash)
|
||||||
<a href="LICENSE">
|
|
||||||
<img alt="license" src="https://img.shields.io/github/license/chen08209/FlClash"/>
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
基于ClashMeta的多平台代理客户端,简单易用,开源无广告。
|
基于ClashMeta的多平台代理客户端,简单易用,开源无广告。
|
||||||
|
|
||||||
@@ -38,9 +35,9 @@ on Mobile:
|
|||||||
|
|
||||||
✨ 支持一键导入订阅, 深色模式
|
✨ 支持一键导入订阅, 深色模式
|
||||||
|
|
||||||
## Contact
|
## Download
|
||||||
|
|
||||||
[Telegram](https://t.me/+G-veVtwBOl4wODc1)
|
<a href="https://chen08209.github.io/FlClash-fdroid-repo/repo?fingerprint=789D6D32668712EF7672F9E58DEEB15FBD6DCEEC5AE7A4371EA72F2AAE8A12FD"><img alt="Get it on F-Droid" src="snapshots/get-it-on-fdroid.svg" width="200px"/></a> <a href="https://github.com/chen08209/FlClash/releases"><img alt="Get it on GitHub" src="snapshots/get-it-on-github.svg" width="200px"/></a>
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
|||||||
@@ -34,22 +34,22 @@ def isRelease = defStoreFile.exists() && defStorePassword != null && defKeyAlias
|
|||||||
android {
|
android {
|
||||||
namespace "com.follow.clash"
|
namespace "com.follow.clash"
|
||||||
compileSdkVersion 34
|
compileSdkVersion 34
|
||||||
ndkVersion "25.1.8937393"
|
ndkVersion "27.1.12297006"
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility JavaVersion.VERSION_17
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_17
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = '1.8'
|
jvmTarget = '17'
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main.java.srcDirs += 'src/main/kotlin'
|
main.java.srcDirs += 'src/main/kotlin'
|
||||||
}
|
}
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
if (isRelease){
|
if (isRelease) {
|
||||||
release {
|
release {
|
||||||
storeFile defStoreFile
|
storeFile defStoreFile
|
||||||
storePassword defStorePassword
|
storePassword defStorePassword
|
||||||
@@ -62,7 +62,7 @@ android {
|
|||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.follow.clash"
|
applicationId "com.follow.clash"
|
||||||
minSdkVersion 24
|
minSdkVersion 21
|
||||||
targetSdkVersion 34
|
targetSdkVersion 34
|
||||||
versionCode flutterVersionCode.toInteger()
|
versionCode flutterVersionCode.toInteger()
|
||||||
versionName flutterVersionName
|
versionName flutterVersionName
|
||||||
@@ -74,10 +74,9 @@ android {
|
|||||||
applicationIdSuffix '.debug'
|
applicationIdSuffix '.debug'
|
||||||
}
|
}
|
||||||
release {
|
release {
|
||||||
minifyEnabled true
|
if (isRelease) {
|
||||||
if(isRelease){
|
|
||||||
signingConfig signingConfigs.release
|
signingConfig signingConfigs.release
|
||||||
}else{
|
} else {
|
||||||
signingConfig signingConfigs.debug
|
signingConfig signingConfigs.debug
|
||||||
}
|
}
|
||||||
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
|
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
|
||||||
@@ -102,6 +101,9 @@ flutter {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation 'androidx.core:core-splashscreen:1.0.1'
|
implementation 'androidx.core:core-splashscreen:1.0.1'
|
||||||
implementation 'com.google.code.gson:gson:2.10'
|
implementation 'com.google.code.gson:gson:2.10'
|
||||||
|
implementation("com.android.tools.smali:smali-dexlib2:3.0.7") {
|
||||||
|
exclude group: "com.google.guava", module: "guava"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,28 +2,29 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
<uses-feature
|
<uses-feature
|
||||||
android:name="android.hardware.touchscreen"
|
android:name="android.hardware.touchscreen"
|
||||||
android:required="false" />
|
android:required="false" />
|
||||||
<uses-feature
|
<uses-feature
|
||||||
android:name="android.hardware.camera"
|
android:name="android.hardware.camera"
|
||||||
android:required="false" />
|
android:required="false" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE"
|
||||||
|
tools:ignore="SystemPermissionTypo" />
|
||||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE"
|
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
|
||||||
tools:ignore="SystemPermissionTypo" />
|
<uses-permission
|
||||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
|
android:name="android.permission.QUERY_ALL_PACKAGES"
|
||||||
tools:ignore="QueryAllPackagesPermission" />
|
tools:ignore="QueryAllPackagesPermission" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:extractNativeLibs="true"
|
android:hardwareAccelerated="true"
|
||||||
android:networkSecurityConfig="@xml/network_security_config"
|
|
||||||
android:label="FlClash">
|
android:label="FlClash">
|
||||||
<activity
|
<activity
|
||||||
android:name="com.follow.clash.MainActivity"
|
android:name="com.follow.clash.MainActivity"
|
||||||
@@ -54,27 +55,37 @@
|
|||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
|
||||||
<data android:scheme="clash"/>
|
<data android:scheme="clash" />
|
||||||
<data android:scheme="clashmeta"/>
|
<data android:scheme="clashmeta" />
|
||||||
<data android:scheme="flclash"/>
|
<data android:scheme="flclash" />
|
||||||
|
|
||||||
<data android:host="install-config"/>
|
<data android:host="install-config" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<!-- <meta-data-->
|
<!-- <meta-data-->
|
||||||
<!-- android:name="io.flutter.embedding.android.EnableImpeller"-->
|
<!-- android:name="io.flutter.embedding.android.EnableImpeller"-->
|
||||||
<!-- android:value="true" />-->
|
<!-- android:value="true" />-->
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".TempActivity"
|
android:name=".TempActivity"
|
||||||
android:theme="@style/TransparentTheme" />
|
android:exported="true"
|
||||||
|
android:theme="@style/TransparentTheme">
|
||||||
|
<intent-filter>
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<action android:name="com.follow.clash.action.START" />
|
||||||
|
</intent-filter>
|
||||||
|
<intent-filter>
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<action android:name="com.follow.clash.action.STOP" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name=".services.FlClashTileService"
|
android:name=".services.FlClashTileService"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:icon="@drawable/icon"
|
|
||||||
android:foregroundServiceType="specialUse"
|
android:foregroundServiceType="specialUse"
|
||||||
|
android:icon="@drawable/ic_stat_name"
|
||||||
android:label="FlClash"
|
android:label="FlClash"
|
||||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
|
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
@@ -84,6 +95,29 @@
|
|||||||
android:name="android.service.quicksettings.TOGGLEABLE_TILE"
|
android:name="android.service.quicksettings.TOGGLEABLE_TILE"
|
||||||
android:value="true" />
|
android:value="true" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
<provider
|
||||||
|
android:name=".FilesProvider"
|
||||||
|
android:authorities="${applicationId}.files"
|
||||||
|
android:exported="true"
|
||||||
|
android:grantUriPermissions="true"
|
||||||
|
android:permission="android.permission.MANAGE_DOCUMENTS"
|
||||||
|
android:process=":background">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.content.action.DOCUMENTS_PROVIDER" />
|
||||||
|
</intent-filter>
|
||||||
|
</provider>
|
||||||
|
|
||||||
|
<provider
|
||||||
|
android:name="androidx.core.content.FileProvider"
|
||||||
|
android:authorities="${applicationId}.fileProvider"
|
||||||
|
android:exported="false"
|
||||||
|
android:grantUriPermissions="true">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||||
|
android:resource="@xml/file_paths" />
|
||||||
|
</provider>
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name=".services.FlClashVpnService"
|
android:name=".services.FlClashVpnService"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
@@ -92,6 +126,18 @@
|
|||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.net.VpnService" />
|
<action android:name="android.net.VpnService" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
<property
|
||||||
|
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
|
||||||
|
android:value="vpn" />
|
||||||
|
</service>
|
||||||
|
|
||||||
|
<service
|
||||||
|
android:name=".services.FlClashService"
|
||||||
|
android:exported="false"
|
||||||
|
android:foregroundServiceType="specialUse">
|
||||||
|
<property
|
||||||
|
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
|
||||||
|
android:value="service" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 12 KiB |
@@ -0,0 +1,10 @@
|
|||||||
|
package com.follow.clash
|
||||||
|
|
||||||
|
|
||||||
|
import com.follow.clash.models.VpnOptions
|
||||||
|
|
||||||
|
interface BaseServiceInterface {
|
||||||
|
fun start(options: VpnOptions): Int
|
||||||
|
fun stop()
|
||||||
|
fun startForeground(title: String, content: String)
|
||||||
|
}
|
||||||
112
android/app/src/main/kotlin/com/follow/clash/FilesProvider.kt
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
package com.follow.clash
|
||||||
|
|
||||||
|
import android.database.Cursor
|
||||||
|
import android.database.MatrixCursor
|
||||||
|
import android.os.CancellationSignal
|
||||||
|
import android.os.ParcelFileDescriptor
|
||||||
|
import android.provider.DocumentsContract.Document
|
||||||
|
import android.provider.DocumentsContract.Root
|
||||||
|
import android.provider.DocumentsProvider
|
||||||
|
import java.io.File
|
||||||
|
import java.io.FileNotFoundException
|
||||||
|
|
||||||
|
|
||||||
|
class FilesProvider : DocumentsProvider() {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val DEFAULT_ROOT_ID = "0"
|
||||||
|
|
||||||
|
private val DEFAULT_DOCUMENT_COLUMNS = arrayOf(
|
||||||
|
Document.COLUMN_DOCUMENT_ID,
|
||||||
|
Document.COLUMN_DISPLAY_NAME,
|
||||||
|
Document.COLUMN_MIME_TYPE,
|
||||||
|
Document.COLUMN_FLAGS,
|
||||||
|
Document.COLUMN_SIZE,
|
||||||
|
)
|
||||||
|
private val DEFAULT_ROOT_COLUMNS = arrayOf(
|
||||||
|
Root.COLUMN_ROOT_ID,
|
||||||
|
Root.COLUMN_FLAGS,
|
||||||
|
Root.COLUMN_ICON,
|
||||||
|
Root.COLUMN_TITLE,
|
||||||
|
Root.COLUMN_SUMMARY,
|
||||||
|
Root.COLUMN_DOCUMENT_ID
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate(): Boolean {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun queryRoots(projection: Array<String>?): Cursor {
|
||||||
|
return MatrixCursor(projection ?: DEFAULT_ROOT_COLUMNS).apply {
|
||||||
|
newRow().apply {
|
||||||
|
add(Root.COLUMN_ROOT_ID, DEFAULT_ROOT_ID)
|
||||||
|
add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY)
|
||||||
|
add(Root.COLUMN_ICON, R.mipmap.ic_launcher)
|
||||||
|
add(Root.COLUMN_TITLE, context!!.getString(R.string.fl_clash))
|
||||||
|
add(Root.COLUMN_SUMMARY, "Data")
|
||||||
|
add(Root.COLUMN_DOCUMENT_ID, "/")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun queryChildDocuments(
|
||||||
|
parentDocumentId: String,
|
||||||
|
projection: Array<String>?,
|
||||||
|
sortOrder: String?
|
||||||
|
): Cursor {
|
||||||
|
val result = MatrixCursor(resolveDocumentProjection(projection))
|
||||||
|
val parentFile = if (parentDocumentId == "/") {
|
||||||
|
context?.filesDir
|
||||||
|
} else {
|
||||||
|
File(parentDocumentId)
|
||||||
|
} ?: throw FileNotFoundException("Parent directory not found")
|
||||||
|
parentFile.listFiles()?.forEach { file ->
|
||||||
|
includeFile(result, file)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun queryDocument(documentId: String, projection: Array<String>?): Cursor {
|
||||||
|
val result = MatrixCursor(resolveDocumentProjection(projection))
|
||||||
|
val file = File(documentId)
|
||||||
|
includeFile(result, file)
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun openDocument(
|
||||||
|
documentId: String,
|
||||||
|
mode: String,
|
||||||
|
signal: CancellationSignal?
|
||||||
|
): ParcelFileDescriptor {
|
||||||
|
val file = File(documentId)
|
||||||
|
val accessMode = ParcelFileDescriptor.parseMode(mode)
|
||||||
|
return ParcelFileDescriptor.open(file, accessMode)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun includeFile(result: MatrixCursor, file: File) {
|
||||||
|
result.newRow().apply {
|
||||||
|
add(Document.COLUMN_DOCUMENT_ID, file.absolutePath)
|
||||||
|
add(Document.COLUMN_DISPLAY_NAME, file.name)
|
||||||
|
add(Document.COLUMN_SIZE, file.length())
|
||||||
|
add(
|
||||||
|
Document.COLUMN_FLAGS,
|
||||||
|
Document.FLAG_SUPPORTS_WRITE or Document.FLAG_SUPPORTS_DELETE
|
||||||
|
)
|
||||||
|
add(Document.COLUMN_MIME_TYPE, getDocumentType(file))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getDocumentType(file: File): String {
|
||||||
|
return if (file.isDirectory) {
|
||||||
|
Document.MIME_TYPE_DIR
|
||||||
|
} else {
|
||||||
|
"application/octet-stream"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun resolveDocumentProjection(projection: Array<String>?): Array<String> {
|
||||||
|
return projection ?: DEFAULT_DOCUMENT_COLUMNS
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,16 @@
|
|||||||
package com.follow.clash
|
package com.follow.clash
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import com.follow.clash.plugins.AppPlugin
|
import com.follow.clash.plugins.AppPlugin
|
||||||
|
import com.follow.clash.plugins.ServicePlugin
|
||||||
|
import com.follow.clash.plugins.VpnPlugin
|
||||||
import com.follow.clash.plugins.TilePlugin
|
import com.follow.clash.plugins.TilePlugin
|
||||||
|
import io.flutter.FlutterInjector
|
||||||
import io.flutter.embedding.engine.FlutterEngine
|
import io.flutter.embedding.engine.FlutterEngine
|
||||||
import java.util.Date
|
import io.flutter.embedding.engine.dart.DartExecutor
|
||||||
|
import java.util.concurrent.locks.ReentrantLock
|
||||||
|
import kotlin.concurrent.withLock
|
||||||
|
|
||||||
enum class RunState {
|
enum class RunState {
|
||||||
START,
|
START,
|
||||||
@@ -12,15 +18,52 @@ enum class RunState {
|
|||||||
STOP
|
STOP
|
||||||
}
|
}
|
||||||
|
|
||||||
class GlobalState {
|
|
||||||
companion object {
|
|
||||||
val runState: MutableLiveData<RunState> = MutableLiveData<RunState>(RunState.STOP)
|
|
||||||
var flutterEngine: FlutterEngine? = null
|
|
||||||
fun getCurrentTilePlugin(): TilePlugin? =
|
|
||||||
flutterEngine?.plugins?.get(TilePlugin::class.java) as TilePlugin?
|
|
||||||
|
|
||||||
fun getCurrentAppPlugin(): AppPlugin? =
|
object GlobalState {
|
||||||
flutterEngine?.plugins?.get(AppPlugin::class.java) as AppPlugin?
|
|
||||||
|
private val lock = ReentrantLock()
|
||||||
|
val runLock = ReentrantLock()
|
||||||
|
|
||||||
|
val runState: MutableLiveData<RunState> = MutableLiveData<RunState>(RunState.STOP)
|
||||||
|
var flutterEngine: FlutterEngine? = null
|
||||||
|
private var serviceEngine: FlutterEngine? = null
|
||||||
|
|
||||||
|
fun getCurrentAppPlugin(): AppPlugin? {
|
||||||
|
val currentEngine = if (flutterEngine != null) flutterEngine else serviceEngine
|
||||||
|
return currentEngine?.plugins?.get(AppPlugin::class.java) as AppPlugin?
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getCurrentTilePlugin(): TilePlugin? {
|
||||||
|
val currentEngine = if (flutterEngine != null) flutterEngine else serviceEngine
|
||||||
|
return currentEngine?.plugins?.get(TilePlugin::class.java) as TilePlugin?
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getCurrentVPNPlugin(): VpnPlugin? {
|
||||||
|
return serviceEngine?.plugins?.get(VpnPlugin::class.java) as VpnPlugin?
|
||||||
|
}
|
||||||
|
|
||||||
|
fun destroyServiceEngine() {
|
||||||
|
serviceEngine?.destroy()
|
||||||
|
serviceEngine = null
|
||||||
|
}
|
||||||
|
|
||||||
|
fun initServiceEngine(context: Context) {
|
||||||
|
if (serviceEngine != null) return
|
||||||
|
lock.withLock {
|
||||||
|
destroyServiceEngine()
|
||||||
|
serviceEngine = FlutterEngine(context)
|
||||||
|
serviceEngine?.plugins?.add(VpnPlugin())
|
||||||
|
serviceEngine?.plugins?.add(AppPlugin())
|
||||||
|
serviceEngine?.plugins?.add(TilePlugin())
|
||||||
|
serviceEngine?.plugins?.add(ServicePlugin())
|
||||||
|
val vpnService = DartExecutor.DartEntrypoint(
|
||||||
|
FlutterInjector.instance().flutterLoader().findAppBundlePath(),
|
||||||
|
"vpnService"
|
||||||
|
)
|
||||||
|
serviceEngine?.dartExecutor?.executeDartEntrypoint(
|
||||||
|
vpnService,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,18 +2,18 @@ package com.follow.clash
|
|||||||
|
|
||||||
|
|
||||||
import com.follow.clash.plugins.AppPlugin
|
import com.follow.clash.plugins.AppPlugin
|
||||||
import com.follow.clash.plugins.ProxyPlugin
|
import com.follow.clash.plugins.ServicePlugin
|
||||||
|
import com.follow.clash.plugins.VpnPlugin
|
||||||
import com.follow.clash.plugins.TilePlugin
|
import com.follow.clash.plugins.TilePlugin
|
||||||
import io.flutter.embedding.android.FlutterActivity
|
import io.flutter.embedding.android.FlutterActivity
|
||||||
import io.flutter.embedding.engine.FlutterEngine
|
import io.flutter.embedding.engine.FlutterEngine
|
||||||
|
|
||||||
class MainActivity : FlutterActivity() {
|
class MainActivity : FlutterActivity() {
|
||||||
|
|
||||||
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
||||||
GlobalState.flutterEngine?.destroy()
|
|
||||||
super.configureFlutterEngine(flutterEngine)
|
super.configureFlutterEngine(flutterEngine)
|
||||||
flutterEngine.plugins.add(AppPlugin())
|
flutterEngine.plugins.add(AppPlugin())
|
||||||
flutterEngine.plugins.add(ProxyPlugin())
|
flutterEngine.plugins.add(VpnPlugin())
|
||||||
|
flutterEngine.plugins.add(ServicePlugin())
|
||||||
flutterEngine.plugins.add(TilePlugin())
|
flutterEngine.plugins.add(TilePlugin())
|
||||||
GlobalState.flutterEngine = flutterEngine
|
GlobalState.flutterEngine = flutterEngine
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,15 @@ import android.os.Bundle
|
|||||||
class TempActivity : Activity() {
|
class TempActivity : Activity() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
when (intent.action) {
|
||||||
|
"com.follow.clash.action.START" -> {
|
||||||
|
GlobalState.getCurrentTilePlugin()?.handleStart()
|
||||||
|
}
|
||||||
|
|
||||||
|
"com.follow.clash.action.STOP" -> {
|
||||||
|
GlobalState.getCurrentTilePlugin()?.handleStop()
|
||||||
|
}
|
||||||
|
}
|
||||||
finishAndRemoveTask()
|
finishAndRemoveTask()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
package com.follow.clash.extensions
|
|
||||||
|
|
||||||
import android.graphics.Bitmap
|
|
||||||
import android.graphics.drawable.Drawable
|
|
||||||
import android.system.OsConstants.IPPROTO_TCP
|
|
||||||
import android.system.OsConstants.IPPROTO_UDP
|
|
||||||
import android.util.Base64
|
|
||||||
import java.net.URL
|
|
||||||
import androidx.core.graphics.drawable.toBitmap
|
|
||||||
import com.follow.clash.models.Metadata
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.withContext
|
|
||||||
import java.io.ByteArrayOutputStream
|
|
||||||
import java.net.InetAddress
|
|
||||||
import java.net.InetSocketAddress
|
|
||||||
|
|
||||||
|
|
||||||
suspend fun Drawable.getBase64(): String {
|
|
||||||
val drawable = this
|
|
||||||
return withContext(Dispatchers.IO) {
|
|
||||||
val bitmap = drawable.toBitmap()
|
|
||||||
val byteArrayOutputStream = ByteArrayOutputStream()
|
|
||||||
bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream)
|
|
||||||
Base64.encodeToString(byteArrayOutputStream.toByteArray(), Base64.NO_WRAP)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Metadata.getProtocol(): Int? {
|
|
||||||
if (network.startsWith("tcp")) return IPPROTO_TCP
|
|
||||||
if (network.startsWith("udp")) return IPPROTO_UDP
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
fun String.getInetSocketAddress(): InetSocketAddress {
|
|
||||||
val url = URL("https://$this")
|
|
||||||
return InetSocketAddress(InetAddress.getByName(url.host), url.port)
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
package com.follow.clash.extensions
|
||||||
|
|
||||||
|
import android.graphics.Bitmap
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
|
import android.net.ConnectivityManager
|
||||||
|
import android.net.Network
|
||||||
|
import android.system.OsConstants.IPPROTO_TCP
|
||||||
|
import android.system.OsConstants.IPPROTO_UDP
|
||||||
|
import android.util.Base64
|
||||||
|
import androidx.core.graphics.drawable.toBitmap
|
||||||
|
import com.follow.clash.models.CIDR
|
||||||
|
import com.follow.clash.models.Metadata
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
|
import java.io.ByteArrayOutputStream
|
||||||
|
import java.net.Inet4Address
|
||||||
|
import java.net.Inet6Address
|
||||||
|
import java.net.InetAddress
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun Drawable.getBase64(): String {
|
||||||
|
val drawable = this
|
||||||
|
return withContext(Dispatchers.IO) {
|
||||||
|
val bitmap = drawable.toBitmap()
|
||||||
|
val byteArrayOutputStream = ByteArrayOutputStream()
|
||||||
|
bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream)
|
||||||
|
Base64.encodeToString(byteArrayOutputStream.toByteArray(), Base64.NO_WRAP)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Metadata.getProtocol(): Int? {
|
||||||
|
if (network.startsWith("tcp")) return IPPROTO_TCP
|
||||||
|
if (network.startsWith("udp")) return IPPROTO_UDP
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
fun String.toCIDR(): CIDR {
|
||||||
|
val parts = split("/")
|
||||||
|
if (parts.size != 2) {
|
||||||
|
throw IllegalArgumentException("Invalid CIDR format")
|
||||||
|
}
|
||||||
|
val ipAddress = parts[0]
|
||||||
|
val prefixLength = parts[1].toIntOrNull()
|
||||||
|
?: throw IllegalArgumentException("Invalid prefix length")
|
||||||
|
|
||||||
|
val address = InetAddress.getByName(ipAddress)
|
||||||
|
|
||||||
|
val maxPrefix = if (address.address.size == 4) 32 else 128
|
||||||
|
if (prefixLength < 0 || prefixLength > maxPrefix) {
|
||||||
|
throw IllegalArgumentException("Invalid prefix length for IP version")
|
||||||
|
}
|
||||||
|
|
||||||
|
return CIDR(address, prefixLength)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun ConnectivityManager.resolveDns(network: Network?): List<String> {
|
||||||
|
val properties = getLinkProperties(network) ?: return listOf()
|
||||||
|
return properties.dnsServers.map { it.asSocketAddressText(53) }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun InetAddress.asSocketAddressText(port: Int): String {
|
||||||
|
return when (this) {
|
||||||
|
is Inet6Address ->
|
||||||
|
"[${numericToTextFormat(this.address)}]:$port"
|
||||||
|
|
||||||
|
is Inet4Address ->
|
||||||
|
"${this.hostAddress}:$port"
|
||||||
|
|
||||||
|
else -> throw IllegalArgumentException("Unsupported Inet type ${this.javaClass}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun numericToTextFormat(src: ByteArray): String {
|
||||||
|
val sb = StringBuilder(39)
|
||||||
|
for (i in 0 until 8) {
|
||||||
|
sb.append(
|
||||||
|
Integer.toHexString(
|
||||||
|
src[i shl 1].toInt() shl 8 and 0xff00
|
||||||
|
or (src[(i shl 1) + 1].toInt() and 0xff)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if (i < 7) {
|
||||||
|
sb.append(":")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString()
|
||||||
|
}
|
||||||
@@ -3,5 +3,6 @@ package com.follow.clash.models
|
|||||||
data class Package(
|
data class Package(
|
||||||
val packageName: String,
|
val packageName: String,
|
||||||
val label: String,
|
val label: String,
|
||||||
val isSystem:Boolean
|
val isSystem: Boolean,
|
||||||
|
val firstInstallTime: Long,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.follow.clash.models
|
package com.follow.clash.models
|
||||||
|
|
||||||
|
import java.net.InetAddress
|
||||||
|
|
||||||
enum class AccessControlMode {
|
enum class AccessControlMode {
|
||||||
acceptSelected,
|
acceptSelected,
|
||||||
rejectSelected,
|
rejectSelected,
|
||||||
@@ -11,8 +13,16 @@ data class AccessControl(
|
|||||||
val rejectList: List<String>,
|
val rejectList: List<String>,
|
||||||
)
|
)
|
||||||
|
|
||||||
data class Props(
|
data class CIDR(val address: InetAddress, val prefixLength: Int)
|
||||||
|
|
||||||
|
data class VpnOptions(
|
||||||
|
val enable: Boolean,
|
||||||
|
val port: Int,
|
||||||
val accessControl: AccessControl?,
|
val accessControl: AccessControl?,
|
||||||
val allowBypass: Boolean?,
|
val allowBypass: Boolean,
|
||||||
val systemProxy: Boolean?,
|
val systemProxy: Boolean,
|
||||||
)
|
val bypassDomain: List<String>,
|
||||||
|
val ipv4Address: String,
|
||||||
|
val ipv6Address: String,
|
||||||
|
val dnsServerAddress: String,
|
||||||
|
)
|
||||||
@@ -2,33 +2,38 @@ package com.follow.clash.plugins
|
|||||||
|
|
||||||
import android.Manifest
|
import android.Manifest
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
import android.app.ActivityManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
import android.content.pm.ApplicationInfo
|
import android.content.pm.ApplicationInfo
|
||||||
|
import android.content.pm.ComponentInfo
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.net.ConnectivityManager
|
import android.net.VpnService
|
||||||
import android.net.Uri
|
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.core.app.ActivityCompat
|
||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.graphics.drawable.toBitmap
|
import androidx.core.content.ContextCompat.getSystemService
|
||||||
|
import com.android.tools.smali.dexlib2.dexbacked.DexBackedDexFile
|
||||||
|
import androidx.core.content.FileProvider
|
||||||
|
import com.follow.clash.GlobalState
|
||||||
import com.follow.clash.extensions.getBase64
|
import com.follow.clash.extensions.getBase64
|
||||||
import com.follow.clash.extensions.getInetSocketAddress
|
|
||||||
import com.follow.clash.extensions.getProtocol
|
|
||||||
import com.follow.clash.models.Process
|
|
||||||
import com.follow.clash.models.Package
|
import com.follow.clash.models.Package
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
|
import io.flutter.embedding.android.FlutterActivity
|
||||||
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
||||||
import io.flutter.embedding.engine.plugins.activity.ActivityAware
|
import io.flutter.embedding.engine.plugins.activity.ActivityAware
|
||||||
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
|
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
|
||||||
import io.flutter.plugin.common.MethodCall
|
import io.flutter.plugin.common.MethodCall
|
||||||
import io.flutter.plugin.common.MethodChannel
|
import io.flutter.plugin.common.MethodChannel
|
||||||
|
import io.flutter.plugin.common.MethodChannel.Result
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.cancel
|
import kotlinx.coroutines.cancel
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import java.net.InetSocketAddress
|
import java.io.File
|
||||||
|
import java.util.zip.ZipFile
|
||||||
|
|
||||||
class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware {
|
class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware {
|
||||||
|
|
||||||
@@ -36,17 +41,81 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
|||||||
|
|
||||||
private var toast: Toast? = null
|
private var toast: Toast? = null
|
||||||
|
|
||||||
private var context: Context? = null
|
private lateinit var context: Context
|
||||||
|
|
||||||
private lateinit var channel: MethodChannel
|
private lateinit var channel: MethodChannel
|
||||||
|
|
||||||
private lateinit var scope: CoroutineScope
|
private lateinit var scope: CoroutineScope
|
||||||
|
|
||||||
private var connectivity: ConnectivityManager? = null
|
private var vpnCallBack: (() -> Unit)? = null
|
||||||
|
|
||||||
private val iconMap = mutableMapOf<String, String?>()
|
private val iconMap = mutableMapOf<String, String?>()
|
||||||
|
|
||||||
|
private val packages = mutableListOf<Package>()
|
||||||
|
|
||||||
|
private val skipPrefixList = listOf(
|
||||||
|
"com.google",
|
||||||
|
"com.android.chrome",
|
||||||
|
"com.android.vending",
|
||||||
|
"com.microsoft",
|
||||||
|
"com.apple",
|
||||||
|
"com.zhiliaoapp.musically", // Banned by China
|
||||||
|
)
|
||||||
|
|
||||||
|
private val chinaAppPrefixList = listOf(
|
||||||
|
"com.tencent",
|
||||||
|
"com.alibaba",
|
||||||
|
"com.umeng",
|
||||||
|
"com.qihoo",
|
||||||
|
"com.ali",
|
||||||
|
"com.alipay",
|
||||||
|
"com.amap",
|
||||||
|
"com.sina",
|
||||||
|
"com.weibo",
|
||||||
|
"com.vivo",
|
||||||
|
"com.xiaomi",
|
||||||
|
"com.huawei",
|
||||||
|
"com.taobao",
|
||||||
|
"com.secneo",
|
||||||
|
"s.h.e.l.l",
|
||||||
|
"com.stub",
|
||||||
|
"com.kiwisec",
|
||||||
|
"com.secshell",
|
||||||
|
"com.wrapper",
|
||||||
|
"cn.securitystack",
|
||||||
|
"com.mogosec",
|
||||||
|
"com.secoen",
|
||||||
|
"com.netease",
|
||||||
|
"com.mx",
|
||||||
|
"com.qq.e",
|
||||||
|
"com.baidu",
|
||||||
|
"com.bytedance",
|
||||||
|
"com.bugly",
|
||||||
|
"com.miui",
|
||||||
|
"com.oppo",
|
||||||
|
"com.coloros",
|
||||||
|
"com.iqoo",
|
||||||
|
"com.meizu",
|
||||||
|
"com.gionee",
|
||||||
|
"cn.nubia",
|
||||||
|
"com.oplus",
|
||||||
|
"andes.oplus",
|
||||||
|
"com.unionpay",
|
||||||
|
"cn.wps"
|
||||||
|
)
|
||||||
|
|
||||||
|
private val chinaAppRegex by lazy {
|
||||||
|
("(" + chinaAppPrefixList.joinToString("|").replace(".", "\\.") + ").*").toRegex()
|
||||||
|
}
|
||||||
|
|
||||||
|
val VPN_PERMISSION_REQUEST_CODE = 1001
|
||||||
|
|
||||||
|
val NOTIFICATION_PERMISSION_REQUEST_CODE = 1002
|
||||||
|
|
||||||
|
private var isBlockNotification: Boolean = false
|
||||||
|
|
||||||
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
||||||
|
scope = CoroutineScope(Dispatchers.Default)
|
||||||
context = flutterPluginBinding.applicationContext;
|
context = flutterPluginBinding.applicationContext;
|
||||||
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "app")
|
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "app")
|
||||||
channel.setMethodCallHandler(this)
|
channel.setMethodCallHandler(this)
|
||||||
@@ -54,27 +123,41 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
|||||||
|
|
||||||
override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
|
override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
|
||||||
channel.setMethodCallHandler(null)
|
channel.setMethodCallHandler(null)
|
||||||
|
scope.cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun tip(message: String?) {
|
private fun tip(message: String?) {
|
||||||
if (toast != null) {
|
if (GlobalState.flutterEngine == null) {
|
||||||
toast!!.cancel()
|
if (toast != null) {
|
||||||
|
toast!!.cancel()
|
||||||
|
}
|
||||||
|
toast = Toast.makeText(context, message, Toast.LENGTH_SHORT)
|
||||||
|
toast!!.show()
|
||||||
}
|
}
|
||||||
toast = Toast.makeText(context, message, Toast.LENGTH_SHORT)
|
|
||||||
toast!!.show()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.Q)
|
override fun onMethodCall(call: MethodCall, result: Result) {
|
||||||
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
|
|
||||||
when (call.method) {
|
when (call.method) {
|
||||||
"moveTaskToBack" -> {
|
"moveTaskToBack" -> {
|
||||||
activity?.moveTaskToBack(true)
|
activity?.moveTaskToBack(true)
|
||||||
result.success(true);
|
result.success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"updateExcludeFromRecents" -> {
|
||||||
|
val value = call.argument<Boolean>("value")
|
||||||
|
updateExcludeFromRecents(value)
|
||||||
|
result.success(true);
|
||||||
|
}
|
||||||
|
|
||||||
"getPackages" -> {
|
"getPackages" -> {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
result.success(getPackages())
|
result.success(getPackagesToJson())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
"getChinaPackageNames" -> {
|
||||||
|
scope.launch {
|
||||||
|
result.success(getChinaPackageNames())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +176,7 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
|||||||
}
|
}
|
||||||
if (iconMap["default"] == null) {
|
if (iconMap["default"] == null) {
|
||||||
iconMap["default"] =
|
iconMap["default"] =
|
||||||
context?.packageManager?.defaultActivityIcon?.getBase64()
|
context.packageManager?.defaultActivityIcon?.getBase64()
|
||||||
}
|
}
|
||||||
result.success(iconMap["default"])
|
result.success(iconMap["default"])
|
||||||
return@launch
|
return@launch
|
||||||
@@ -101,57 +184,16 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
"resolverProcess" -> {
|
|
||||||
val data = call.argument<String>("data")
|
|
||||||
val process =
|
|
||||||
if (data != null) Gson().fromJson(
|
|
||||||
data,
|
|
||||||
Process::class.java
|
|
||||||
) else null
|
|
||||||
val metadata = process?.metadata
|
|
||||||
val protocol = metadata?.getProtocol()
|
|
||||||
if (protocol == null) {
|
|
||||||
result.success(null)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
scope.launch {
|
|
||||||
withContext(Dispatchers.Default) {
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q){
|
|
||||||
result.success(null)
|
|
||||||
return@withContext
|
|
||||||
}
|
|
||||||
if (context == null) {
|
|
||||||
result.success(null)
|
|
||||||
return@withContext
|
|
||||||
}
|
|
||||||
if (connectivity == null) {
|
|
||||||
connectivity = context!!.getSystemService<ConnectivityManager>()
|
|
||||||
}
|
|
||||||
val src = InetSocketAddress(metadata.sourceIP, metadata.sourcePort)
|
|
||||||
val dst = InetSocketAddress(
|
|
||||||
metadata.destinationIP.ifEmpty { metadata.host },
|
|
||||||
metadata.destinationPort
|
|
||||||
)
|
|
||||||
val uid = try {
|
|
||||||
connectivity?.getConnectionOwnerUid(protocol, src, dst)
|
|
||||||
} catch (_: Exception) {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
if (uid == null || uid == -1) {
|
|
||||||
result.success(null)
|
|
||||||
return@withContext
|
|
||||||
}
|
|
||||||
val packages = context?.packageManager?.getPackagesForUid(uid)
|
|
||||||
result.success(packages?.first())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
"tip" -> {
|
"tip" -> {
|
||||||
val message = call.argument<String>("message")
|
val message = call.argument<String>("message")
|
||||||
tip(message)
|
tip(message)
|
||||||
result.success(true)
|
result.success(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
"openFile" -> {
|
||||||
|
val path = call.argument<String>("path")!!
|
||||||
|
openFile(path)
|
||||||
|
result.success(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
@@ -160,8 +202,61 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun openFile(path: String) {
|
||||||
|
val file = File(path)
|
||||||
|
val uri = FileProvider.getUriForFile(
|
||||||
|
context,
|
||||||
|
"${context.packageName}.fileProvider",
|
||||||
|
file
|
||||||
|
)
|
||||||
|
|
||||||
|
val intent = Intent(Intent.ACTION_VIEW).setDataAndType(
|
||||||
|
uri,
|
||||||
|
"text/plain"
|
||||||
|
)
|
||||||
|
|
||||||
|
val flags =
|
||||||
|
Intent.FLAG_GRANT_WRITE_URI_PERMISSION or Intent.FLAG_GRANT_READ_URI_PERMISSION
|
||||||
|
|
||||||
|
val resInfoList = context.packageManager.queryIntentActivities(
|
||||||
|
intent, PackageManager.MATCH_DEFAULT_ONLY
|
||||||
|
)
|
||||||
|
|
||||||
|
for (resolveInfo in resInfoList) {
|
||||||
|
val packageName = resolveInfo.activityInfo.packageName
|
||||||
|
context.grantUriPermission(
|
||||||
|
packageName,
|
||||||
|
uri,
|
||||||
|
flags
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
activity?.startActivity(intent)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateExcludeFromRecents(value: Boolean?) {
|
||||||
|
val am = getSystemService(context, ActivityManager::class.java)
|
||||||
|
val task = am?.appTasks?.firstOrNull {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
|
it.taskInfo.taskId == activity?.taskId
|
||||||
|
} else {
|
||||||
|
it.taskInfo.id == activity?.taskId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
when (value) {
|
||||||
|
true -> task?.setExcludeFromRecents(value)
|
||||||
|
false -> task?.setExcludeFromRecents(value)
|
||||||
|
null -> task?.setExcludeFromRecents(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private suspend fun getPackageIcon(packageName: String): String? {
|
private suspend fun getPackageIcon(packageName: String): String? {
|
||||||
val packageManager = context?.packageManager
|
val packageManager = context.packageManager
|
||||||
if (iconMap[packageName] == null) {
|
if (iconMap[packageName] == null) {
|
||||||
iconMap[packageName] = try {
|
iconMap[packageName] = try {
|
||||||
packageManager?.getApplicationIcon(packageName)?.getBase64()
|
packageManager?.getApplicationIcon(packageName)?.getBase64()
|
||||||
@@ -173,37 +268,143 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
|||||||
return iconMap[packageName]
|
return iconMap[packageName]
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun getPackages(): String {
|
private fun getPackages(): List<Package> {
|
||||||
return withContext(Dispatchers.Default) {
|
val packageManager = context.packageManager
|
||||||
val packageManager = context?.packageManager
|
if (packages.isNotEmpty()) return packages;
|
||||||
val packages: List<Package>? =
|
packageManager?.getInstalledPackages(PackageManager.GET_META_DATA)?.filter {
|
||||||
packageManager?.getInstalledPackages(PackageManager.GET_META_DATA)?.filter {
|
it.packageName != context.packageName
|
||||||
it.packageName != context?.packageName
|
|| it.requestedPermissions?.contains(Manifest.permission.INTERNET) == true
|
||||||
|| it.requestedPermissions?.contains(Manifest.permission.INTERNET) == true
|
|| it.packageName == "android"
|
||||||
|| it.packageName == "android"
|
|
||||||
|
|
||||||
}?.map {
|
}?.map {
|
||||||
Package(
|
Package(
|
||||||
packageName = it.packageName,
|
packageName = it.packageName,
|
||||||
label = it.applicationInfo.loadLabel(packageManager).toString(),
|
label = it.applicationInfo.loadLabel(packageManager).toString(),
|
||||||
isSystem = (it.applicationInfo.flags and ApplicationInfo.FLAG_SYSTEM) == 1
|
isSystem = (it.applicationInfo.flags and ApplicationInfo.FLAG_SYSTEM) == 1,
|
||||||
)
|
firstInstallTime = it.firstInstallTime
|
||||||
}
|
)
|
||||||
|
}?.let { packages.addAll(it) }
|
||||||
|
return packages;
|
||||||
|
}
|
||||||
|
|
||||||
|
private suspend fun getPackagesToJson(): String {
|
||||||
|
return withContext(Dispatchers.Default) {
|
||||||
|
Gson().toJson(getPackages())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private suspend fun getChinaPackageNames(): String {
|
||||||
|
return withContext(Dispatchers.Default) {
|
||||||
|
val packages: List<String> =
|
||||||
|
getPackages().map { it.packageName }.filter { isChinaPackage(it) }
|
||||||
Gson().toJson(packages)
|
Gson().toJson(packages)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun requestGc() {
|
fun requestVpnPermission(context: Context, callBack: () -> Unit) {
|
||||||
channel.invokeMethod("gc", null)
|
vpnCallBack = callBack
|
||||||
|
val intent = VpnService.prepare(context)
|
||||||
|
if (intent != null) {
|
||||||
|
activity?.startActivityForResult(intent, VPN_PERMISSION_REQUEST_CODE)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
vpnCallBack?.invoke()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun requestNotificationsPermission(context: Context) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
val permission = ContextCompat.checkSelfPermission(
|
||||||
|
context,
|
||||||
|
Manifest.permission.POST_NOTIFICATIONS
|
||||||
|
)
|
||||||
|
if (permission != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
if (isBlockNotification) return
|
||||||
|
if (activity == null) return
|
||||||
|
ActivityCompat.requestPermissions(
|
||||||
|
activity!!,
|
||||||
|
arrayOf(Manifest.permission.POST_NOTIFICATIONS),
|
||||||
|
NOTIFICATION_PERMISSION_REQUEST_CODE
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun isChinaPackage(packageName: String): Boolean {
|
||||||
|
val packageManager = context.packageManager ?: return false
|
||||||
|
skipPrefixList.forEach {
|
||||||
|
if (packageName == it || packageName.startsWith("$it.")) return false
|
||||||
|
}
|
||||||
|
val packageManagerFlags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
PackageManager.MATCH_UNINSTALLED_PACKAGES or PackageManager.GET_ACTIVITIES or PackageManager.GET_SERVICES or PackageManager.GET_RECEIVERS or PackageManager.GET_PROVIDERS
|
||||||
|
} else {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
PackageManager.GET_UNINSTALLED_PACKAGES or PackageManager.GET_ACTIVITIES or PackageManager.GET_SERVICES or PackageManager.GET_RECEIVERS or PackageManager.GET_PROVIDERS
|
||||||
|
}
|
||||||
|
if (packageName.matches(chinaAppRegex)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
val packageInfo = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
packageManager.getPackageInfo(
|
||||||
|
packageName,
|
||||||
|
PackageManager.PackageInfoFlags.of(packageManagerFlags.toLong())
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
@Suppress("DEPRECATION") packageManager.getPackageInfo(
|
||||||
|
packageName, packageManagerFlags
|
||||||
|
)
|
||||||
|
}
|
||||||
|
mutableListOf<ComponentInfo>().apply {
|
||||||
|
packageInfo.services?.let { addAll(it) }
|
||||||
|
packageInfo.activities?.let { addAll(it) }
|
||||||
|
packageInfo.receivers?.let { addAll(it) }
|
||||||
|
packageInfo.providers?.let { addAll(it) }
|
||||||
|
}.forEach {
|
||||||
|
if (it.name.matches(chinaAppRegex)) return true
|
||||||
|
}
|
||||||
|
ZipFile(File(packageInfo.applicationInfo.publicSourceDir)).use {
|
||||||
|
for (packageEntry in it.entries()) {
|
||||||
|
if (packageEntry.name.startsWith("firebase-")) return false
|
||||||
|
}
|
||||||
|
for (packageEntry in it.entries()) {
|
||||||
|
if (!(packageEntry.name.startsWith("classes") && packageEntry.name.endsWith(
|
||||||
|
".dex"
|
||||||
|
))
|
||||||
|
) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (packageEntry.size > 15000000) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
val input = it.getInputStream(packageEntry).buffered()
|
||||||
|
val dexFile = try {
|
||||||
|
DexBackedDexFile.fromInputStream(null, input)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for (clazz in dexFile.classes) {
|
||||||
|
val clazzName =
|
||||||
|
clazz.type.substring(1, clazz.type.length - 1).replace("/", ".")
|
||||||
|
.replace("$", ".")
|
||||||
|
if (clazzName.matches(chinaAppRegex)) return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (_: Exception) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAttachedToActivity(binding: ActivityPluginBinding) {
|
override fun onAttachedToActivity(binding: ActivityPluginBinding) {
|
||||||
activity = binding.activity;
|
activity = binding.activity;
|
||||||
scope = CoroutineScope(Dispatchers.Default)
|
binding.addActivityResultListener(::onActivityResult)
|
||||||
|
binding.addRequestPermissionsResultListener(::onRequestPermissionsResultListener)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDetachedFromActivityForConfigChanges() {
|
override fun onDetachedFromActivityForConfigChanges() {
|
||||||
activity = null;
|
activity = null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) {
|
override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) {
|
||||||
@@ -212,7 +413,27 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
|
|||||||
|
|
||||||
override fun onDetachedFromActivity() {
|
override fun onDetachedFromActivity() {
|
||||||
channel.invokeMethod("exit", null)
|
channel.invokeMethod("exit", null)
|
||||||
scope.cancel()
|
activity = null
|
||||||
activity = null;
|
}
|
||||||
|
|
||||||
|
private fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?): Boolean {
|
||||||
|
if (requestCode == VPN_PERMISSION_REQUEST_CODE) {
|
||||||
|
if (resultCode == FlutterActivity.RESULT_OK) {
|
||||||
|
GlobalState.initServiceEngine(context)
|
||||||
|
vpnCallBack?.invoke()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun onRequestPermissionsResultListener(
|
||||||
|
requestCode: Int,
|
||||||
|
permissions: Array<String>,
|
||||||
|
grantResults: IntArray
|
||||||
|
): Boolean {
|
||||||
|
if (requestCode == NOTIFICATION_PERMISSION_REQUEST_CODE) {
|
||||||
|
isBlockNotification = true
|
||||||
|
}
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,220 +0,0 @@
|
|||||||
package com.follow.clash.plugins
|
|
||||||
|
|
||||||
import android.Manifest
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.app.Activity
|
|
||||||
import android.content.ComponentName
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.Intent
|
|
||||||
import android.content.ServiceConnection
|
|
||||||
import android.content.pm.PackageManager
|
|
||||||
import android.net.VpnService
|
|
||||||
import android.os.Build.VERSION
|
|
||||||
import android.os.Build.VERSION_CODES
|
|
||||||
import android.os.IBinder
|
|
||||||
import androidx.core.app.ActivityCompat
|
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import com.follow.clash.GlobalState
|
|
||||||
import com.follow.clash.RunState
|
|
||||||
import com.follow.clash.models.Props
|
|
||||||
import com.follow.clash.services.FlClashVpnService
|
|
||||||
import com.google.gson.Gson
|
|
||||||
import io.flutter.embedding.android.FlutterActivity
|
|
||||||
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
|
||||||
import io.flutter.embedding.engine.plugins.activity.ActivityAware
|
|
||||||
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
|
|
||||||
import io.flutter.plugin.common.MethodCall
|
|
||||||
import io.flutter.plugin.common.MethodChannel
|
|
||||||
|
|
||||||
|
|
||||||
class ProxyPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware {
|
|
||||||
|
|
||||||
|
|
||||||
val VPN_PERMISSION_REQUEST_CODE = 1001
|
|
||||||
val NOTIFICATION_PERMISSION_REQUEST_CODE = 1002
|
|
||||||
|
|
||||||
private lateinit var flutterMethodChannel: MethodChannel
|
|
||||||
|
|
||||||
private var activity: Activity? = null
|
|
||||||
private var context: Context? = null
|
|
||||||
private var flClashVpnService: FlClashVpnService? = null
|
|
||||||
private var isBound = false
|
|
||||||
private var port: Int? = null
|
|
||||||
private var props: Props? = null
|
|
||||||
private lateinit var title: String
|
|
||||||
private lateinit var content: String
|
|
||||||
|
|
||||||
private val connection = object : ServiceConnection {
|
|
||||||
override fun onServiceConnected(className: ComponentName, service: IBinder) {
|
|
||||||
val binder = service as FlClashVpnService.LocalBinder
|
|
||||||
flClashVpnService = binder.getService()
|
|
||||||
port?.let { startVpn(it) }
|
|
||||||
isBound = true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onServiceDisconnected(arg0: ComponentName) {
|
|
||||||
flClashVpnService = null
|
|
||||||
isBound = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
|
||||||
context = flutterPluginBinding.applicationContext
|
|
||||||
flutterMethodChannel = MethodChannel(flutterPluginBinding.binaryMessenger, "proxy")
|
|
||||||
flutterMethodChannel.setMethodCallHandler(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDetachedFromEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
|
||||||
flutterMethodChannel.setMethodCallHandler(null)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) = when (call.method) {
|
|
||||||
"StartProxy" -> {
|
|
||||||
port = call.argument<Int>("port")
|
|
||||||
val args = call.argument<String>("args")
|
|
||||||
props =
|
|
||||||
if (args != null) Gson().fromJson(args, Props::class.java) else null
|
|
||||||
handleStartVpn()
|
|
||||||
result.success(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
"StopProxy" -> {
|
|
||||||
stopVpn()
|
|
||||||
result.success(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
"SetProtect" -> {
|
|
||||||
val fd = call.argument<Int>("fd")
|
|
||||||
if (fd != null) {
|
|
||||||
flClashVpnService?.protect(fd)
|
|
||||||
result.success(true)
|
|
||||||
} else {
|
|
||||||
result.success(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
"startForeground" -> {
|
|
||||||
title = call.argument<String>("title") as String
|
|
||||||
content = call.argument<String>("content") as String
|
|
||||||
requestNotificationsPermission()
|
|
||||||
result.success(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> {
|
|
||||||
result.notImplemented()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun handleStartVpn() {
|
|
||||||
val intent = VpnService.prepare(context)
|
|
||||||
if (intent != null) {
|
|
||||||
activity?.startActivityForResult(intent, VPN_PERMISSION_REQUEST_CODE)
|
|
||||||
} else {
|
|
||||||
bindService()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun startVpn(port: Int) {
|
|
||||||
if (GlobalState.runState.value == RunState.START) return;
|
|
||||||
flClashVpnService?.start(port, props)
|
|
||||||
GlobalState.runState.value = RunState.START
|
|
||||||
startAfter()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun stopVpn() {
|
|
||||||
if (GlobalState.runState.value == RunState.STOP) return
|
|
||||||
flClashVpnService?.stop()
|
|
||||||
unbindService()
|
|
||||||
GlobalState.runState.value = RunState.STOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("ForegroundServiceType")
|
|
||||||
private fun startForeground() {
|
|
||||||
if (GlobalState.runState.value != RunState.START) return
|
|
||||||
flClashVpnService?.startForeground(title, content)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun requestNotificationsPermission() {
|
|
||||||
if (VERSION.SDK_INT >= VERSION_CODES.TIRAMISU) {
|
|
||||||
val permission = context?.let {
|
|
||||||
ContextCompat.checkSelfPermission(
|
|
||||||
it,
|
|
||||||
Manifest.permission.POST_NOTIFICATIONS
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if (permission == PackageManager.PERMISSION_GRANTED) {
|
|
||||||
startForeground()
|
|
||||||
} else {
|
|
||||||
activity?.let {
|
|
||||||
ActivityCompat.requestPermissions(
|
|
||||||
it,
|
|
||||||
arrayOf(Manifest.permission.POST_NOTIFICATIONS),
|
|
||||||
NOTIFICATION_PERMISSION_REQUEST_CODE
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
startForeground()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun startAfter() {
|
|
||||||
flutterMethodChannel.invokeMethod("startAfter", flClashVpnService?.fd)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onAttachedToActivity(binding: ActivityPluginBinding) {
|
|
||||||
activity = binding.activity
|
|
||||||
binding.addActivityResultListener(::onActivityResult)
|
|
||||||
binding.addRequestPermissionsResultListener(::onRequestPermissionsResultListener)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?): Boolean {
|
|
||||||
if (requestCode == VPN_PERMISSION_REQUEST_CODE) {
|
|
||||||
if (resultCode == FlutterActivity.RESULT_OK) {
|
|
||||||
bindService()
|
|
||||||
} else {
|
|
||||||
stopVpn()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun onRequestPermissionsResultListener(
|
|
||||||
requestCode: Int,
|
|
||||||
permissions: Array<String>,
|
|
||||||
grantResults: IntArray
|
|
||||||
): Boolean {
|
|
||||||
if (requestCode == NOTIFICATION_PERMISSION_REQUEST_CODE) {
|
|
||||||
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
|
||||||
startForeground()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
override fun onDetachedFromActivityForConfigChanges() {
|
|
||||||
activity = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) {
|
|
||||||
activity = binding.activity
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDetachedFromActivity() {
|
|
||||||
stopVpn()
|
|
||||||
activity = null
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun bindService() {
|
|
||||||
val intent = Intent(context, FlClashVpnService::class.java)
|
|
||||||
context?.bindService(intent, connection, Context.BIND_AUTO_CREATE)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun unbindService() {
|
|
||||||
if (isBound) {
|
|
||||||
context?.unbindService(connection)
|
|
||||||
isBound = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package com.follow.clash.plugins
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.net.ConnectivityManager
|
||||||
|
import androidx.core.content.getSystemService
|
||||||
|
import com.follow.clash.GlobalState
|
||||||
|
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
||||||
|
import io.flutter.plugin.common.MethodCall
|
||||||
|
import io.flutter.plugin.common.MethodChannel
|
||||||
|
|
||||||
|
|
||||||
|
class ServicePlugin : FlutterPlugin, MethodChannel.MethodCallHandler {
|
||||||
|
|
||||||
|
private lateinit var flutterMethodChannel: MethodChannel
|
||||||
|
|
||||||
|
private lateinit var context: Context
|
||||||
|
|
||||||
|
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
||||||
|
context = flutterPluginBinding.applicationContext
|
||||||
|
flutterMethodChannel = MethodChannel(flutterPluginBinding.binaryMessenger, "service")
|
||||||
|
flutterMethodChannel.setMethodCallHandler(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDetachedFromEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
||||||
|
flutterMethodChannel.setMethodCallHandler(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) = when (call.method) {
|
||||||
|
"init" -> {
|
||||||
|
GlobalState.getCurrentAppPlugin()?.requestNotificationsPermission(context)
|
||||||
|
GlobalState.initServiceEngine(context)
|
||||||
|
result.success(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
"destroy" -> {
|
||||||
|
handleDestroy()
|
||||||
|
result.success(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
result.notImplemented()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun handleDestroy() {
|
||||||
|
GlobalState.getCurrentVPNPlugin()?.stop()
|
||||||
|
GlobalState.destroyServiceEngine()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
package com.follow.clash.plugins
|
package com.follow.clash.plugins
|
||||||
|
|
||||||
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
||||||
|
|||||||
@@ -0,0 +1,265 @@
|
|||||||
|
package com.follow.clash.plugins
|
||||||
|
|
||||||
|
import android.content.ComponentName
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.ServiceConnection
|
||||||
|
import android.net.ConnectivityManager
|
||||||
|
import android.net.Network
|
||||||
|
import android.net.NetworkCapabilities
|
||||||
|
import android.net.NetworkRequest
|
||||||
|
import android.os.Build
|
||||||
|
import android.os.IBinder
|
||||||
|
import androidx.core.content.getSystemService
|
||||||
|
import com.follow.clash.BaseServiceInterface
|
||||||
|
import com.follow.clash.GlobalState
|
||||||
|
import com.follow.clash.RunState
|
||||||
|
import com.follow.clash.extensions.getProtocol
|
||||||
|
import com.follow.clash.extensions.resolveDns
|
||||||
|
import com.follow.clash.services.FlClashService
|
||||||
|
import com.follow.clash.services.FlClashVpnService
|
||||||
|
import com.google.gson.Gson
|
||||||
|
import io.flutter.embedding.engine.plugins.FlutterPlugin
|
||||||
|
import io.flutter.plugin.common.MethodCall
|
||||||
|
import io.flutter.plugin.common.MethodChannel
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
|
import java.net.InetSocketAddress
|
||||||
|
import kotlin.concurrent.withLock
|
||||||
|
import com.follow.clash.models.Process
|
||||||
|
import com.follow.clash.models.VpnOptions
|
||||||
|
|
||||||
|
|
||||||
|
class VpnPlugin : FlutterPlugin, MethodChannel.MethodCallHandler {
|
||||||
|
private lateinit var flutterMethodChannel: MethodChannel
|
||||||
|
private lateinit var context: Context
|
||||||
|
private var flClashService: BaseServiceInterface? = null
|
||||||
|
private lateinit var options: VpnOptions
|
||||||
|
private lateinit var scope: CoroutineScope
|
||||||
|
|
||||||
|
private val connectivity by lazy {
|
||||||
|
context.getSystemService<ConnectivityManager>()
|
||||||
|
}
|
||||||
|
|
||||||
|
private val connection = object : ServiceConnection {
|
||||||
|
override fun onServiceConnected(className: ComponentName, service: IBinder) {
|
||||||
|
flClashService = when (service) {
|
||||||
|
is FlClashVpnService.LocalBinder -> service.getService()
|
||||||
|
is FlClashService.LocalBinder -> service.getService()
|
||||||
|
else -> throw Exception("invalid binder")
|
||||||
|
}
|
||||||
|
start()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onServiceDisconnected(arg: ComponentName) {
|
||||||
|
flClashService = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
||||||
|
scope = CoroutineScope(Dispatchers.Default)
|
||||||
|
context = flutterPluginBinding.applicationContext
|
||||||
|
scope.launch {
|
||||||
|
registerNetworkCallback()
|
||||||
|
}
|
||||||
|
flutterMethodChannel = MethodChannel(flutterPluginBinding.binaryMessenger, "vpn")
|
||||||
|
flutterMethodChannel.setMethodCallHandler(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDetachedFromEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
|
||||||
|
unRegisterNetworkCallback()
|
||||||
|
flutterMethodChannel.setMethodCallHandler(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
|
||||||
|
when (call.method) {
|
||||||
|
"start" -> {
|
||||||
|
val data = call.argument<String>("data")
|
||||||
|
options = Gson().fromJson(data, VpnOptions::class.java)
|
||||||
|
when (options.enable) {
|
||||||
|
true -> handleStartVpn()
|
||||||
|
false -> start()
|
||||||
|
}
|
||||||
|
result.success(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
"stop" -> {
|
||||||
|
stop()
|
||||||
|
result.success(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
"setProtect" -> {
|
||||||
|
val fd = call.argument<Int>("fd")
|
||||||
|
if (fd != null) {
|
||||||
|
if (flClashService is FlClashVpnService) {
|
||||||
|
(flClashService as FlClashVpnService).protect(fd)
|
||||||
|
}
|
||||||
|
result.success(true)
|
||||||
|
} else {
|
||||||
|
result.success(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
"startForeground" -> {
|
||||||
|
val title = call.argument<String>("title") as String
|
||||||
|
val content = call.argument<String>("content") as String
|
||||||
|
startForeground(title, content)
|
||||||
|
result.success(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
"resolverProcess" -> {
|
||||||
|
val data = call.argument<String>("data")
|
||||||
|
val process =
|
||||||
|
if (data != null) Gson().fromJson(
|
||||||
|
data,
|
||||||
|
Process::class.java
|
||||||
|
) else null
|
||||||
|
val metadata = process?.metadata
|
||||||
|
if (metadata == null) {
|
||||||
|
result.success(null)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val protocol = metadata.getProtocol()
|
||||||
|
if (protocol == null) {
|
||||||
|
result.success(null)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
scope.launch {
|
||||||
|
withContext(Dispatchers.Default) {
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||||
|
result.success(null)
|
||||||
|
return@withContext
|
||||||
|
}
|
||||||
|
val src = InetSocketAddress(metadata.sourceIP, metadata.sourcePort)
|
||||||
|
val dst = InetSocketAddress(
|
||||||
|
metadata.destinationIP.ifEmpty { metadata.host },
|
||||||
|
metadata.destinationPort
|
||||||
|
)
|
||||||
|
val uid = try {
|
||||||
|
connectivity?.getConnectionOwnerUid(protocol, src, dst)
|
||||||
|
} catch (_: Exception) {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
if (uid == null || uid == -1) {
|
||||||
|
result.success(null)
|
||||||
|
return@withContext
|
||||||
|
}
|
||||||
|
val packages = context.packageManager?.getPackagesForUid(uid)
|
||||||
|
result.success(packages?.first())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
result.notImplemented()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun handleStartVpn() {
|
||||||
|
GlobalState.getCurrentAppPlugin()?.requestVpnPermission(context) {
|
||||||
|
start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun requestGc() {
|
||||||
|
flutterMethodChannel.invokeMethod("gc", null)
|
||||||
|
}
|
||||||
|
|
||||||
|
val networks = mutableSetOf<Network>()
|
||||||
|
|
||||||
|
fun onUpdateNetwork() {
|
||||||
|
val dns = networks.flatMap { network ->
|
||||||
|
connectivity?.resolveDns(network) ?: emptyList()
|
||||||
|
}
|
||||||
|
.toSet()
|
||||||
|
.joinToString(",")
|
||||||
|
scope.launch {
|
||||||
|
withContext(Dispatchers.Main) {
|
||||||
|
flutterMethodChannel.invokeMethod("dnsChanged", dns)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if (flClashService is FlClashVpnService) {
|
||||||
|
// val network = networks.maxByOrNull { net ->
|
||||||
|
// connectivity?.getNetworkCapabilities(net)?.let { cap ->
|
||||||
|
// TRANSPORT_PRIORITY.indexOfFirst { cap.hasTransport(it) }
|
||||||
|
// } ?: -1
|
||||||
|
// }
|
||||||
|
// network?.let {
|
||||||
|
// (flClashService as FlClashVpnService).updateUnderlyingNetworks(arrayOf(network))
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
private val callback = object : ConnectivityManager.NetworkCallback() {
|
||||||
|
override fun onAvailable(network: Network) {
|
||||||
|
networks.add(network)
|
||||||
|
onUpdateNetwork()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onLost(network: Network) {
|
||||||
|
networks.remove(network)
|
||||||
|
onUpdateNetwork()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val request = NetworkRequest.Builder().apply {
|
||||||
|
addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)
|
||||||
|
addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
|
||||||
|
addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED)
|
||||||
|
}.build()
|
||||||
|
|
||||||
|
private fun registerNetworkCallback() {
|
||||||
|
networks.clear()
|
||||||
|
connectivity?.registerNetworkCallback(request, callback)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun unRegisterNetworkCallback() {
|
||||||
|
connectivity?.unregisterNetworkCallback(callback)
|
||||||
|
networks.clear()
|
||||||
|
onUpdateNetwork()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun startForeground(title: String, content: String) {
|
||||||
|
GlobalState.runLock.withLock {
|
||||||
|
if (GlobalState.runState.value != RunState.START) return
|
||||||
|
flClashService?.startForeground(title, content)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun start() {
|
||||||
|
if (flClashService == null) {
|
||||||
|
bindService()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
GlobalState.runLock.withLock {
|
||||||
|
if (GlobalState.runState.value == RunState.START) return
|
||||||
|
GlobalState.runState.value = RunState.START
|
||||||
|
val fd = flClashService?.start(options)
|
||||||
|
flutterMethodChannel.invokeMethod(
|
||||||
|
"started",
|
||||||
|
fd
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun stop() {
|
||||||
|
GlobalState.runLock.withLock {
|
||||||
|
if (GlobalState.runState.value == RunState.STOP) return
|
||||||
|
GlobalState.runState.value = RunState.STOP
|
||||||
|
flClashService?.stop()
|
||||||
|
}
|
||||||
|
GlobalState.destroyServiceEngine()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun bindService() {
|
||||||
|
val intent = when (options.enable) {
|
||||||
|
true -> Intent(context, FlClashVpnService::class.java)
|
||||||
|
false -> Intent(context, FlClashService::class.java)
|
||||||
|
}
|
||||||
|
context.bindService(intent, connection, Context.BIND_AUTO_CREATE)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
package com.follow.clash.services
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.app.Notification.FOREGROUND_SERVICE_IMMEDIATE
|
||||||
|
import android.app.NotificationChannel
|
||||||
|
import android.app.NotificationManager
|
||||||
|
import android.app.PendingIntent
|
||||||
|
import android.app.Service
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE
|
||||||
|
import android.os.Binder
|
||||||
|
import android.os.Build
|
||||||
|
import android.os.IBinder
|
||||||
|
import androidx.core.app.NotificationCompat
|
||||||
|
import com.follow.clash.BaseServiceInterface
|
||||||
|
import com.follow.clash.MainActivity
|
||||||
|
import com.follow.clash.models.VpnOptions
|
||||||
|
|
||||||
|
|
||||||
|
class FlClashService : Service(), BaseServiceInterface {
|
||||||
|
|
||||||
|
private val binder = LocalBinder()
|
||||||
|
|
||||||
|
inner class LocalBinder : Binder() {
|
||||||
|
fun getService(): FlClashService = this@FlClashService
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBind(intent: Intent): IBinder {
|
||||||
|
return binder
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onUnbind(intent: Intent?): Boolean {
|
||||||
|
return super.onUnbind(intent)
|
||||||
|
}
|
||||||
|
|
||||||
|
private val CHANNEL = "FlClash"
|
||||||
|
|
||||||
|
private val notificationId: Int = 1
|
||||||
|
|
||||||
|
private val notificationBuilder: NotificationCompat.Builder by lazy {
|
||||||
|
val intent = Intent(this, MainActivity::class.java)
|
||||||
|
|
||||||
|
val pendingIntent = if (Build.VERSION.SDK_INT >= 31) {
|
||||||
|
PendingIntent.getActivity(
|
||||||
|
this,
|
||||||
|
0,
|
||||||
|
intent,
|
||||||
|
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
PendingIntent.getActivity(
|
||||||
|
this,
|
||||||
|
0,
|
||||||
|
intent,
|
||||||
|
PendingIntent.FLAG_UPDATE_CURRENT
|
||||||
|
)
|
||||||
|
}
|
||||||
|
with(NotificationCompat.Builder(this, CHANNEL)) {
|
||||||
|
setSmallIcon(com.follow.clash.R.drawable.ic_stat_name)
|
||||||
|
setContentTitle("FlClash")
|
||||||
|
setContentIntent(pendingIntent)
|
||||||
|
setCategory(NotificationCompat.CATEGORY_SERVICE)
|
||||||
|
priority = NotificationCompat.PRIORITY_MIN
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||||
|
foregroundServiceBehavior = FOREGROUND_SERVICE_IMMEDIATE
|
||||||
|
}
|
||||||
|
setOngoing(true)
|
||||||
|
setShowWhen(false)
|
||||||
|
setOnlyAlertOnce(true)
|
||||||
|
setAutoCancel(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun start(options: VpnOptions) = 0
|
||||||
|
|
||||||
|
override fun stop() {
|
||||||
|
stopSelf()
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
|
stopForeground(STOP_FOREGROUND_REMOVE)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ForegroundServiceType", "WrongConstant")
|
||||||
|
override fun startForeground(title: String, content: String) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
val manager = getSystemService(NotificationManager::class.java)
|
||||||
|
var channel = manager?.getNotificationChannel(CHANNEL)
|
||||||
|
if (channel == null) {
|
||||||
|
channel =
|
||||||
|
NotificationChannel(CHANNEL, "FlClash", NotificationManager.IMPORTANCE_LOW)
|
||||||
|
manager?.createNotificationChannel(channel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val notification =
|
||||||
|
notificationBuilder.setContentTitle(title).setContentText(content).build()
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||||
|
startForeground(notificationId, notification, FOREGROUND_SERVICE_TYPE_SPECIAL_USE)
|
||||||
|
} else {
|
||||||
|
startForeground(notificationId, notification)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import android.annotation.SuppressLint
|
|||||||
import android.app.PendingIntent
|
import android.app.PendingIntent
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
import android.os.IBinder
|
||||||
import android.service.quicksettings.Tile
|
import android.service.quicksettings.Tile
|
||||||
import android.service.quicksettings.TileService
|
import android.service.quicksettings.TileService
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
@@ -11,14 +12,9 @@ import androidx.lifecycle.Observer
|
|||||||
import com.follow.clash.GlobalState
|
import com.follow.clash.GlobalState
|
||||||
import com.follow.clash.RunState
|
import com.follow.clash.RunState
|
||||||
import com.follow.clash.TempActivity
|
import com.follow.clash.TempActivity
|
||||||
import com.follow.clash.plugins.AppPlugin
|
|
||||||
import com.follow.clash.plugins.ProxyPlugin
|
|
||||||
import com.follow.clash.plugins.TilePlugin
|
|
||||||
import io.flutter.FlutterInjector
|
|
||||||
import io.flutter.embedding.engine.FlutterEngine
|
|
||||||
import io.flutter.embedding.engine.dart.DartExecutor
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.N)
|
||||||
class FlClashTileService : TileService() {
|
class FlClashTileService : TileService() {
|
||||||
|
|
||||||
private val observer = Observer<RunState> { runState ->
|
private val observer = Observer<RunState> { runState ->
|
||||||
@@ -42,6 +38,7 @@ class FlClashTileService : TileService() {
|
|||||||
GlobalState.runState.observeForever(observer)
|
GlobalState.runState.observeForever(observer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("StartActivityAndCollapseDeprecated")
|
||||||
private fun activityTransfer() {
|
private fun activityTransfer() {
|
||||||
val intent = Intent(this, TempActivity::class.java)
|
val intent = Intent(this, TempActivity::class.java)
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_MULTIPLE_TASK)
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_MULTIPLE_TASK)
|
||||||
@@ -62,42 +59,25 @@ class FlClashTileService : TileService() {
|
|||||||
}
|
}
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||||
startActivityAndCollapse(pendingIntent)
|
startActivityAndCollapse(pendingIntent)
|
||||||
}else{
|
} else {
|
||||||
startActivityAndCollapse(intent)
|
startActivityAndCollapse(intent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var flutterEngine: FlutterEngine? = null;
|
|
||||||
|
|
||||||
private fun initFlutterEngine() {
|
|
||||||
flutterEngine = FlutterEngine(this)
|
|
||||||
flutterEngine?.plugins?.add(ProxyPlugin())
|
|
||||||
flutterEngine?.plugins?.add(TilePlugin())
|
|
||||||
flutterEngine?.plugins?.add(AppPlugin())
|
|
||||||
GlobalState.flutterEngine = flutterEngine
|
|
||||||
if (flutterEngine?.dartExecutor?.isExecutingDart != true) {
|
|
||||||
val vpnService = DartExecutor.DartEntrypoint(
|
|
||||||
FlutterInjector.instance().flutterLoader().findAppBundlePath(),
|
|
||||||
"vpnService"
|
|
||||||
)
|
|
||||||
flutterEngine?.dartExecutor?.executeDartEntrypoint(vpnService)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onClick() {
|
override fun onClick() {
|
||||||
super.onClick()
|
super.onClick()
|
||||||
activityTransfer()
|
activityTransfer()
|
||||||
val currentTilePlugin = GlobalState.getCurrentTilePlugin()
|
|
||||||
if (GlobalState.runState.value == RunState.STOP) {
|
if (GlobalState.runState.value == RunState.STOP) {
|
||||||
GlobalState.runState.value = RunState.PENDING
|
GlobalState.runState.value = RunState.PENDING
|
||||||
if(currentTilePlugin == null){
|
val tilePlugin = GlobalState.getCurrentTilePlugin()
|
||||||
initFlutterEngine()
|
if (tilePlugin != null) {
|
||||||
}else{
|
tilePlugin.handleStart()
|
||||||
currentTilePlugin.handleStart()
|
} else {
|
||||||
|
GlobalState.initServiceEngine(applicationContext)
|
||||||
}
|
}
|
||||||
} else if(GlobalState.runState.value == RunState.START){
|
} else if (GlobalState.runState.value == RunState.START) {
|
||||||
GlobalState.runState.value = RunState.PENDING
|
GlobalState.runState.value = RunState.PENDING
|
||||||
currentTilePlugin?.handleStop()
|
GlobalState.getCurrentTilePlugin()?.handleStop()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,62 +1,55 @@
|
|||||||
package com.follow.clash.services
|
package com.follow.clash.services
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.app.Notification.FOREGROUND_SERVICE_IMMEDIATE
|
import android.app.Notification.FOREGROUND_SERVICE_IMMEDIATE
|
||||||
import android.app.NotificationChannel
|
import android.app.NotificationChannel
|
||||||
import android.app.NotificationManager
|
import android.app.NotificationManager
|
||||||
import android.app.PendingIntent
|
import android.app.PendingIntent
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE
|
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE
|
||||||
|
import android.net.Network
|
||||||
import android.net.ProxyInfo
|
import android.net.ProxyInfo
|
||||||
import android.net.VpnService
|
import android.net.VpnService
|
||||||
import android.os.Binder
|
import android.os.Binder
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
|
import android.os.Parcel
|
||||||
|
import android.os.RemoteException
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
|
import com.follow.clash.BaseServiceInterface
|
||||||
import com.follow.clash.GlobalState
|
import com.follow.clash.GlobalState
|
||||||
import com.follow.clash.MainActivity
|
import com.follow.clash.MainActivity
|
||||||
import com.follow.clash.R
|
import com.follow.clash.R
|
||||||
|
import com.follow.clash.TempActivity
|
||||||
|
import com.follow.clash.extensions.toCIDR
|
||||||
import com.follow.clash.models.AccessControlMode
|
import com.follow.clash.models.AccessControlMode
|
||||||
import com.follow.clash.models.Props
|
import com.follow.clash.models.VpnOptions
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
|
||||||
class FlClashVpnService : VpnService() {
|
class FlClashVpnService : VpnService(), BaseServiceInterface {
|
||||||
|
override fun onCreate() {
|
||||||
|
super.onCreate()
|
||||||
private val CHANNEL = "FlClash"
|
GlobalState.initServiceEngine(applicationContext)
|
||||||
|
|
||||||
var fd: Int? = null
|
|
||||||
private val notificationId: Int = 1
|
|
||||||
|
|
||||||
private val passList = listOf(
|
|
||||||
"*zhihu.com",
|
|
||||||
"*zhimg.com",
|
|
||||||
"*jd.com",
|
|
||||||
"100ime-iat-api.xfyun.cn",
|
|
||||||
"*360buyimg.com",
|
|
||||||
"localhost",
|
|
||||||
"*.local",
|
|
||||||
"127.*",
|
|
||||||
"10.*",
|
|
||||||
"172.16.*",
|
|
||||||
"172.17.*",
|
|
||||||
"172.18.*",
|
|
||||||
"172.19.*",
|
|
||||||
"172.2*",
|
|
||||||
"172.30.*",
|
|
||||||
"172.31.*",
|
|
||||||
"192.168.*"
|
|
||||||
)
|
|
||||||
|
|
||||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
|
||||||
return START_STICKY
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun start(port: Int, props: Props?) {
|
override fun start(options: VpnOptions): Int {
|
||||||
fd = with(Builder()) {
|
return with(Builder()) {
|
||||||
addAddress("172.16.0.1", 30)
|
if (options.ipv4Address.isNotEmpty()) {
|
||||||
|
val cidr = options.ipv4Address.toCIDR()
|
||||||
|
addAddress(cidr.address, cidr.prefixLength)
|
||||||
|
addRoute("0.0.0.0", 0)
|
||||||
|
}
|
||||||
|
if (options.ipv6Address.isNotEmpty()) {
|
||||||
|
val cidr = options.ipv6Address.toCIDR()
|
||||||
|
addAddress(cidr.address, cidr.prefixLength)
|
||||||
|
addRoute("::", 0)
|
||||||
|
}
|
||||||
|
addDnsServer(options.dnsServerAddress)
|
||||||
setMtu(9000)
|
setMtu(9000)
|
||||||
addRoute("0.0.0.0", 0)
|
options.accessControl?.let { accessControl ->
|
||||||
props?.accessControl?.let { accessControl ->
|
|
||||||
when (accessControl.mode) {
|
when (accessControl.mode) {
|
||||||
AccessControlMode.acceptSelected -> {
|
AccessControlMode.acceptSelected -> {
|
||||||
(accessControl.acceptList + packageName).forEach {
|
(accessControl.acceptList + packageName).forEach {
|
||||||
@@ -71,33 +64,44 @@ class FlClashVpnService : VpnService() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addDnsServer("172.16.0.2")
|
|
||||||
setSession("FlClash")
|
setSession("FlClash")
|
||||||
setBlocking(false)
|
setBlocking(false)
|
||||||
if (Build.VERSION.SDK_INT >= 29) {
|
if (Build.VERSION.SDK_INT >= 29) {
|
||||||
setMetered(false)
|
setMetered(false)
|
||||||
}
|
}
|
||||||
if (props?.allowBypass == true) {
|
if (options.allowBypass) {
|
||||||
allowBypass()
|
allowBypass()
|
||||||
}
|
}
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && props?.systemProxy == true) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && options.systemProxy) {
|
||||||
setHttpProxy(
|
setHttpProxy(
|
||||||
ProxyInfo.buildDirectProxy(
|
ProxyInfo.buildDirectProxy(
|
||||||
"127.0.0.1",
|
"127.0.0.1",
|
||||||
port,
|
options.port,
|
||||||
passList
|
options.bypassDomain
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
establish()?.detachFd()
|
establish()?.detachFd()
|
||||||
|
?: throw NullPointerException("Establish VPN rejected by system")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun stop() {
|
fun updateUnderlyingNetworks(networks: Array<Network>) {
|
||||||
stopSelf()
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||||
stopForeground()
|
this.setUnderlyingNetworks(networks)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun stop() {
|
||||||
|
stopSelf()
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
|
stopForeground(STOP_FOREGROUND_REMOVE)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val CHANNEL = "FlClash"
|
||||||
|
|
||||||
|
private val notificationId: Int = 1
|
||||||
|
|
||||||
private val notificationBuilder: NotificationCompat.Builder by lazy {
|
private val notificationBuilder: NotificationCompat.Builder by lazy {
|
||||||
val intent = Intent(this, MainActivity::class.java)
|
val intent = Intent(this, MainActivity::class.java)
|
||||||
@@ -118,6 +122,26 @@ class FlClashVpnService : VpnService() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val stopIntent = Intent(this, TempActivity::class.java)
|
||||||
|
stopIntent.action = "com.follow.clash.action.STOP"
|
||||||
|
stopIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_MULTIPLE_TASK)
|
||||||
|
|
||||||
|
|
||||||
|
val stopPendingIntent = if (Build.VERSION.SDK_INT >= 31) {
|
||||||
|
PendingIntent.getActivity(
|
||||||
|
this,
|
||||||
|
0,
|
||||||
|
stopIntent,
|
||||||
|
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
PendingIntent.getActivity(
|
||||||
|
this,
|
||||||
|
0,
|
||||||
|
stopIntent,
|
||||||
|
PendingIntent.FLAG_UPDATE_CURRENT
|
||||||
|
)
|
||||||
|
}
|
||||||
with(NotificationCompat.Builder(this, CHANNEL)) {
|
with(NotificationCompat.Builder(this, CHANNEL)) {
|
||||||
setSmallIcon(R.drawable.ic_stat_name)
|
setSmallIcon(R.drawable.ic_stat_name)
|
||||||
setContentTitle("FlClash")
|
setContentTitle("FlClash")
|
||||||
@@ -130,16 +154,13 @@ class FlClashVpnService : VpnService() {
|
|||||||
setOngoing(true)
|
setOngoing(true)
|
||||||
setShowWhen(false)
|
setShowWhen(false)
|
||||||
setOnlyAlertOnce(true)
|
setOnlyAlertOnce(true)
|
||||||
setAutoCancel(true);
|
setAutoCancel(true)
|
||||||
|
addAction(0, "Stop", stopPendingIntent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTrimMemory(level: Int) {
|
@SuppressLint("ForegroundServiceType", "WrongConstant")
|
||||||
super.onTrimMemory(level)
|
override fun startForeground(title: String, content: String) {
|
||||||
GlobalState.getCurrentAppPlugin()?.requestGc()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun startForeground(title: String, content: String) {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
val manager = getSystemService(NotificationManager::class.java)
|
val manager = getSystemService(NotificationManager::class.java)
|
||||||
var channel = manager?.getNotificationChannel(CHANNEL)
|
var channel = manager?.getNotificationChannel(CHANNEL)
|
||||||
@@ -151,23 +172,36 @@ class FlClashVpnService : VpnService() {
|
|||||||
}
|
}
|
||||||
val notification =
|
val notification =
|
||||||
notificationBuilder.setContentTitle(title).setContentText(content).build()
|
notificationBuilder.setContentTitle(title).setContentText(content).build()
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||||
startForeground(notificationId, notification, FOREGROUND_SERVICE_TYPE_SPECIAL_USE)
|
startForeground(notificationId, notification, FOREGROUND_SERVICE_TYPE_SPECIAL_USE)
|
||||||
} else {
|
} else {
|
||||||
startForeground(notificationId, notification)
|
startForeground(notificationId, notification)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun stopForeground() {
|
override fun onTrimMemory(level: Int) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
super.onTrimMemory(level)
|
||||||
stopForeground(STOP_FOREGROUND_REMOVE)
|
GlobalState.getCurrentVPNPlugin()?.requestGc()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val binder = LocalBinder()
|
private val binder = LocalBinder()
|
||||||
|
|
||||||
inner class LocalBinder : Binder() {
|
inner class LocalBinder : Binder() {
|
||||||
fun getService(): FlClashVpnService = this@FlClashVpnService
|
fun getService(): FlClashVpnService = this@FlClashVpnService
|
||||||
|
|
||||||
|
override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean {
|
||||||
|
try {
|
||||||
|
val isSuccess = super.onTransact(code, data, reply, flags)
|
||||||
|
if (!isSuccess) {
|
||||||
|
CoroutineScope(Dispatchers.Main).launch {
|
||||||
|
GlobalState.getCurrentTilePlugin()?.handleStop()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return isSuccess
|
||||||
|
} catch (e: RemoteException) {
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBind(intent: Intent): IBinder {
|
override fun onBind(intent: Intent): IBinder {
|
||||||
@@ -175,7 +209,6 @@ class FlClashVpnService : VpnService() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onUnbind(intent: Intent?): Boolean {
|
override fun onUnbind(intent: Intent?): Boolean {
|
||||||
GlobalState.getCurrentTilePlugin()?.handleStop();
|
|
||||||
return super.onUnbind(intent)
|
return super.onUnbind(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 763 B After Width: | Height: | Size: 618 B |
|
Before Width: | Height: | Size: 520 B After Width: | Height: | Size: 423 B |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 803 B |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 1.6 KiB |
25
android/app/src/main/res/drawable/ic_launcher_foreground.xml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="240"
|
||||||
|
android:viewportHeight="240">
|
||||||
|
<group android:scaleX="0.924"
|
||||||
|
android:scaleY="0.924"
|
||||||
|
android:translateX="9.12"
|
||||||
|
android:translateY="9.12">
|
||||||
|
<group android:scaleX="0.63461536"
|
||||||
|
android:scaleY="0.63461536"
|
||||||
|
android:translateX="45.96154"
|
||||||
|
android:translateY="43.846153">
|
||||||
|
<path
|
||||||
|
android:pathData="M60.65,89.6L154.18,35.6A18,18 107.59,0 1,178.77 42.19L178.77,42.19A18,18 107.59,0 1,172.18 66.78L78.65,120.78A18,18 106.67,0 1,54.06 114.19L54.06,114.19A18,18 106.67,0 1,60.65 89.6z"
|
||||||
|
android:fillColor="#6666FB"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M84.65,131.17L131.42,104.17A18,18 107.83,0 1,156 110.76L156,110.76A18,18 107.83,0 1,149.42 135.35L102.65,162.35A18,18 106.67,0 1,78.06 155.76L78.06,155.76A18,18 106.67,0 1,84.65 131.17z"
|
||||||
|
android:fillColor="#336AB6"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M108.65,172.74L108.65,172.74A18,18 116.03,0 1,133.24 179.33L133.24,179.33A18,18 116.03,0 1,126.65 203.92L126.65,203.92A18,18 116.03,0 1,102.06 197.33L102.06,197.33A18,18 116.03,0 1,108.65 172.74z"
|
||||||
|
android:fillColor="#5CA8E9"/>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
</vector>
|
||||||
|
Before Width: | Height: | Size: 118 KiB |
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<background android:drawable="@color/ic_launcher_background"/>
|
<background android:drawable="@color/ic_launcher_background"/>
|
||||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||||
<monochrome android:drawable="@mipmap/ic_launcher_foreground" />
|
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
</adaptive-icon>
|
</adaptive-icon>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<background android:drawable="@color/ic_launcher_background"/>
|
<background android:drawable="@color/ic_launcher_background"/>
|
||||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||||
<monochrome android:drawable="@mipmap/ic_launcher_foreground" />
|
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
</adaptive-icon>
|
</adaptive-icon>
|
||||||
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 886 B |
|
Before Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 8.6 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 7.1 KiB |
@@ -6,7 +6,7 @@
|
|||||||
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
|
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
|
||||||
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
|
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
|
||||||
<item name="android:windowSplashScreenBackground" tools:targetApi="s">#121212</item>
|
<item name="android:windowSplashScreenBackground" tools:targetApi="s">#121212</item>
|
||||||
<item name="android:windowSplashScreenAnimatedIcon" tools:targetApi="s">@mipmap/ic_launcher_foreground</item>
|
<item name="android:windowSplashScreenAnimatedIcon" tools:targetApi="s">@drawable/ic_launcher_foreground</item>
|
||||||
<item name="postSplashScreenTheme">@style/NormalTheme</item>
|
<item name="postSplashScreenTheme">@style/NormalTheme</item>
|
||||||
</style>
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
|
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
|
||||||
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
|
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
|
||||||
<item name="android:windowSplashScreenBackground" tools:targetApi="s">@color/ic_launcher_background</item>
|
<item name="android:windowSplashScreenBackground" tools:targetApi="s">@color/ic_launcher_background</item>
|
||||||
<item name="android:windowSplashScreenAnimatedIcon" tools:targetApi="s">@mipmap/ic_launcher_foreground</item>
|
<item name="android:windowSplashScreenAnimatedIcon" tools:targetApi="s">@drawable/ic_launcher_foreground</item>
|
||||||
<item name="postSplashScreenTheme">@style/NormalTheme</item>
|
<item name="postSplashScreenTheme">@style/NormalTheme</item>
|
||||||
</style>
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<color name="ic_launcher_background">#EFEFEF</color>
|
<color name="ic_launcher_background">#FAFAFA</color>
|
||||||
</resources>
|
</resources>
|
||||||
6
android/app/src/main/res/xml/file_paths.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<paths>
|
||||||
|
<files-path
|
||||||
|
name="files"
|
||||||
|
path="."/>
|
||||||
|
</paths>
|
||||||
|
|
||||||
@@ -7,4 +7,8 @@
|
|||||||
<certificates src="user" />
|
<certificates src="user" />
|
||||||
</trust-anchors>
|
</trust-anchors>
|
||||||
</base-config>
|
</base-config>
|
||||||
|
<domain-config cleartextTrafficPermitted="true">
|
||||||
|
<domain includeSubdomains="true">localhost</domain>
|
||||||
|
<domain includeSubdomains="true">127.0.0.1</domain>
|
||||||
|
</domain-config>
|
||||||
</network-security-config>
|
</network-security-config>
|
||||||
BIN
assets/data/GeoIP.dat
Normal file
64257
assets/data/GeoSite.dat
BIN
assets/fonts/Icons.ttf
Normal file
BIN
assets/fonts/Twemoji.Mozilla.ttf
Normal file
|
Before Width: | Height: | Size: 9.4 KiB |
BIN
assets/images/avatars/arue.jpg
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
assets/images/avatars/june2.jpg
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
assets/images/icon.ico
Normal file
|
After Width: | Height: | Size: 9.5 KiB |
BIN
assets/images/icon.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
assets/images/icon_black.ico
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
assets/images/icon_black.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
assets/images/icon_white.ico
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
assets/images/icon_white.png
Normal file
|
After Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 118 KiB |
680
core/common.go
@@ -2,68 +2,52 @@ package main
|
|||||||
|
|
||||||
import "C"
|
import "C"
|
||||||
import (
|
import (
|
||||||
"github.com/metacubex/mihomo/adapter"
|
"context"
|
||||||
"github.com/metacubex/mihomo/adapter/inbound"
|
"core/state"
|
||||||
ap "github.com/metacubex/mihomo/adapter/provider"
|
"errors"
|
||||||
"github.com/metacubex/mihomo/component/dialer"
|
"fmt"
|
||||||
"github.com/metacubex/mihomo/component/resolver"
|
"github.com/metacubex/mihomo/constant/features"
|
||||||
"github.com/metacubex/mihomo/config"
|
|
||||||
"github.com/metacubex/mihomo/constant"
|
|
||||||
"github.com/metacubex/mihomo/hub"
|
|
||||||
"github.com/metacubex/mihomo/hub/executor"
|
|
||||||
"github.com/metacubex/mihomo/hub/route"
|
"github.com/metacubex/mihomo/hub/route"
|
||||||
"github.com/metacubex/mihomo/listener"
|
"github.com/samber/lo"
|
||||||
"github.com/metacubex/mihomo/log"
|
|
||||||
"github.com/metacubex/mihomo/tunnel"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/metacubex/mihomo/adapter"
|
||||||
|
"github.com/metacubex/mihomo/adapter/inbound"
|
||||||
|
"github.com/metacubex/mihomo/adapter/outboundgroup"
|
||||||
|
"github.com/metacubex/mihomo/adapter/provider"
|
||||||
|
"github.com/metacubex/mihomo/common/batch"
|
||||||
|
"github.com/metacubex/mihomo/component/dialer"
|
||||||
|
"github.com/metacubex/mihomo/component/resolver"
|
||||||
|
"github.com/metacubex/mihomo/config"
|
||||||
|
"github.com/metacubex/mihomo/constant"
|
||||||
|
cp "github.com/metacubex/mihomo/constant/provider"
|
||||||
|
"github.com/metacubex/mihomo/hub"
|
||||||
|
"github.com/metacubex/mihomo/hub/executor"
|
||||||
|
"github.com/metacubex/mihomo/listener"
|
||||||
|
"github.com/metacubex/mihomo/log"
|
||||||
|
rp "github.com/metacubex/mihomo/rules/provider"
|
||||||
|
"github.com/metacubex/mihomo/tunnel"
|
||||||
)
|
)
|
||||||
|
|
||||||
type healthCheckSchema struct {
|
type ConfigExtendedParams struct {
|
||||||
Enable bool `provider:"enable"`
|
IsPatch bool `json:"is-patch"`
|
||||||
URL string `provider:"url"`
|
IsCompatible bool `json:"is-compatible"`
|
||||||
Interval int `provider:"interval"`
|
SelectedMap map[string]string `json:"selected-map"`
|
||||||
TestTimeout int `provider:"timeout,omitempty"`
|
TestURL *string `json:"test-url"`
|
||||||
Lazy bool `provider:"lazy,omitempty"`
|
OverrideDns bool `json:"override-dns"`
|
||||||
ExpectedStatus string `provider:"expected-status,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type proxyProviderSchema struct {
|
|
||||||
Type string `provider:"type"`
|
|
||||||
Path string `provider:"path,omitempty"`
|
|
||||||
URL string `provider:"url,omitempty"`
|
|
||||||
Proxy string `provider:"proxy,omitempty"`
|
|
||||||
Interval int `provider:"interval,omitempty"`
|
|
||||||
Filter string `provider:"filter,omitempty"`
|
|
||||||
ExcludeFilter string `provider:"exclude-filter,omitempty"`
|
|
||||||
ExcludeType string `provider:"exclude-type,omitempty"`
|
|
||||||
DialerProxy string `provider:"dialer-proxy,omitempty"`
|
|
||||||
|
|
||||||
HealthCheck healthCheckSchema `provider:"health-check,omitempty"`
|
|
||||||
Override ap.OverrideSchema `provider:"override,omitempty"`
|
|
||||||
Header map[string][]string `provider:"header,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ruleProviderSchema struct {
|
|
||||||
Type string `provider:"type"`
|
|
||||||
Behavior string `provider:"behavior"`
|
|
||||||
Path string `provider:"path,omitempty"`
|
|
||||||
URL string `provider:"url,omitempty"`
|
|
||||||
Proxy string `provider:"proxy,omitempty"`
|
|
||||||
Format string `provider:"format,omitempty"`
|
|
||||||
Interval int `provider:"interval,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type GenerateConfigParams struct {
|
type GenerateConfigParams struct {
|
||||||
ProfilePath *string `json:"profile-path"`
|
ProfileId string `json:"profile-id"`
|
||||||
Config *config.RawConfig `json:"config" `
|
Config config.RawConfig `json:"config" `
|
||||||
IsPatch *bool `json:"is-patch"`
|
Params ConfigExtendedParams `json:"params"`
|
||||||
IsCompatible *bool `json:"is-compatible"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ChangeProxyParams struct {
|
type ChangeProxyParams struct {
|
||||||
@@ -76,23 +60,8 @@ type TestDelayParams struct {
|
|||||||
Timeout int64 `json:"timeout"`
|
Timeout int64 `json:"timeout"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Delay struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
Value int32 `json:"value"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Process struct {
|
|
||||||
Id int64 `json:"id"`
|
|
||||||
Metadata constant.Metadata `json:"metadata"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ProcessMapItem struct {
|
type ProcessMapItem struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
Value *string `json:"value"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Now struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
Value string `json:"value"`
|
Value string `json:"value"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,9 +69,19 @@ type ExternalProvider struct {
|
|||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
VehicleType string `json:"vehicle-type"`
|
VehicleType string `json:"vehicle-type"`
|
||||||
|
Count int `json:"count"`
|
||||||
|
Path string `json:"path"`
|
||||||
UpdateAt time.Time `json:"update-at"`
|
UpdateAt time.Time `json:"update-at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ExternalProviders []ExternalProvider
|
||||||
|
|
||||||
|
func (a ExternalProviders) Len() int { return len(a) }
|
||||||
|
func (a ExternalProviders) Less(i, j int) bool { return a[i].Name < a[j].Name }
|
||||||
|
func (a ExternalProviders) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||||
|
|
||||||
|
var b, _ = batch.New[bool](context.Background(), batch.WithConcurrencyNum[bool](50))
|
||||||
|
|
||||||
func restartExecutable(execPath string) {
|
func restartExecutable(execPath string) {
|
||||||
var err error
|
var err error
|
||||||
executor.Shutdown()
|
executor.Shutdown()
|
||||||
@@ -152,252 +131,455 @@ func removeFile(path string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getRawConfigWithPath(path *string) *config.RawConfig {
|
func getProfilePath(id string) string {
|
||||||
if path == nil {
|
return filepath.Join(constant.Path.HomeDir(), "profiles", id+".yaml")
|
||||||
return config.DefaultRawConfig()
|
|
||||||
} else {
|
|
||||||
bytes, err := readFile(*path)
|
|
||||||
if err != nil {
|
|
||||||
log.Errorln("getProfile readFile error %v", err)
|
|
||||||
return config.DefaultRawConfig()
|
|
||||||
}
|
|
||||||
prof, err := config.UnmarshalRawConfig(bytes)
|
|
||||||
if err != nil {
|
|
||||||
log.Errorln("getProfile UnmarshalRawConfig error %v", err)
|
|
||||||
return config.DefaultRawConfig()
|
|
||||||
}
|
|
||||||
return prof
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func decorationConfig(profilePath *string, cfg config.RawConfig, compatible bool) *config.RawConfig {
|
func getProfileProvidersPath(id string) string {
|
||||||
prof := getRawConfigWithPath(profilePath)
|
return filepath.Join(constant.Path.HomeDir(), "providers", id)
|
||||||
overwriteConfig(prof, cfg, compatible)
|
}
|
||||||
|
|
||||||
|
func getRawConfigWithId(id string) *config.RawConfig {
|
||||||
|
path := getProfilePath(id)
|
||||||
|
bytes, err := readFile(path)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorln("profile is not exist")
|
||||||
|
return config.DefaultRawConfig()
|
||||||
|
}
|
||||||
|
prof, err := config.UnmarshalRawConfig(bytes)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorln("unmarshalRawConfig error %v", err)
|
||||||
|
return config.DefaultRawConfig()
|
||||||
|
}
|
||||||
|
for _, mapping := range prof.ProxyProvider {
|
||||||
|
value, exist := mapping["path"].(string)
|
||||||
|
if !exist {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
mapping["path"] = filepath.Join(getProfileProvidersPath(id), value)
|
||||||
|
if configParams.TestURL != nil {
|
||||||
|
hc := mapping["health-check"].(map[string]any)
|
||||||
|
if hc != nil {
|
||||||
|
if hc["url"] != nil {
|
||||||
|
hc["url"] = *configParams.TestURL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, mapping := range prof.RuleProvider {
|
||||||
|
value, exist := mapping["path"].(string)
|
||||||
|
if !exist {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
mapping["path"] = filepath.Join(getProfileProvidersPath(id), value)
|
||||||
|
}
|
||||||
return prof
|
return prof
|
||||||
}
|
}
|
||||||
|
|
||||||
func Reduce[T any, U any](s []T, initVal U, f func(U, T) U) U {
|
func getExternalProvidersRaw() map[string]cp.Provider {
|
||||||
for _, v := range s {
|
eps := make(map[string]cp.Provider)
|
||||||
initVal = f(initVal, v)
|
for n, p := range tunnel.Providers() {
|
||||||
}
|
if p.VehicleType() != cp.Compatible {
|
||||||
return initVal
|
eps[n] = p
|
||||||
}
|
|
||||||
|
|
||||||
func Map[T, U any](slice []T, fn func(T) U) []U {
|
|
||||||
result := make([]U, len(slice))
|
|
||||||
for i, v := range slice {
|
|
||||||
result[i] = fn(v)
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
func replaceFromMap(s string, m map[string]string) string {
|
|
||||||
for k, v := range m {
|
|
||||||
s = strings.ReplaceAll(s, k, v)
|
|
||||||
}
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
|
|
||||||
func removeDuplicateFromSlice[T any](slice []T) []T {
|
|
||||||
result := make([]T, 0)
|
|
||||||
seen := make(map[any]struct{})
|
|
||||||
for _, value := range slice {
|
|
||||||
if _, ok := seen[value]; !ok {
|
|
||||||
result = append(result, value)
|
|
||||||
seen[value] = struct{}{}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result
|
for n, p := range tunnel.RuleProviders() {
|
||||||
|
if p.VehicleType() != cp.Compatible {
|
||||||
|
eps[n] = p
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return eps
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateProxyGroupAndRule(proxyGroup *[]map[string]any, rule *[]string) {
|
func toExternalProvider(p cp.Provider) (*ExternalProvider, error) {
|
||||||
var replacements = map[string]string{}
|
switch p.(type) {
|
||||||
var selectArr []map[string]any
|
case *provider.ProxySetProvider:
|
||||||
var urlTestArr []map[string]any
|
psp := p.(*provider.ProxySetProvider)
|
||||||
var fallbackArr []map[string]any
|
return &ExternalProvider{
|
||||||
for _, group := range *proxyGroup {
|
Name: psp.Name(),
|
||||||
switch group["type"] {
|
Type: psp.Type().String(),
|
||||||
case "select":
|
VehicleType: psp.VehicleType().String(),
|
||||||
selectArr = append(selectArr, group)
|
Count: psp.Count(),
|
||||||
replacements[group["name"].(string)] = "Proxy"
|
Path: psp.Vehicle().Path(),
|
||||||
break
|
UpdateAt: psp.UpdatedAt(),
|
||||||
case "url-test":
|
}, nil
|
||||||
urlTestArr = append(urlTestArr, group)
|
case *rp.RuleSetProvider:
|
||||||
replacements[group["name"].(string)] = "Auto"
|
rsp := p.(*rp.RuleSetProvider)
|
||||||
break
|
return &ExternalProvider{
|
||||||
case "fallback":
|
Name: rsp.Name(),
|
||||||
fallbackArr = append(fallbackArr, group)
|
Type: rsp.Type().String(),
|
||||||
replacements[group["name"].(string)] = "Fallback"
|
VehicleType: rsp.VehicleType().String(),
|
||||||
break
|
Count: rsp.Count(),
|
||||||
default:
|
Path: rsp.Vehicle().Path(),
|
||||||
|
UpdateAt: rsp.UpdatedAt(),
|
||||||
|
}, nil
|
||||||
|
default:
|
||||||
|
return nil, errors.New("not external provider")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func sideUpdateExternalProvider(p cp.Provider, bytes []byte) error {
|
||||||
|
switch p.(type) {
|
||||||
|
case *provider.ProxySetProvider:
|
||||||
|
psp := p.(*provider.ProxySetProvider)
|
||||||
|
_, _, err := psp.SideUpdate(bytes)
|
||||||
|
if err == nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
case rp.RuleSetProvider:
|
||||||
|
rsp := p.(*rp.RuleSetProvider)
|
||||||
|
_, _, err := rsp.SideUpdate(bytes)
|
||||||
|
if err == nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
default:
|
||||||
|
return errors.New("not external provider")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func decorationConfig(profileId string, cfg config.RawConfig) *config.RawConfig {
|
||||||
|
prof := getRawConfigWithId(profileId)
|
||||||
|
overwriteConfig(prof, cfg)
|
||||||
|
return prof
|
||||||
|
}
|
||||||
|
|
||||||
|
//func Reduce[T any, U any](s []T, initVal U, f func(U, T) U) U {
|
||||||
|
// for _, v := range s {
|
||||||
|
// initVal = f(initVal, v)
|
||||||
|
// }
|
||||||
|
// return initVal
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func Map[T, U any](slice []T, fn func(T) U) []U {
|
||||||
|
// result := make([]U, len(slice))
|
||||||
|
// for i, v := range slice {
|
||||||
|
// result[i] = fn(v)
|
||||||
|
// }
|
||||||
|
// return result
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func replaceFromMap(s string, m map[string]string) string {
|
||||||
|
// for k, v := range m {
|
||||||
|
// s = strings.ReplaceAll(s, k, v)
|
||||||
|
// }
|
||||||
|
// return s
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func removeDuplicateFromSlice[T any](slice []T) []T {
|
||||||
|
// result := make([]T, 0)
|
||||||
|
// seen := make(map[any]struct{})
|
||||||
|
// for _, value := range slice {
|
||||||
|
// if _, ok := seen[value]; !ok {
|
||||||
|
// result = append(result, value)
|
||||||
|
// seen[value] = struct{}{}
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return result
|
||||||
|
//}
|
||||||
|
|
||||||
|
//func generateProxyGroupAndRule(proxyGroup *[]map[string]any, rule *[]string) {
|
||||||
|
// var replacements = map[string]string{}
|
||||||
|
// var selectArr []map[string]any
|
||||||
|
// var urlTestArr []map[string]any
|
||||||
|
// var fallbackArr []map[string]any
|
||||||
|
// for _, group := range *proxyGroup {
|
||||||
|
// switch group["type"] {
|
||||||
|
// case "select":
|
||||||
|
// selectArr = append(selectArr, group)
|
||||||
|
// replacements[group["name"].(string)] = "Proxy"
|
||||||
|
// break
|
||||||
|
// case "url-test":
|
||||||
|
// urlTestArr = append(urlTestArr, group)
|
||||||
|
// replacements[group["name"].(string)] = "Auto"
|
||||||
|
// break
|
||||||
|
// case "fallback":
|
||||||
|
// fallbackArr = append(fallbackArr, group)
|
||||||
|
// replacements[group["name"].(string)] = "Fallback"
|
||||||
|
// break
|
||||||
|
// default:
|
||||||
|
// break
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// ProxyProxies := Reduce(selectArr, []string{}, func(res []string, cur map[string]any) []string {
|
||||||
|
// if cur["proxies"] == nil {
|
||||||
|
// return res
|
||||||
|
// }
|
||||||
|
// for _, proxyName := range cur["proxies"].([]interface{}) {
|
||||||
|
// if str, ok := proxyName.(string); ok {
|
||||||
|
// str = replaceFromMap(str, replacements)
|
||||||
|
// if str != "Proxy" {
|
||||||
|
// res = append(res, str)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return res
|
||||||
|
// })
|
||||||
|
//
|
||||||
|
// ProxyProxies = removeDuplicateFromSlice(ProxyProxies)
|
||||||
|
//
|
||||||
|
// AutoProxies := Reduce(urlTestArr, []string{}, func(res []string, cur map[string]any) []string {
|
||||||
|
// if cur["proxies"] == nil {
|
||||||
|
// return res
|
||||||
|
// }
|
||||||
|
// for _, proxyName := range cur["proxies"].([]interface{}) {
|
||||||
|
// if str, ok := proxyName.(string); ok {
|
||||||
|
// str = replaceFromMap(str, replacements)
|
||||||
|
// if str != "Auto" {
|
||||||
|
// res = append(res, str)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return res
|
||||||
|
// })
|
||||||
|
//
|
||||||
|
// AutoProxies = removeDuplicateFromSlice(AutoProxies)
|
||||||
|
//
|
||||||
|
// FallbackProxies := Reduce(fallbackArr, []string{}, func(res []string, cur map[string]any) []string {
|
||||||
|
// if cur["proxies"] == nil {
|
||||||
|
// return res
|
||||||
|
// }
|
||||||
|
// for _, proxyName := range cur["proxies"].([]interface{}) {
|
||||||
|
// if str, ok := proxyName.(string); ok {
|
||||||
|
// str = replaceFromMap(str, replacements)
|
||||||
|
// if str != "Fallback" {
|
||||||
|
// res = append(res, str)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return res
|
||||||
|
// })
|
||||||
|
//
|
||||||
|
// FallbackProxies = removeDuplicateFromSlice(FallbackProxies)
|
||||||
|
//
|
||||||
|
// var computedProxyGroup []map[string]any
|
||||||
|
//
|
||||||
|
// if len(ProxyProxies) > 0 {
|
||||||
|
// computedProxyGroup = append(computedProxyGroup,
|
||||||
|
// map[string]any{
|
||||||
|
// "name": "Proxy",
|
||||||
|
// "type": "select",
|
||||||
|
// "proxies": ProxyProxies,
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if len(AutoProxies) > 0 {
|
||||||
|
// computedProxyGroup = append(computedProxyGroup,
|
||||||
|
// map[string]any{
|
||||||
|
// "name": "Auto",
|
||||||
|
// "type": "url-test",
|
||||||
|
// "proxies": AutoProxies,
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if len(FallbackProxies) > 0 {
|
||||||
|
// computedProxyGroup = append(computedProxyGroup,
|
||||||
|
// map[string]any{
|
||||||
|
// "name": "Fallback",
|
||||||
|
// "type": "fallback",
|
||||||
|
// "proxies": FallbackProxies,
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// computedRule := Map(*rule, func(value string) string {
|
||||||
|
// return replaceFromMap(value, replacements)
|
||||||
|
// })
|
||||||
|
//
|
||||||
|
// *proxyGroup = computedProxyGroup
|
||||||
|
// *rule = computedRule
|
||||||
|
//}
|
||||||
|
|
||||||
|
func genHosts(hosts, patchHosts map[string]any) {
|
||||||
|
for k, v := range patchHosts {
|
||||||
|
hosts[k] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func trimArr(arr []string) (r []string) {
|
||||||
|
for _, e := range arr {
|
||||||
|
r = append(r, strings.Trim(e, " "))
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var ips = []string{"ipinfo.io", "ipapi.co", "api.ip.sb", "ipwho.is"}
|
||||||
|
|
||||||
|
func overrideRules(rules *[]string) {
|
||||||
|
var target = ""
|
||||||
|
for _, line := range *rules {
|
||||||
|
rule := trimArr(strings.Split(line, ","))
|
||||||
|
l := len(rule)
|
||||||
|
if l != 2 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if strings.ToUpper(rule[0]) == "MATCH" {
|
||||||
|
target = rule[1]
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if target == "" {
|
||||||
ProxyProxies := Reduce(selectArr, []string{}, func(res []string, cur map[string]any) []string {
|
return
|
||||||
if cur["proxies"] == nil {
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
for _, proxyName := range cur["proxies"].([]interface{}) {
|
|
||||||
if str, ok := proxyName.(string); ok {
|
|
||||||
str = replaceFromMap(str, replacements)
|
|
||||||
if str != "Proxy" {
|
|
||||||
res = append(res, str)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
})
|
|
||||||
|
|
||||||
ProxyProxies = removeDuplicateFromSlice(ProxyProxies)
|
|
||||||
|
|
||||||
AutoProxies := Reduce(urlTestArr, []string{}, func(res []string, cur map[string]any) []string {
|
|
||||||
if cur["proxies"] == nil {
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
for _, proxyName := range cur["proxies"].([]interface{}) {
|
|
||||||
if str, ok := proxyName.(string); ok {
|
|
||||||
str = replaceFromMap(str, replacements)
|
|
||||||
if str != "Auto" {
|
|
||||||
res = append(res, str)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
})
|
|
||||||
|
|
||||||
AutoProxies = removeDuplicateFromSlice(AutoProxies)
|
|
||||||
|
|
||||||
FallbackProxies := Reduce(fallbackArr, []string{}, func(res []string, cur map[string]any) []string {
|
|
||||||
if cur["proxies"] == nil {
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
for _, proxyName := range cur["proxies"].([]interface{}) {
|
|
||||||
if str, ok := proxyName.(string); ok {
|
|
||||||
str = replaceFromMap(str, replacements)
|
|
||||||
if str != "Fallback" {
|
|
||||||
res = append(res, str)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
})
|
|
||||||
|
|
||||||
FallbackProxies = removeDuplicateFromSlice(FallbackProxies)
|
|
||||||
|
|
||||||
var computedProxyGroup []map[string]any
|
|
||||||
|
|
||||||
if len(ProxyProxies) > 0 {
|
|
||||||
computedProxyGroup = append(computedProxyGroup,
|
|
||||||
map[string]any{
|
|
||||||
"name": "Proxy",
|
|
||||||
"type": "select",
|
|
||||||
"proxies": ProxyProxies,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
var rulesExt = lo.Map(ips, func(ip string, index int) string {
|
||||||
if len(AutoProxies) > 0 {
|
return fmt.Sprintf("DOMAIN %s %s", ip, target)
|
||||||
computedProxyGroup = append(computedProxyGroup,
|
|
||||||
map[string]any{
|
|
||||||
"name": "Auto",
|
|
||||||
"type": "url-test",
|
|
||||||
"proxies": AutoProxies,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(FallbackProxies) > 0 {
|
|
||||||
computedProxyGroup = append(computedProxyGroup,
|
|
||||||
map[string]any{
|
|
||||||
"name": "Fallback",
|
|
||||||
"type": "fallback",
|
|
||||||
"proxies": FallbackProxies,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
computedRule := Map(*rule, func(value string) string {
|
|
||||||
return replaceFromMap(value, replacements)
|
|
||||||
})
|
})
|
||||||
|
*rules = append(rulesExt, *rules...)
|
||||||
*proxyGroup = computedProxyGroup
|
|
||||||
*rule = computedRule
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func overwriteConfig(targetConfig *config.RawConfig, patchConfig config.RawConfig, compatible bool) {
|
func overwriteConfig(targetConfig *config.RawConfig, patchConfig config.RawConfig) {
|
||||||
targetConfig.ExternalController = patchConfig.ExternalController
|
targetConfig.ExternalController = patchConfig.ExternalController
|
||||||
targetConfig.ExternalUI = ""
|
targetConfig.ExternalUI = ""
|
||||||
targetConfig.Interface = ""
|
targetConfig.Interface = ""
|
||||||
targetConfig.ExternalUIURL = ""
|
targetConfig.ExternalUIURL = ""
|
||||||
targetConfig.TCPConcurrent = patchConfig.TCPConcurrent
|
targetConfig.TCPConcurrent = patchConfig.TCPConcurrent
|
||||||
targetConfig.UnifiedDelay = patchConfig.UnifiedDelay
|
targetConfig.UnifiedDelay = patchConfig.UnifiedDelay
|
||||||
targetConfig.GeodataMode = false
|
|
||||||
targetConfig.IPv6 = patchConfig.IPv6
|
targetConfig.IPv6 = patchConfig.IPv6
|
||||||
targetConfig.LogLevel = patchConfig.LogLevel
|
targetConfig.LogLevel = patchConfig.LogLevel
|
||||||
targetConfig.Port = 0
|
targetConfig.Port = 0
|
||||||
targetConfig.SocksPort = 0
|
targetConfig.SocksPort = 0
|
||||||
|
targetConfig.KeepAliveInterval = patchConfig.KeepAliveInterval
|
||||||
targetConfig.MixedPort = patchConfig.MixedPort
|
targetConfig.MixedPort = patchConfig.MixedPort
|
||||||
targetConfig.FindProcessMode = patchConfig.FindProcessMode
|
targetConfig.FindProcessMode = patchConfig.FindProcessMode
|
||||||
targetConfig.AllowLan = patchConfig.AllowLan
|
targetConfig.AllowLan = patchConfig.AllowLan
|
||||||
targetConfig.Mode = patchConfig.Mode
|
targetConfig.Mode = patchConfig.Mode
|
||||||
targetConfig.Tun.Enable = patchConfig.Tun.Enable
|
targetConfig.Tun.Enable = patchConfig.Tun.Enable
|
||||||
targetConfig.Tun.Device = patchConfig.Tun.Device
|
targetConfig.Tun.Device = patchConfig.Tun.Device
|
||||||
//targetConfig.Tun.DNSHijack = patchConfig.Tun.DNSHijack
|
targetConfig.Tun.DNSHijack = patchConfig.Tun.DNSHijack
|
||||||
//targetConfig.Tun.Stack = patchConfig.Tun.Stack
|
targetConfig.Tun.Stack = patchConfig.Tun.Stack
|
||||||
targetConfig.GeodataLoader = patchConfig.GeodataLoader
|
targetConfig.GeodataLoader = patchConfig.GeodataLoader
|
||||||
targetConfig.Profile.StoreSelected = false
|
targetConfig.Profile.StoreSelected = false
|
||||||
if targetConfig.DNS.Enable == false {
|
targetConfig.GeoXUrl = patchConfig.GeoXUrl
|
||||||
targetConfig.DNS = patchConfig.DNS
|
targetConfig.GlobalUA = patchConfig.GlobalUA
|
||||||
|
if configParams.TestURL != nil {
|
||||||
|
constant.DefaultTestURL = *configParams.TestURL
|
||||||
}
|
}
|
||||||
|
for idx := range targetConfig.ProxyGroup {
|
||||||
|
targetConfig.ProxyGroup[idx]["url"] = ""
|
||||||
|
}
|
||||||
|
genHosts(targetConfig.Hosts, patchConfig.Hosts)
|
||||||
|
if configParams.OverrideDns {
|
||||||
|
targetConfig.DNS = patchConfig.DNS
|
||||||
|
} else {
|
||||||
|
if targetConfig.DNS.Enable == false {
|
||||||
|
targetConfig.DNS.Enable = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
overrideRules(&targetConfig.Rule)
|
||||||
//if runtime.GOOS == "android" {
|
//if runtime.GOOS == "android" {
|
||||||
// targetConfig.DNS.NameServer = append(targetConfig.DNS.NameServer, "dhcp://"+dns.SystemDNSPlaceholder)
|
// targetConfig.DNS.NameServer = append(targetConfig.DNS.NameServer, "dhcp://"+dns.SystemDNSPlaceholder)
|
||||||
//} else if runtime.GOOS == "windows" {
|
//} else if runtime.GOOS == "windows" {
|
||||||
// targetConfig.DNS.NameServer = append(targetConfig.DNS.NameServer, dns.SystemDNSPlaceholder)
|
// targetConfig.DNS.NameServer = append(targetConfig.DNS.NameServer, dns.SystemDNSPlaceholder)
|
||||||
//}
|
//}
|
||||||
if compatible == false {
|
//if configParams.IsCompatible == false {
|
||||||
targetConfig.ProxyProvider = make(map[string]map[string]any)
|
// targetConfig.ProxyProvider = make(map[string]map[string]any)
|
||||||
targetConfig.RuleProvider = make(map[string]map[string]any)
|
// targetConfig.RuleProvider = make(map[string]map[string]any)
|
||||||
generateProxyGroupAndRule(&targetConfig.ProxyGroup, &targetConfig.Rule)
|
// generateProxyGroupAndRule(&targetConfig.ProxyGroup, &targetConfig.Rule)
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
func patchConfig(general *config.General) {
|
func patchConfig(general *config.General, controller *config.Controller, tls *config.TLS) {
|
||||||
log.Infoln("[Apply] patch")
|
log.Infoln("[Apply] patch")
|
||||||
route.ReStartServer(general.ExternalController)
|
|
||||||
listener.SetAllowLan(general.AllowLan)
|
|
||||||
inbound.SetSkipAuthPrefixes(general.SkipAuthPrefixes)
|
|
||||||
inbound.SetAllowedIPs(general.LanAllowedIPs)
|
|
||||||
inbound.SetDisAllowedIPs(general.LanDisAllowedIPs)
|
|
||||||
listener.SetBindAddress(general.BindAddress)
|
|
||||||
tunnel.SetSniffing(general.Sniffing)
|
tunnel.SetSniffing(general.Sniffing)
|
||||||
tunnel.SetFindProcessMode(general.FindProcessMode)
|
tunnel.SetFindProcessMode(general.FindProcessMode)
|
||||||
dialer.SetTcpConcurrent(general.TCPConcurrent)
|
dialer.SetTcpConcurrent(general.TCPConcurrent)
|
||||||
dialer.DefaultInterface.Store(general.Interface)
|
dialer.DefaultInterface.Store(general.Interface)
|
||||||
adapter.UnifiedDelay.Store(general.UnifiedDelay)
|
adapter.UnifiedDelay.Store(general.UnifiedDelay)
|
||||||
|
tunnel.SetMode(general.Mode)
|
||||||
|
log.SetLevel(general.LogLevel)
|
||||||
|
resolver.DisableIPv6 = !general.IPv6
|
||||||
|
|
||||||
|
route.ReCreateServer(&route.Config{
|
||||||
|
Addr: controller.ExternalController,
|
||||||
|
TLSAddr: controller.ExternalControllerTLS,
|
||||||
|
UnixAddr: controller.ExternalControllerUnix,
|
||||||
|
PipeAddr: controller.ExternalControllerPipe,
|
||||||
|
Secret: controller.Secret,
|
||||||
|
Certificate: tls.Certificate,
|
||||||
|
PrivateKey: tls.PrivateKey,
|
||||||
|
DohServer: controller.ExternalDohServer,
|
||||||
|
IsDebug: false,
|
||||||
|
Cors: route.Cors{
|
||||||
|
AllowOrigins: controller.Cors.AllowOrigins,
|
||||||
|
AllowPrivateNetwork: controller.Cors.AllowPrivateNetwork,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
var isRunning = false
|
||||||
|
|
||||||
|
var runLock sync.Mutex
|
||||||
|
|
||||||
|
func updateListeners(general *config.General, listeners map[string]constant.InboundListener) {
|
||||||
|
if !isRunning {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
runLock.Lock()
|
||||||
|
defer runLock.Unlock()
|
||||||
|
stopListeners()
|
||||||
|
listener.PatchInboundListeners(listeners, tunnel.Tunnel, true)
|
||||||
|
listener.SetAllowLan(general.AllowLan)
|
||||||
|
inbound.SetSkipAuthPrefixes(general.SkipAuthPrefixes)
|
||||||
|
inbound.SetAllowedIPs(general.LanAllowedIPs)
|
||||||
|
inbound.SetDisAllowedIPs(general.LanDisAllowedIPs)
|
||||||
|
listener.SetBindAddress(general.BindAddress)
|
||||||
listener.ReCreateHTTP(general.Port, tunnel.Tunnel)
|
listener.ReCreateHTTP(general.Port, tunnel.Tunnel)
|
||||||
listener.ReCreateSocks(general.SocksPort, tunnel.Tunnel)
|
listener.ReCreateSocks(general.SocksPort, tunnel.Tunnel)
|
||||||
listener.ReCreateRedir(general.RedirPort, tunnel.Tunnel)
|
listener.ReCreateRedir(general.RedirPort, tunnel.Tunnel)
|
||||||
listener.ReCreateAutoRedir(general.EBpf.AutoRedir, tunnel.Tunnel)
|
|
||||||
listener.ReCreateTProxy(general.TProxyPort, tunnel.Tunnel)
|
listener.ReCreateTProxy(general.TProxyPort, tunnel.Tunnel)
|
||||||
listener.ReCreateTun(general.Tun, tunnel.Tunnel)
|
|
||||||
listener.ReCreateMixed(general.MixedPort, tunnel.Tunnel)
|
listener.ReCreateMixed(general.MixedPort, tunnel.Tunnel)
|
||||||
listener.ReCreateShadowSocks(general.ShadowSocksConfig, tunnel.Tunnel)
|
listener.ReCreateShadowSocks(general.ShadowSocksConfig, tunnel.Tunnel)
|
||||||
listener.ReCreateVmess(general.VmessConfig, tunnel.Tunnel)
|
listener.ReCreateVmess(general.VmessConfig, tunnel.Tunnel)
|
||||||
listener.ReCreateTuic(general.TuicServer, tunnel.Tunnel)
|
listener.ReCreateTuic(general.TuicServer, tunnel.Tunnel)
|
||||||
tunnel.SetMode(general.Mode)
|
if !features.Android {
|
||||||
log.SetLevel(general.LogLevel)
|
listener.ReCreateTun(general.Tun, tunnel.Tunnel)
|
||||||
|
}
|
||||||
resolver.DisableIPv6 = !general.IPv6
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func applyConfig(isPatch bool) {
|
func stopListeners() {
|
||||||
cfg, err := config.ParseRawConfig(currentConfig)
|
listener.StopListener()
|
||||||
|
}
|
||||||
|
|
||||||
|
func patchSelectGroup() {
|
||||||
|
mapping := configParams.SelectedMap
|
||||||
|
if mapping == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for name, proxy := range tunnel.ProxiesWithProviders() {
|
||||||
|
outbound, ok := proxy.(*adapter.Proxy)
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
selector, ok := outbound.ProxyAdapter.(outboundgroup.SelectAble)
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
selected, exist := mapping[name]
|
||||||
|
if !exist {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
selector.ForceSet(selected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func applyConfig() error {
|
||||||
|
cfg, err := config.ParseRawConfig(state.CurrentRawConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cfg, _ = config.ParseRawConfig(config.DefaultRawConfig())
|
cfg, _ = config.ParseRawConfig(config.DefaultRawConfig())
|
||||||
}
|
}
|
||||||
if isPatch {
|
if configParams.IsPatch {
|
||||||
patchConfig(cfg.General)
|
patchConfig(cfg.General, cfg.Controller, cfg.TLS)
|
||||||
} else {
|
} else {
|
||||||
|
closeConnections()
|
||||||
runtime.GC()
|
runtime.GC()
|
||||||
executor.Shutdown()
|
hub.ApplyConfig(cfg)
|
||||||
hub.UltraApplyConfig(cfg, true)
|
patchSelectGroup()
|
||||||
}
|
}
|
||||||
|
updateListeners(cfg.General, cfg.Listeners)
|
||||||
|
externalProviders = getExternalProvidersRaw()
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dart_bridge
|
package dart_bridge
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
#include <stdlib.h>
|
||||||
#include "stdint.h"
|
#include "stdint.h"
|
||||||
#include "include/dart_api_dl.h"
|
#include "include/dart_api_dl.h"
|
||||||
#include "include/dart_api_dl.c"
|
#include "include/dart_api_dl.c"
|
||||||
@@ -24,14 +25,16 @@ func InitDartApi(api unsafe.Pointer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func SendToPort(port int64, msg string) {
|
func SendToPort(port int64, msg string) bool {
|
||||||
var obj C.Dart_CObject
|
var obj C.Dart_CObject
|
||||||
obj._type = C.Dart_CObject_kString
|
obj._type = C.Dart_CObject_kString
|
||||||
msgString := C.CString(msg)
|
msgString := C.CString(msg)
|
||||||
|
defer C.free(unsafe.Pointer(msgString))
|
||||||
ptr := unsafe.Pointer(&obj.value[0])
|
ptr := unsafe.Pointer(&obj.value[0])
|
||||||
*(**C.char)(ptr) = msgString
|
*(**C.char)(ptr) = msgString
|
||||||
isSuccess := C.GoDart_PostCObject(C.Dart_Port_DL(port), &obj)
|
isSuccess := C.GoDart_PostCObject(C.Dart_Port_DL(port), &obj)
|
||||||
if !isSuccess {
|
if !isSuccess {
|
||||||
fmt.Println("ERROR: post to port ", port, " failed", msg)
|
return false
|
||||||
}
|
}
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
package dart_bridge
|
|
||||||
|
|
||||||
import "encoding/json"
|
|
||||||
|
|
||||||
var Port *int64
|
|
||||||
|
|
||||||
type MessageType string
|
|
||||||
|
|
||||||
const (
|
|
||||||
Log MessageType = "log"
|
|
||||||
Tun MessageType = "tun"
|
|
||||||
Delay MessageType = "delay"
|
|
||||||
Now MessageType = "now"
|
|
||||||
Process MessageType = "process"
|
|
||||||
Request MessageType = "request"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Message struct {
|
|
||||||
Type MessageType `json:"type"`
|
|
||||||
Data interface{} `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (message *Message) Json() string {
|
|
||||||
data, _ := json.Marshal(message)
|
|
||||||
return string(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
func SendMessage(message Message) {
|
|
||||||
SendToPort(*Port, message.Json())
|
|
||||||
}
|
|
||||||
20
core/dns.go
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
//go:build android
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "C"
|
||||||
|
import (
|
||||||
|
"github.com/metacubex/mihomo/dns"
|
||||||
|
"github.com/metacubex/mihomo/log"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
//export updateDns
|
||||||
|
func updateDns(s *C.char) {
|
||||||
|
dnsList := C.GoString(s)
|
||||||
|
go func() {
|
||||||
|
log.Infoln("[DNS] updateDns %s", dnsList)
|
||||||
|
dns.UpdateSystemDNS(strings.Split(dnsList, ","))
|
||||||
|
dns.FlushCacheWithDefaultResolver()
|
||||||
|
}()
|
||||||
|
}
|
||||||
87
core/go.mod
@@ -4,66 +4,71 @@ go 1.21.0
|
|||||||
|
|
||||||
replace github.com/metacubex/mihomo => ./Clash.Meta
|
replace github.com/metacubex/mihomo => ./Clash.Meta
|
||||||
|
|
||||||
|
require github.com/metacubex/mihomo v1.17.1
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Kr328/tun2socket v0.0.0-20220414050025-d07c78d06d34
|
github.com/metacubex/amneziawg-go v0.0.0-20240922133038-fdf3a4d5a4ab // indirect
|
||||||
github.com/metacubex/mihomo v1.17.1
|
github.com/metacubex/wireguard-go v0.0.0-20240922131502-c182e7471181 // indirect
|
||||||
github.com/miekg/dns v1.1.59
|
github.com/sagernet/cors v1.2.1 // indirect
|
||||||
golang.org/x/net v0.25.0
|
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
|
||||||
golang.org/x/sync v0.7.0
|
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
|
replace github.com/sagernet/sing => github.com/metacubex/sing v0.0.0-20240724044459-6f3cf5896297
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/3andne/restls-client-go v0.1.6 // indirect
|
github.com/3andne/restls-client-go v0.1.6 // indirect
|
||||||
github.com/RyuaNerin/go-krypto v1.2.4 // indirect
|
github.com/RyuaNerin/go-krypto v1.2.4 // indirect
|
||||||
github.com/Yawning/aez v0.0.0-20211027044916-e49e68abd344 // indirect
|
github.com/Yawning/aez v0.0.0-20211027044916-e49e68abd344 // indirect
|
||||||
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect
|
|
||||||
github.com/ajg/form v1.5.1 // indirect
|
github.com/ajg/form v1.5.1 // indirect
|
||||||
github.com/andybalholm/brotli v1.0.6 // indirect
|
github.com/andybalholm/brotli v1.0.6 // indirect
|
||||||
github.com/bahlo/generic-list-go v0.2.0 // indirect
|
github.com/bahlo/generic-list-go v0.2.0 // indirect
|
||||||
github.com/buger/jsonparser v1.1.1 // indirect
|
github.com/buger/jsonparser v1.1.1 // indirect
|
||||||
github.com/cilium/ebpf v0.12.3 // indirect
|
|
||||||
github.com/cloudflare/circl v1.3.7 // indirect
|
github.com/cloudflare/circl v1.3.7 // indirect
|
||||||
github.com/coreos/go-iptables v0.7.0 // indirect
|
github.com/coreos/go-iptables v0.8.0 // indirect
|
||||||
github.com/dlclark/regexp2 v1.11.0 // indirect
|
github.com/dlclark/regexp2 v1.11.4 // indirect
|
||||||
github.com/ericlagergren/aegis v0.0.0-20230312195928-b4ce538b56f9 // indirect
|
github.com/ericlagergren/aegis v0.0.0-20230312195928-b4ce538b56f9 // indirect
|
||||||
github.com/ericlagergren/polyval v0.0.0-20220411101811-e25bc10ba391 // indirect
|
github.com/ericlagergren/polyval v0.0.0-20220411101811-e25bc10ba391 // indirect
|
||||||
github.com/ericlagergren/siv v0.0.0-20220507050439-0b757b3aa5f1 // indirect
|
github.com/ericlagergren/siv v0.0.0-20220507050439-0b757b3aa5f1 // indirect
|
||||||
github.com/ericlagergren/subtle v0.0.0-20220507045147-890d697da010 // indirect
|
github.com/ericlagergren/subtle v0.0.0-20220507045147-890d697da010 // indirect
|
||||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||||
github.com/gaukas/godicttls v0.0.4 // indirect
|
github.com/gaukas/godicttls v0.0.4 // indirect
|
||||||
github.com/go-chi/chi/v5 v5.0.12 // indirect
|
github.com/go-chi/chi/v5 v5.1.0 // indirect
|
||||||
github.com/go-chi/cors v1.2.1 // indirect
|
|
||||||
github.com/go-chi/render v1.0.3 // indirect
|
github.com/go-chi/render v1.0.3 // indirect
|
||||||
github.com/go-ole/go-ole v1.3.0 // indirect
|
github.com/go-ole/go-ole v1.3.0 // indirect
|
||||||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
|
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
|
||||||
github.com/gobwas/httphead v0.1.0 // indirect
|
github.com/gobwas/httphead v0.1.0 // indirect
|
||||||
github.com/gobwas/pool v0.2.1 // indirect
|
github.com/gobwas/pool v0.2.1 // indirect
|
||||||
github.com/gobwas/ws v1.4.0 // indirect
|
github.com/gobwas/ws v1.4.0 // indirect
|
||||||
github.com/gofrs/uuid/v5 v5.2.0 // indirect
|
github.com/gofrs/uuid/v5 v5.3.0 // indirect
|
||||||
github.com/google/btree v1.1.2 // indirect
|
github.com/google/btree v1.1.2 // indirect
|
||||||
github.com/google/go-cmp v0.6.0 // indirect
|
github.com/google/go-cmp v0.6.0 // indirect
|
||||||
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
|
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
|
||||||
github.com/hashicorp/yamux v0.1.1 // indirect
|
github.com/hashicorp/yamux v0.1.1 // indirect
|
||||||
github.com/insomniacslk/dhcp v0.0.0-20240419123447-f1cffa2c0c49 // indirect
|
github.com/insomniacslk/dhcp v0.0.0-20240829085014-a3a4c1f04475 // indirect
|
||||||
github.com/josharian/native v1.1.0 // indirect
|
github.com/josharian/native v1.1.0 // indirect
|
||||||
github.com/klauspost/compress v1.17.4 // indirect
|
github.com/klauspost/compress v1.17.9 // indirect
|
||||||
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
|
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
|
||||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
|
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
|
||||||
github.com/lunixbochs/struc v0.0.0-20200707160740-784aaebc1d40 // indirect
|
github.com/lunixbochs/struc v0.0.0-20200707160740-784aaebc1d40 // indirect
|
||||||
github.com/mailru/easyjson v0.7.7 // indirect
|
github.com/mailru/easyjson v0.7.7 // indirect
|
||||||
github.com/mdlayher/netlink v1.7.2 // indirect
|
github.com/mdlayher/netlink v1.7.2 // indirect
|
||||||
github.com/mdlayher/socket v0.4.1 // indirect
|
github.com/mdlayher/socket v0.4.1 // indirect
|
||||||
|
github.com/metacubex/bbolt v0.0.0-20240822011022-aed6d4850399 // indirect
|
||||||
|
github.com/metacubex/chacha v0.1.0 // indirect
|
||||||
github.com/metacubex/gopacket v1.1.20-0.20230608035415-7e2f98a3e759 // indirect
|
github.com/metacubex/gopacket v1.1.20-0.20230608035415-7e2f98a3e759 // indirect
|
||||||
github.com/metacubex/gvisor v0.0.0-20240320004321-933faba989ec // indirect
|
github.com/metacubex/gvisor v0.0.0-20240320004321-933faba989ec // indirect
|
||||||
github.com/metacubex/quic-go v0.43.2-0.20240518033621-2c3d14c6b38e // indirect
|
github.com/metacubex/quic-go v0.47.1-0.20240909010619-6b38f24bfcc4 // indirect
|
||||||
github.com/metacubex/sing-quic v0.0.0-20240518034124-7696d3f7da72 // indirect
|
github.com/metacubex/randv2 v0.2.0 // indirect
|
||||||
github.com/metacubex/sing-shadowsocks v0.2.6 // indirect
|
github.com/metacubex/sing-quic v0.0.0-20240827003841-cd97758ed8b4 // indirect
|
||||||
github.com/metacubex/sing-shadowsocks2 v0.2.0 // indirect
|
github.com/metacubex/sing-shadowsocks v0.2.8 // indirect
|
||||||
github.com/metacubex/sing-tun v0.2.7-0.20240512075008-89e7c6208eec // indirect
|
github.com/metacubex/sing-shadowsocks2 v0.2.2 // indirect
|
||||||
github.com/metacubex/sing-vmess v0.1.9-0.20231207122118-72303677451f // indirect
|
github.com/metacubex/sing-tun v0.2.7-0.20240729131039-ed03f557dee1 // indirect
|
||||||
github.com/metacubex/sing-wireguard v0.0.0-20240321042214-224f96122a63 // indirect
|
github.com/metacubex/sing-vmess v0.1.9-0.20240719134745-1df6fb20bbf9 // indirect
|
||||||
github.com/metacubex/tfo-go v0.0.0-20240228025757-be1269474a66 // indirect
|
github.com/metacubex/sing-wireguard v0.0.0-20240924052438-b0976fc59ea3 // indirect
|
||||||
|
github.com/metacubex/tfo-go v0.0.0-20241006021335-daedaf0ca7aa // indirect
|
||||||
github.com/metacubex/utls v1.6.6 // indirect
|
github.com/metacubex/utls v1.6.6 // indirect
|
||||||
|
github.com/miekg/dns v1.1.62 // indirect
|
||||||
github.com/mroth/weightedrand/v2 v2.1.0 // indirect
|
github.com/mroth/weightedrand/v2 v2.1.0 // indirect
|
||||||
github.com/oasisprotocol/deoxysii v0.0.0-20220228165953-2091330c22b7 // indirect
|
github.com/oasisprotocol/deoxysii v0.0.0-20220228165953-2091330c22b7 // indirect
|
||||||
github.com/onsi/ginkgo/v2 v2.9.5 // indirect
|
github.com/onsi/ginkgo/v2 v2.9.5 // indirect
|
||||||
@@ -71,18 +76,18 @@ require (
|
|||||||
github.com/oschwald/maxminddb-golang v1.12.0 // indirect
|
github.com/oschwald/maxminddb-golang v1.12.0 // indirect
|
||||||
github.com/pierrec/lz4/v4 v4.1.14 // indirect
|
github.com/pierrec/lz4/v4 v4.1.14 // indirect
|
||||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
|
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
|
||||||
github.com/puzpuzpuz/xsync/v3 v3.1.0 // indirect
|
github.com/puzpuzpuz/xsync/v3 v3.4.0 // indirect
|
||||||
github.com/quic-go/qpack v0.4.0 // indirect
|
github.com/quic-go/qpack v0.4.0 // indirect
|
||||||
github.com/quic-go/qtls-go1-20 v0.4.1 // indirect
|
github.com/quic-go/qtls-go1-20 v0.4.1 // indirect
|
||||||
github.com/sagernet/bbolt v0.0.0-20231014093535-ea5cb2fe9f0a // indirect
|
github.com/sagernet/fswatch v0.1.1 // indirect
|
||||||
github.com/sagernet/netlink v0.0.0-20220905062125-8043b4a9aa97 // indirect
|
github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a // indirect
|
||||||
github.com/sagernet/sing v0.3.8 // indirect
|
github.com/sagernet/nftables v0.3.0-beta.4 // indirect
|
||||||
|
github.com/sagernet/sing v0.5.0-alpha.13 // indirect
|
||||||
github.com/sagernet/sing-mux v0.2.1-0.20240124034317-9bfb33698bb6 // indirect
|
github.com/sagernet/sing-mux v0.2.1-0.20240124034317-9bfb33698bb6 // indirect
|
||||||
github.com/sagernet/sing-shadowtls v0.1.4 // indirect
|
github.com/sagernet/sing-shadowtls v0.1.4 // indirect
|
||||||
github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7 // indirect
|
github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7 // indirect
|
||||||
github.com/sagernet/wireguard-go v0.0.0-20231209092712-9a439356a62e // indirect
|
github.com/samber/lo v1.47.0
|
||||||
github.com/samber/lo v1.39.0 // indirect
|
github.com/shirou/gopsutil/v3 v3.24.5 // indirect
|
||||||
github.com/shirou/gopsutil/v3 v3.24.4 // indirect
|
|
||||||
github.com/shoenig/go-m1cpu v0.1.6 // indirect
|
github.com/shoenig/go-m1cpu v0.1.6 // indirect
|
||||||
github.com/sina-ghaderi/poly1305 v0.0.0-20220724002748-c5926b03988b // indirect
|
github.com/sina-ghaderi/poly1305 v0.0.0-20220724002748-c5926b03988b // indirect
|
||||||
github.com/sina-ghaderi/rabaead v0.0.0-20220730151906-ab6e06b96e8c // indirect
|
github.com/sina-ghaderi/rabaead v0.0.0-20220730151906-ab6e06b96e8c // indirect
|
||||||
@@ -91,21 +96,23 @@ require (
|
|||||||
github.com/tklauser/go-sysconf v0.3.12 // indirect
|
github.com/tklauser/go-sysconf v0.3.12 // indirect
|
||||||
github.com/tklauser/numcpus v0.6.1 // indirect
|
github.com/tklauser/numcpus v0.6.1 // indirect
|
||||||
github.com/u-root/uio v0.0.0-20230220225925-ffce2a382923 // indirect
|
github.com/u-root/uio v0.0.0-20230220225925-ffce2a382923 // indirect
|
||||||
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 // indirect
|
github.com/vishvananda/netns v0.0.4 // indirect
|
||||||
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
|
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
|
||||||
github.com/yusufpapurcu/wmi v1.2.4 // indirect
|
github.com/yusufpapurcu/wmi v1.2.4 // indirect
|
||||||
github.com/zhangyunhao116/fastrand v0.4.0 // indirect
|
gitlab.com/go-extension/aes-ccm v0.0.0-20230221065045-e58665ef23c7 // indirect
|
||||||
gitlab.com/yawning/bsaes.git v0.0.0-20190805113838-0a714cd429ec // indirect
|
gitlab.com/yawning/bsaes.git v0.0.0-20190805113838-0a714cd429ec // indirect
|
||||||
go.uber.org/mock v0.4.0 // indirect
|
go.uber.org/mock v0.4.0 // indirect
|
||||||
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba // indirect
|
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba // indirect
|
||||||
golang.org/x/crypto v0.23.0 // indirect
|
golang.org/x/crypto v0.28.0 // indirect
|
||||||
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
|
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e // indirect
|
||||||
golang.org/x/mod v0.17.0 // indirect
|
golang.org/x/mod v0.20.0 // indirect
|
||||||
golang.org/x/sys v0.20.0 // indirect
|
golang.org/x/net v0.30.0 // indirect
|
||||||
golang.org/x/text v0.15.0 // indirect
|
golang.org/x/sync v0.8.0 // indirect
|
||||||
|
golang.org/x/sys v0.26.0 // indirect
|
||||||
|
golang.org/x/text v0.19.0 // indirect
|
||||||
golang.org/x/time v0.5.0 // indirect
|
golang.org/x/time v0.5.0 // indirect
|
||||||
golang.org/x/tools v0.21.0 // indirect
|
golang.org/x/tools v0.24.0 // indirect
|
||||||
google.golang.org/protobuf v1.34.1 // indirect
|
google.golang.org/protobuf v1.34.2 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect; indirect`
|
||||||
lukechampine.com/blake3 v1.3.0 // indirect
|
lukechampine.com/blake3 v1.3.0 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
180
core/go.sum
@@ -1,14 +1,10 @@
|
|||||||
github.com/3andne/restls-client-go v0.1.6 h1:tRx/YilqW7iHpgmEL4E1D8dAsuB0tFF3uvncS+B6I08=
|
github.com/3andne/restls-client-go v0.1.6 h1:tRx/YilqW7iHpgmEL4E1D8dAsuB0tFF3uvncS+B6I08=
|
||||||
github.com/3andne/restls-client-go v0.1.6/go.mod h1:iEdTZNt9kzPIxjIGSMScUFSBrUH6bFRNg0BWlP4orEY=
|
github.com/3andne/restls-client-go v0.1.6/go.mod h1:iEdTZNt9kzPIxjIGSMScUFSBrUH6bFRNg0BWlP4orEY=
|
||||||
github.com/Kr328/tun2socket v0.0.0-20220414050025-d07c78d06d34 h1:USCTqih5d1bUXUxWNS9ZD5Tx/lb0jXHEtRIIx/F9dMc=
|
|
||||||
github.com/Kr328/tun2socket v0.0.0-20220414050025-d07c78d06d34/go.mod h1:YR9wK13TgI5ww8iKWm91MHiSoHC7Oz0U4beCCmtXqLw=
|
|
||||||
github.com/RyuaNerin/elliptic2 v1.0.0/go.mod h1:wWB8fWrJI/6EPJkyV/r1Rj0hxUgrusmqSj8JN6yNf/A=
|
github.com/RyuaNerin/elliptic2 v1.0.0/go.mod h1:wWB8fWrJI/6EPJkyV/r1Rj0hxUgrusmqSj8JN6yNf/A=
|
||||||
github.com/RyuaNerin/go-krypto v1.2.4 h1:mXuNdK6M317aPV0llW6Xpjbo4moOlPF7Yxz4tb4b4Go=
|
github.com/RyuaNerin/go-krypto v1.2.4 h1:mXuNdK6M317aPV0llW6Xpjbo4moOlPF7Yxz4tb4b4Go=
|
||||||
github.com/RyuaNerin/go-krypto v1.2.4/go.mod h1:QqCYkoutU3yInyD9INt2PGolVRsc3W4oraQadVGXJ/8=
|
github.com/RyuaNerin/go-krypto v1.2.4/go.mod h1:QqCYkoutU3yInyD9INt2PGolVRsc3W4oraQadVGXJ/8=
|
||||||
github.com/Yawning/aez v0.0.0-20211027044916-e49e68abd344 h1:cDVUiFo+npB0ZASqnw4q90ylaVAbnYyx0JYqK4YcGok=
|
github.com/Yawning/aez v0.0.0-20211027044916-e49e68abd344 h1:cDVUiFo+npB0ZASqnw4q90ylaVAbnYyx0JYqK4YcGok=
|
||||||
github.com/Yawning/aez v0.0.0-20211027044916-e49e68abd344/go.mod h1:9pIqrY6SXNL8vjRQE5Hd/OL5GyK/9MrGUWs87z/eFfk=
|
github.com/Yawning/aez v0.0.0-20211027044916-e49e68abd344/go.mod h1:9pIqrY6SXNL8vjRQE5Hd/OL5GyK/9MrGUWs87z/eFfk=
|
||||||
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY=
|
|
||||||
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA=
|
|
||||||
github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
|
github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
|
||||||
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
|
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
|
||||||
github.com/andybalholm/brotli v1.0.6 h1:Yf9fFpf49Zrxb9NlQaluyE92/+X7UVHlhMNJN2sxfOI=
|
github.com/andybalholm/brotli v1.0.6 h1:Yf9fFpf49Zrxb9NlQaluyE92/+X7UVHlhMNJN2sxfOI=
|
||||||
@@ -21,17 +17,15 @@ github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx2
|
|||||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||||
github.com/cilium/ebpf v0.12.3 h1:8ht6F9MquybnY97at+VDZb3eQQr8ev79RueWeVaEcG4=
|
|
||||||
github.com/cilium/ebpf v0.12.3/go.mod h1:TctK1ivibvI3znr66ljgi4hqOT8EYQjz1KWBfb1UVgM=
|
|
||||||
github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU=
|
github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU=
|
||||||
github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA=
|
github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA=
|
||||||
github.com/coreos/go-iptables v0.7.0 h1:XWM3V+MPRr5/q51NuWSgU0fqMad64Zyxs8ZUoMsamr8=
|
github.com/coreos/go-iptables v0.8.0 h1:MPc2P89IhuVpLI7ETL/2tx3XZ61VeICZjYqDEgNsPRc=
|
||||||
github.com/coreos/go-iptables v0.7.0/go.mod h1:Qe8Bv2Xik5FyTXwgIbLAnv2sWSBmvWdFETJConOQ//Q=
|
github.com/coreos/go-iptables v0.8.0/go.mod h1:Qe8Bv2Xik5FyTXwgIbLAnv2sWSBmvWdFETJConOQ//Q=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI=
|
github.com/dlclark/regexp2 v1.11.4 h1:rPYF9/LECdNymJufQKmri9gV604RvvABwgOA8un7yAo=
|
||||||
github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
|
github.com/dlclark/regexp2 v1.11.4/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
|
||||||
github.com/ericlagergren/aegis v0.0.0-20230312195928-b4ce538b56f9 h1:/5RkVc9Rc81XmMyVqawCiDyrBHZbLAZgTTCqou4mwj8=
|
github.com/ericlagergren/aegis v0.0.0-20230312195928-b4ce538b56f9 h1:/5RkVc9Rc81XmMyVqawCiDyrBHZbLAZgTTCqou4mwj8=
|
||||||
github.com/ericlagergren/aegis v0.0.0-20230312195928-b4ce538b56f9/go.mod h1:hkIFzoiIPZYxdFOOLyDho59b7SrDfo+w3h+yWdlg45I=
|
github.com/ericlagergren/aegis v0.0.0-20230312195928-b4ce538b56f9/go.mod h1:hkIFzoiIPZYxdFOOLyDho59b7SrDfo+w3h+yWdlg45I=
|
||||||
github.com/ericlagergren/polyval v0.0.0-20220411101811-e25bc10ba391 h1:8j2RH289RJplhA6WfdaPqzg1MjH2K8wX5e0uhAxrw2g=
|
github.com/ericlagergren/polyval v0.0.0-20220411101811-e25bc10ba391 h1:8j2RH289RJplhA6WfdaPqzg1MjH2K8wX5e0uhAxrw2g=
|
||||||
@@ -42,16 +36,12 @@ github.com/ericlagergren/siv v0.0.0-20220507050439-0b757b3aa5f1 h1:tlDMEdcPRQKBE
|
|||||||
github.com/ericlagergren/siv v0.0.0-20220507050439-0b757b3aa5f1/go.mod h1:4RfsapbGx2j/vU5xC/5/9qB3kn9Awp1YDiEnN43QrJ4=
|
github.com/ericlagergren/siv v0.0.0-20220507050439-0b757b3aa5f1/go.mod h1:4RfsapbGx2j/vU5xC/5/9qB3kn9Awp1YDiEnN43QrJ4=
|
||||||
github.com/ericlagergren/subtle v0.0.0-20220507045147-890d697da010 h1:fuGucgPk5dN6wzfnxl3D0D3rVLw4v2SbBT9jb4VnxzA=
|
github.com/ericlagergren/subtle v0.0.0-20220507045147-890d697da010 h1:fuGucgPk5dN6wzfnxl3D0D3rVLw4v2SbBT9jb4VnxzA=
|
||||||
github.com/ericlagergren/subtle v0.0.0-20220507045147-890d697da010/go.mod h1:JtBcj7sBuTTRupn7c2bFspMDIObMJsVK8TeUvpShPok=
|
github.com/ericlagergren/subtle v0.0.0-20220507045147-890d697da010/go.mod h1:JtBcj7sBuTTRupn7c2bFspMDIObMJsVK8TeUvpShPok=
|
||||||
github.com/frankban/quicktest v1.14.5 h1:dfYrrRyLtiqT9GyKXgdh+k4inNeTvmGbuSgZ3lx3GhA=
|
|
||||||
github.com/frankban/quicktest v1.14.5/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
|
||||||
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
|
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
|
||||||
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
|
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
|
||||||
github.com/gaukas/godicttls v0.0.4 h1:NlRaXb3J6hAnTmWdsEKb9bcSBD6BvcIjdGdeb0zfXbk=
|
github.com/gaukas/godicttls v0.0.4 h1:NlRaXb3J6hAnTmWdsEKb9bcSBD6BvcIjdGdeb0zfXbk=
|
||||||
github.com/gaukas/godicttls v0.0.4/go.mod h1:l6EenT4TLWgTdwslVb4sEMOCf7Bv0JAK67deKr9/NCI=
|
github.com/gaukas/godicttls v0.0.4/go.mod h1:l6EenT4TLWgTdwslVb4sEMOCf7Bv0JAK67deKr9/NCI=
|
||||||
github.com/go-chi/chi/v5 v5.0.12 h1:9euLV5sTrTNTRUU9POmDUvfxyj6LAABLUcEWO+JJb4s=
|
github.com/go-chi/chi/v5 v5.1.0 h1:acVI1TYaD+hhedDJ3r54HyA6sExp3HfXq7QWEEY/xMw=
|
||||||
github.com/go-chi/chi/v5 v5.0.12/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
|
github.com/go-chi/chi/v5 v5.1.0/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
|
||||||
github.com/go-chi/cors v1.2.1 h1:xEC8UT3Rlp2QuWNEr4Fs/c2EAGVKBwy/1vHx3bppil4=
|
|
||||||
github.com/go-chi/cors v1.2.1/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58=
|
|
||||||
github.com/go-chi/render v1.0.3 h1:AsXqd2a1/INaIfUSKq3G5uA8weYx20FOsM7uSoCyyt4=
|
github.com/go-chi/render v1.0.3 h1:AsXqd2a1/INaIfUSKq3G5uA8weYx20FOsM7uSoCyyt4=
|
||||||
github.com/go-chi/render v1.0.3/go.mod h1:/gr3hVkmYR0YlEy3LxCuVRFzEu9Ruok+gFqbIofjao0=
|
github.com/go-chi/render v1.0.3/go.mod h1:/gr3hVkmYR0YlEy3LxCuVRFzEu9Ruok+gFqbIofjao0=
|
||||||
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
|
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
|
||||||
@@ -67,15 +57,14 @@ github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og=
|
|||||||
github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
|
github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
|
||||||
github.com/gobwas/ws v1.4.0 h1:CTaoG1tojrh4ucGPcoJFiAQUAsEWekEWvLy7GsVNqGs=
|
github.com/gobwas/ws v1.4.0 h1:CTaoG1tojrh4ucGPcoJFiAQUAsEWekEWvLy7GsVNqGs=
|
||||||
github.com/gobwas/ws v1.4.0/go.mod h1:G3gNqMNtPppf5XUz7O4shetPpcZ1VJ7zt18dlUeakrc=
|
github.com/gobwas/ws v1.4.0/go.mod h1:G3gNqMNtPppf5XUz7O4shetPpcZ1VJ7zt18dlUeakrc=
|
||||||
github.com/gofrs/uuid/v5 v5.2.0 h1:qw1GMx6/y8vhVsx626ImfKMuS5CvJmhIKKtuyvfajMM=
|
github.com/gofrs/uuid/v5 v5.3.0 h1:m0mUMr+oVYUdxpMLgSYCZiXe7PuVPnI94+OMeVBNedk=
|
||||||
github.com/gofrs/uuid/v5 v5.2.0/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8=
|
github.com/gofrs/uuid/v5 v5.3.0/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8=
|
||||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
||||||
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||||
github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU=
|
github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU=
|
||||||
github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4=
|
github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4=
|
||||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
|
||||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE=
|
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE=
|
||||||
@@ -85,20 +74,16 @@ github.com/google/tink/go v1.6.1/go.mod h1:IGW53kTgag+st5yPhKKwJ6u2l+SSp5/v9XF7s
|
|||||||
github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE=
|
github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE=
|
||||||
github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
|
github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
|
||||||
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||||
github.com/insomniacslk/dhcp v0.0.0-20240419123447-f1cffa2c0c49 h1:/OuvSMGT9+xnyZ+7MZQ1zdngaCCAdPoSw8B/uurZ7pg=
|
github.com/insomniacslk/dhcp v0.0.0-20240829085014-a3a4c1f04475 h1:hxST5pwMBEOWmxpkX20w9oZG+hXdhKmAIPQ3NGGAxas=
|
||||||
github.com/insomniacslk/dhcp v0.0.0-20240419123447-f1cffa2c0c49/go.mod h1:KclMyHxX06VrVr0DJmeFSUb1ankt7xTfoOA35pCkoic=
|
github.com/insomniacslk/dhcp v0.0.0-20240829085014-a3a4c1f04475/go.mod h1:KclMyHxX06VrVr0DJmeFSUb1ankt7xTfoOA35pCkoic=
|
||||||
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
|
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
|
||||||
github.com/josharian/native v1.0.1-0.20221213033349-c1e37c09b531/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
|
github.com/josharian/native v1.0.1-0.20221213033349-c1e37c09b531/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
|
||||||
github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA=
|
github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA=
|
||||||
github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
|
github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
|
||||||
github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4=
|
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
|
||||||
github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
|
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
|
||||||
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
|
github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM=
|
||||||
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
||||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
|
||||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
|
||||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
|
||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
|
||||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
|
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
|
||||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
|
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
|
||||||
github.com/lunixbochs/struc v0.0.0-20200707160740-784aaebc1d40 h1:EnfXoSqDfSNJv0VBNqY/88RNnhSGYkrHaO0mmFGbVsc=
|
github.com/lunixbochs/struc v0.0.0-20200707160740-784aaebc1d40 h1:EnfXoSqDfSNJv0VBNqY/88RNnhSGYkrHaO0mmFGbVsc=
|
||||||
@@ -109,30 +94,42 @@ 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/netlink v1.7.2/go.mod h1:xraEF7uJbxLhc5fpHL4cPe221LI2bdttWlU+ZGLfQSw=
|
||||||
github.com/mdlayher/socket v0.4.1 h1:eM9y2/jlbs1M615oshPQOHZzj6R6wMT7bX5NPiQvn2U=
|
github.com/mdlayher/socket v0.4.1 h1:eM9y2/jlbs1M615oshPQOHZzj6R6wMT7bX5NPiQvn2U=
|
||||||
github.com/mdlayher/socket v0.4.1/go.mod h1:cAqeGjoufqdxWkD7DkpyS+wcefOtmu5OQ8KuoJGIReA=
|
github.com/mdlayher/socket v0.4.1/go.mod h1:cAqeGjoufqdxWkD7DkpyS+wcefOtmu5OQ8KuoJGIReA=
|
||||||
|
github.com/metacubex/amneziawg-go v0.0.0-20240922133038-fdf3a4d5a4ab h1:Chbw+/31UC14YFNr78pESt5Vowlc62zziw05JCUqoL4=
|
||||||
|
github.com/metacubex/amneziawg-go v0.0.0-20240922133038-fdf3a4d5a4ab/go.mod h1:xVKK8jC5Sd3hfh7WjmCq+HorehIbrBijaUWmcuKjPcI=
|
||||||
|
github.com/metacubex/bbolt v0.0.0-20240822011022-aed6d4850399 h1:oBowHVKZycNtAFbZ6avaCSZJYeme2Nrj+4RpV2cNJig=
|
||||||
|
github.com/metacubex/bbolt v0.0.0-20240822011022-aed6d4850399/go.mod h1:4xcieuIK+M4bGQmQYZVqEaIYqjS1ahO4kXG7EmDgEro=
|
||||||
|
github.com/metacubex/chacha v0.1.0 h1:tg9RSJ18NvL38cCWNyYH1eiG6qDCyyXIaTLQthon0sc=
|
||||||
|
github.com/metacubex/chacha v0.1.0/go.mod h1:Djn9bPZxLTXbJFSeyo0/qzEzQI+gUSSzttuzZM75GH8=
|
||||||
github.com/metacubex/gopacket v1.1.20-0.20230608035415-7e2f98a3e759 h1:cjd4biTvOzK9ubNCCkQ+ldc4YSH/rILn53l/xGBFHHI=
|
github.com/metacubex/gopacket v1.1.20-0.20230608035415-7e2f98a3e759 h1:cjd4biTvOzK9ubNCCkQ+ldc4YSH/rILn53l/xGBFHHI=
|
||||||
github.com/metacubex/gopacket v1.1.20-0.20230608035415-7e2f98a3e759/go.mod h1:UHOv2xu+RIgLwpXca7TLrXleEd4oR3sPatW6IF8wU88=
|
github.com/metacubex/gopacket v1.1.20-0.20230608035415-7e2f98a3e759/go.mod h1:UHOv2xu+RIgLwpXca7TLrXleEd4oR3sPatW6IF8wU88=
|
||||||
github.com/metacubex/gvisor v0.0.0-20240320004321-933faba989ec h1:HxreOiFTUrJXJautEo8rnE1uKTVGY8wtZepY1Tii/Nc=
|
github.com/metacubex/gvisor v0.0.0-20240320004321-933faba989ec h1:HxreOiFTUrJXJautEo8rnE1uKTVGY8wtZepY1Tii/Nc=
|
||||||
github.com/metacubex/gvisor v0.0.0-20240320004321-933faba989ec/go.mod h1:8BVmQ+3cxjqzWElafm24rb2Ae4jRI6vAXNXWqWjfrXw=
|
github.com/metacubex/gvisor v0.0.0-20240320004321-933faba989ec/go.mod h1:8BVmQ+3cxjqzWElafm24rb2Ae4jRI6vAXNXWqWjfrXw=
|
||||||
github.com/metacubex/quic-go v0.43.2-0.20240518033621-2c3d14c6b38e h1:Nzwe08FNIJpExWpy9iXkG336dN/8nJqn69yijB7vJ8g=
|
github.com/metacubex/quic-go v0.47.1-0.20240909010619-6b38f24bfcc4 h1:CgdUBRxmNlxEGkp35HwvgQ10jwOOUJKWdOxpi8yWi8o=
|
||||||
github.com/metacubex/quic-go v0.43.2-0.20240518033621-2c3d14c6b38e/go.mod h1:uXHODgJFUfUnkkCMWLd5Er6L5QY/LFRZb9LD5jyyhsk=
|
github.com/metacubex/quic-go v0.47.1-0.20240909010619-6b38f24bfcc4/go.mod h1:Y7yRGqFE6UQL/3aKPYmiYdjfVkeujJaStP4+jiZMcN8=
|
||||||
github.com/metacubex/sing-quic v0.0.0-20240518034124-7696d3f7da72 h1:Wr4g1HCb5Z/QIFwFiVNjO2qL+dRu25+Mdn9xtAZZ+ew=
|
github.com/metacubex/randv2 v0.2.0 h1:uP38uBvV2SxYfLj53kuvAjbND4RUDfFJjwr4UigMiLs=
|
||||||
github.com/metacubex/sing-quic v0.0.0-20240518034124-7696d3f7da72/go.mod h1:g7Mxj7b7zm7YVqD975mk/hSmrb0A0G4bVvIMr2MMzn8=
|
github.com/metacubex/randv2 v0.2.0/go.mod h1:kFi2SzrQ5WuneuoLLCMkABtiBu6VRrMrWFqSPyj2cxY=
|
||||||
github.com/metacubex/sing-shadowsocks v0.2.6 h1:6oEB3QcsFYnNiFeoevcXrCwJ3sAablwVSgtE9R3QeFQ=
|
github.com/metacubex/sing v0.0.0-20240724044459-6f3cf5896297 h1:YG/JkwGPbca5rUtEMHIu8ZuqzR7BSVm1iqY8hNoMeMA=
|
||||||
github.com/metacubex/sing-shadowsocks v0.2.6/go.mod h1:zIkMeSnb8Mbf4hdqhw0pjzkn1d99YJ3JQm/VBg5WMTg=
|
github.com/metacubex/sing v0.0.0-20240724044459-6f3cf5896297/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak=
|
||||||
github.com/metacubex/sing-shadowsocks2 v0.2.0 h1:hqwT/AfI5d5UdPefIzR6onGHJfDXs5zgOM5QSgaM/9A=
|
github.com/metacubex/sing-quic v0.0.0-20240827003841-cd97758ed8b4 h1:HobpULaPK6OoxrHMmgcwLkwwIduXVmwdcznwUfH1GQM=
|
||||||
github.com/metacubex/sing-shadowsocks2 v0.2.0/go.mod h1:LCKF6j1P94zN8ZS+LXRK1gmYTVGB3squivBSXAFnOg8=
|
github.com/metacubex/sing-quic v0.0.0-20240827003841-cd97758ed8b4/go.mod h1:g7Mxj7b7zm7YVqD975mk/hSmrb0A0G4bVvIMr2MMzn8=
|
||||||
github.com/metacubex/sing-tun v0.2.7-0.20240512075008-89e7c6208eec h1:K4Wq3GOdLZ/xcqwyzAt4kmYQrjokyKQ3u/Xh5Yft14U=
|
github.com/metacubex/sing-shadowsocks v0.2.8 h1:wIhlaigswzjPw4hej75sEvWte3QR0+AJRafgwBHO5B4=
|
||||||
github.com/metacubex/sing-tun v0.2.7-0.20240512075008-89e7c6208eec/go.mod h1:4VsMwZH1IlgPGFK1ZbBomZ/B2MYkTgs2+gnBAr5GOIo=
|
github.com/metacubex/sing-shadowsocks v0.2.8/go.mod h1:X3x88XtJpBxG0W0/ECOJL6Ib0SJ3xdniAkU/6/RMWU0=
|
||||||
github.com/metacubex/sing-vmess v0.1.9-0.20231207122118-72303677451f h1:QjXrHKbTMBip/C+R79bvbfr42xH1gZl3uFb0RELdZiQ=
|
github.com/metacubex/sing-shadowsocks2 v0.2.2 h1:eaf42uVx4Lr21S6MDYs0ZdTvGA0GEhDpb9no4+gdXPo=
|
||||||
github.com/metacubex/sing-vmess v0.1.9-0.20231207122118-72303677451f/go.mod h1:olVkD4FChQ5gKMHG4ZzuD7+fMkJY1G8vwOKpRehjrmY=
|
github.com/metacubex/sing-shadowsocks2 v0.2.2/go.mod h1:BhOug03a/RbI7y6hp6q+6ITM1dXjnLTmeWBHSTwvv2Q=
|
||||||
github.com/metacubex/sing-wireguard v0.0.0-20240321042214-224f96122a63 h1:AGyIB55UfQm/0ZH0HtQO9u3l//yjtHUpjeRjjPGfGRI=
|
github.com/metacubex/sing-tun v0.2.7-0.20240729131039-ed03f557dee1 h1:ypfofGDZbP8p3Y4P/m74JYu7sQViesi3c8nbmT6cS0Y=
|
||||||
github.com/metacubex/sing-wireguard v0.0.0-20240321042214-224f96122a63/go.mod h1:uY+BYb0UEknLrqvbGcwi9i++KgrKxsurysgI6G1Pveo=
|
github.com/metacubex/sing-tun v0.2.7-0.20240729131039-ed03f557dee1/go.mod h1:olbEx9yVcaw5tHTNlRamRoxmMKcvDvcVS1YLnQGzvWE=
|
||||||
github.com/metacubex/tfo-go v0.0.0-20240228025757-be1269474a66 h1:as/aO/fM8nv4W4pOr9EETP6kV/Oaujk3fUNyQSJK61c=
|
github.com/metacubex/sing-vmess v0.1.9-0.20240719134745-1df6fb20bbf9 h1:OAXiCosqY8xKDp3pqTW3qbrCprZ1l6WkrXSFSCwyY4I=
|
||||||
github.com/metacubex/tfo-go v0.0.0-20240228025757-be1269474a66/go.mod h1:c7bVFM9f5+VzeZ/6Kg77T/jrg1Xp8QpqlSHvG/aXVts=
|
github.com/metacubex/sing-vmess v0.1.9-0.20240719134745-1df6fb20bbf9/go.mod h1:olVkD4FChQ5gKMHG4ZzuD7+fMkJY1G8vwOKpRehjrmY=
|
||||||
|
github.com/metacubex/sing-wireguard v0.0.0-20240924052438-b0976fc59ea3 h1:xg71VmzLS6ByAzi/57phwDvjE+dLLs+ozH00k4DnOns=
|
||||||
|
github.com/metacubex/sing-wireguard v0.0.0-20240924052438-b0976fc59ea3/go.mod h1:6nitcmzPDL3MXnLdhu6Hm126Zk4S1fBbX3P7jxUxSFw=
|
||||||
|
github.com/metacubex/tfo-go v0.0.0-20241006021335-daedaf0ca7aa h1:9mcjV+RGZVC3reJBNDjjNPyS8PmFG97zq56X7WNaFO4=
|
||||||
|
github.com/metacubex/tfo-go v0.0.0-20241006021335-daedaf0ca7aa/go.mod h1:4tLB5c8U0CxpkFM+AJJB77jEaVDbLH5XQvy42vAGsWw=
|
||||||
github.com/metacubex/utls v1.6.6 h1:3D12YKHTf2Z41UPhQU2dWerNWJ5TVQD9gKoQ+H+iLC8=
|
github.com/metacubex/utls v1.6.6 h1:3D12YKHTf2Z41UPhQU2dWerNWJ5TVQD9gKoQ+H+iLC8=
|
||||||
github.com/metacubex/utls v1.6.6/go.mod h1:+WLFUnXjcpdxXCnyX25nggw8C6YonZ8zOK2Zm/oRvdo=
|
github.com/metacubex/utls v1.6.6/go.mod h1:+WLFUnXjcpdxXCnyX25nggw8C6YonZ8zOK2Zm/oRvdo=
|
||||||
github.com/miekg/dns v1.1.59 h1:C9EXc/UToRwKLhK5wKU/I4QVsBUc8kE6MkHBkeypWZs=
|
github.com/metacubex/wireguard-go v0.0.0-20240922131502-c182e7471181 h1:hJLQviGySBuaynlCwf/oYgIxbVbGRUIKZCxdya9YrbQ=
|
||||||
github.com/miekg/dns v1.1.59/go.mod h1:nZpewl5p6IvctfgrckopVx2OlSEHPRO/U4SYkRklrEk=
|
github.com/metacubex/wireguard-go v0.0.0-20240922131502-c182e7471181/go.mod h1:phewKljNYiTVT31Gcif8RiCKnTUOgVWFJjccqYM8s+Y=
|
||||||
|
github.com/miekg/dns v1.1.62 h1:cN8OuEF1/x5Rq6Np+h1epln8OiyPWV+lROx9LxcGgIQ=
|
||||||
|
github.com/miekg/dns v1.1.62/go.mod h1:mvDlcItzm+br7MToIKqkglaGhlFMHJ9DTNNWONWXbNQ=
|
||||||
github.com/mroth/weightedrand/v2 v2.1.0 h1:o1ascnB1CIVzsqlfArQQjeMy1U0NcIbBO5rfd5E/OeU=
|
github.com/mroth/weightedrand/v2 v2.1.0 h1:o1ascnB1CIVzsqlfArQQjeMy1U0NcIbBO5rfd5E/OeU=
|
||||||
github.com/mroth/weightedrand/v2 v2.1.0/go.mod h1:f2faGsfOGOwc1p94wzHKKZyTpcJUW7OJ/9U4yfiNAOU=
|
github.com/mroth/weightedrand/v2 v2.1.0/go.mod h1:f2faGsfOGOwc1p94wzHKKZyTpcJUW7OJ/9U4yfiNAOU=
|
||||||
github.com/oasisprotocol/deoxysii v0.0.0-20220228165953-2091330c22b7 h1:1102pQc2SEPp5+xrS26wEaeb26sZy6k9/ZXlZN+eXE4=
|
github.com/oasisprotocol/deoxysii v0.0.0-20220228165953-2091330c22b7 h1:1102pQc2SEPp5+xrS26wEaeb26sZy6k9/ZXlZN+eXE4=
|
||||||
@@ -155,33 +152,30 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
|
|||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=
|
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=
|
||||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
|
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
|
||||||
github.com/puzpuzpuz/xsync/v3 v3.1.0 h1:EewKT7/LNac5SLiEblJeUu8z5eERHrmRLnMQL2d7qX4=
|
github.com/puzpuzpuz/xsync/v3 v3.4.0 h1:DuVBAdXuGFHv8adVXjWWZ63pJq+NRXOWVXlKDBZ+mJ4=
|
||||||
github.com/puzpuzpuz/xsync/v3 v3.1.0/go.mod h1:VjzYrABPabuM4KyBh1Ftq6u8nhwY5tBPKP9jpmh0nnA=
|
github.com/puzpuzpuz/xsync/v3 v3.4.0/go.mod h1:VjzYrABPabuM4KyBh1Ftq6u8nhwY5tBPKP9jpmh0nnA=
|
||||||
github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo=
|
github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo=
|
||||||
github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A=
|
github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A=
|
||||||
github.com/quic-go/qtls-go1-20 v0.4.1 h1:D33340mCNDAIKBqXuAvexTNMUByrYmFYVfKfDN5nfFs=
|
github.com/quic-go/qtls-go1-20 v0.4.1 h1:D33340mCNDAIKBqXuAvexTNMUByrYmFYVfKfDN5nfFs=
|
||||||
github.com/quic-go/qtls-go1-20 v0.4.1/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k=
|
github.com/quic-go/qtls-go1-20 v0.4.1/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k=
|
||||||
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
github.com/sagernet/cors v1.2.1 h1:Cv5Z8y9YSD6Gm+qSpNrL3LO4lD3eQVvbFYJSG7JCMHQ=
|
||||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
github.com/sagernet/cors v1.2.1/go.mod h1:O64VyOjjhrkLmQIjF4KGRrJO/5dVXFdpEmCW/eISRAI=
|
||||||
github.com/sagernet/bbolt v0.0.0-20231014093535-ea5cb2fe9f0a h1:+NkI2670SQpQWvkkD2QgdTuzQG263YZ+2emfpeyGqW0=
|
github.com/sagernet/fswatch v0.1.1 h1:YqID+93B7VRfqIH3PArW/XpJv5H4OLEVWDfProGoRQs=
|
||||||
github.com/sagernet/bbolt v0.0.0-20231014093535-ea5cb2fe9f0a/go.mod h1:63s7jpZqcDAIpj8oI/1v4Izok+npJOHACFCU6+huCkM=
|
github.com/sagernet/fswatch v0.1.1/go.mod h1:nz85laH0mkQqJfaOrqPpkwtU1znMFNVTpT/5oRsVz/o=
|
||||||
github.com/sagernet/netlink v0.0.0-20220905062125-8043b4a9aa97 h1:iL5gZI3uFp0X6EslacyapiRz7LLSJyr4RajF/BhMVyE=
|
github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a h1:ObwtHN2VpqE0ZNjr6sGeT00J8uU7JF4cNUdb44/Duis=
|
||||||
github.com/sagernet/netlink v0.0.0-20220905062125-8043b4a9aa97/go.mod h1:xLnfdiJbSp8rNqYEdIW/6eDO4mVoogml14Bh2hSiFpM=
|
github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a/go.mod h1:xLnfdiJbSp8rNqYEdIW/6eDO4mVoogml14Bh2hSiFpM=
|
||||||
github.com/sagernet/sing v0.2.18/go.mod h1:OL6k2F0vHmEzXz2KW19qQzu172FDgSbUSODylighuVo=
|
github.com/sagernet/nftables v0.3.0-beta.4 h1:kbULlAwAC3jvdGAC1P5Fa3GSxVwQJibNenDW2zaXr8I=
|
||||||
github.com/sagernet/sing v0.3.8 h1:gm4JKalPhydMYX2zFOTnnd4TXtM/16WFRqSjMepYQQk=
|
github.com/sagernet/nftables v0.3.0-beta.4/go.mod h1:OQXAjvjNGGFxaTgVCSTRIhYB5/llyVDeapVoENYBDS8=
|
||||||
github.com/sagernet/sing v0.3.8/go.mod h1:+60H3Cm91RnL9dpVGWDPHt0zTQImO9Vfqt9a4rSambI=
|
|
||||||
github.com/sagernet/sing-mux v0.2.1-0.20240124034317-9bfb33698bb6 h1:5bCAkvDDzSMITiHFjolBwpdqYsvycdTu71FsMEFXQ14=
|
github.com/sagernet/sing-mux v0.2.1-0.20240124034317-9bfb33698bb6 h1:5bCAkvDDzSMITiHFjolBwpdqYsvycdTu71FsMEFXQ14=
|
||||||
github.com/sagernet/sing-mux v0.2.1-0.20240124034317-9bfb33698bb6/go.mod h1:khzr9AOPocLa+g53dBplwNDz4gdsyx/YM3swtAhlkHQ=
|
github.com/sagernet/sing-mux v0.2.1-0.20240124034317-9bfb33698bb6/go.mod h1:khzr9AOPocLa+g53dBplwNDz4gdsyx/YM3swtAhlkHQ=
|
||||||
github.com/sagernet/sing-shadowtls v0.1.4 h1:aTgBSJEgnumzFenPvc+kbD9/W0PywzWevnVpEx6Tw3k=
|
github.com/sagernet/sing-shadowtls v0.1.4 h1:aTgBSJEgnumzFenPvc+kbD9/W0PywzWevnVpEx6Tw3k=
|
||||||
github.com/sagernet/sing-shadowtls v0.1.4/go.mod h1:F8NBgsY5YN2beQavdgdm1DPlhaKQlaL6lpDdcBglGK4=
|
github.com/sagernet/sing-shadowtls v0.1.4/go.mod h1:F8NBgsY5YN2beQavdgdm1DPlhaKQlaL6lpDdcBglGK4=
|
||||||
github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7 h1:DImB4lELfQhplLTxeq2z31Fpv8CQqqrUwTbrIRumZqQ=
|
github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7 h1:DImB4lELfQhplLTxeq2z31Fpv8CQqqrUwTbrIRumZqQ=
|
||||||
github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7/go.mod h1:FP9X2xjT/Az1EsG/orYYoC+5MojWnuI7hrffz8fGwwo=
|
github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7/go.mod h1:FP9X2xjT/Az1EsG/orYYoC+5MojWnuI7hrffz8fGwwo=
|
||||||
github.com/sagernet/wireguard-go v0.0.0-20231209092712-9a439356a62e h1:iGH0RMv2FzELOFNFQtvsxH7NPmlo7X5JizEK51UCojo=
|
github.com/samber/lo v1.47.0 h1:z7RynLwP5nbyRscyvcD043DWYoOcYRv3mV8lBeqOCLc=
|
||||||
github.com/sagernet/wireguard-go v0.0.0-20231209092712-9a439356a62e/go.mod h1:YbL4TKHRR6APYQv3U2RGfwLDpPYSyWz6oUlpISBEzBE=
|
github.com/samber/lo v1.47.0/go.mod h1:RmDH9Ct32Qy3gduHQuKJ3gW1fMHAnE/fAzQuf6He5cU=
|
||||||
github.com/samber/lo v1.39.0 h1:4gTz1wUhNYLhFSKl6O+8peW0v2F4BCY034GRpU9WnuA=
|
github.com/shirou/gopsutil/v3 v3.24.5 h1:i0t8kL+kQTvpAYToeuiVk3TgDeKOFioZO3Ztz/iZ9pI=
|
||||||
github.com/samber/lo v1.39.0/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA=
|
github.com/shirou/gopsutil/v3 v3.24.5/go.mod h1:bsoOS1aStSs9ErQ1WWfxllSeS1K5D+U30r2NfcubMVk=
|
||||||
github.com/shirou/gopsutil/v3 v3.24.4 h1:dEHgzZXt4LMNm+oYELpzl9YCqV65Yr/6SfrvgRBtXeU=
|
|
||||||
github.com/shirou/gopsutil/v3 v3.24.4/go.mod h1:lTd2mdiOspcqLgAnr9/nGi71NkeMpWKdmhuxm9GusH8=
|
|
||||||
github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM=
|
github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM=
|
||||||
github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ=
|
github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ=
|
||||||
github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
|
github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
|
||||||
@@ -215,14 +209,18 @@ github.com/u-root/uio v0.0.0-20230220225925-ffce2a382923/go.mod h1:eLL9Nub3yfAho
|
|||||||
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
|
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
|
||||||
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU=
|
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU=
|
||||||
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
|
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
|
||||||
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 h1:gga7acRE695APm9hlsSMoOoE65U4/TcqNj90mc69Rlg=
|
github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8=
|
||||||
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
|
github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM=
|
||||||
|
github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8=
|
||||||
|
github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
|
||||||
|
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
|
||||||
|
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
|
||||||
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
|
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
|
||||||
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
|
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
|
||||||
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
|
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
|
||||||
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
||||||
github.com/zhangyunhao116/fastrand v0.4.0 h1:86QB6Y+GGgLZRFRDCjMmAS28QULwspK9sgL5d1Bx3H4=
|
gitlab.com/go-extension/aes-ccm v0.0.0-20230221065045-e58665ef23c7 h1:UNrDfkQqiEYzdMlNsVvBYOAJWZjdktqFE9tQh5BT2+4=
|
||||||
github.com/zhangyunhao116/fastrand v0.4.0/go.mod h1:vIyo6EyBhjGKpZv6qVlkPl4JVAklpMM4DSKzbAkMguA=
|
gitlab.com/go-extension/aes-ccm v0.0.0-20230221065045-e58665ef23c7/go.mod h1:E+rxHvJG9H6PUdzq9NRG6csuLN3XUx98BfGOVWNYnXs=
|
||||||
gitlab.com/yawning/bsaes.git v0.0.0-20190805113838-0a714cd429ec h1:FpfFs4EhNehiVfzQttTuxanPIT43FtkkCFypIod8LHo=
|
gitlab.com/yawning/bsaes.git v0.0.0-20190805113838-0a714cd429ec h1:FpfFs4EhNehiVfzQttTuxanPIT43FtkkCFypIod8LHo=
|
||||||
gitlab.com/yawning/bsaes.git v0.0.0-20190805113838-0a714cd429ec/go.mod h1:BZ1RAoRPbCxum9Grlv5aeksu2H8BiKehBYooU2LFiOQ=
|
gitlab.com/yawning/bsaes.git v0.0.0-20190805113838-0a714cd429ec/go.mod h1:BZ1RAoRPbCxum9Grlv5aeksu2H8BiKehBYooU2LFiOQ=
|
||||||
go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=
|
go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=
|
||||||
@@ -231,21 +229,21 @@ go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBs
|
|||||||
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y=
|
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
|
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
|
||||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
|
||||||
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM=
|
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e h1:I88y4caeGeuDQxgdoFPUq097j7kNfw6uvuiNxUBfcBk=
|
||||||
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
|
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ=
|
||||||
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||||
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
|
golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
|
||||||
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
|
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
|
||||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
|
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
|
||||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
@@ -261,27 +259,25 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
|
||||||
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
|
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
|
||||||
golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw=
|
golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
|
||||||
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
|
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
|
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
|
||||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
||||||
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
|
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
|
||||||
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||||
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||||
golang.org/x/tools v0.21.0 h1:qc0xYgIbsSDt9EyWz05J5wfa7LOVW0YTLOXrqdLAWIw=
|
golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24=
|
||||||
golang.org/x/tools v0.21.0/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ=
|
||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
|
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
|
||||||
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
|||||||
380
core/hub.go
@@ -1,35 +1,59 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
|
/*
|
||||||
|
#include <stdlib.h>
|
||||||
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
bridge "core/dart-bridge"
|
bridge "core/dart-bridge"
|
||||||
|
"core/state"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/metacubex/mihomo/common/utils"
|
||||||
|
"os"
|
||||||
|
"runtime"
|
||||||
|
"sort"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
"github.com/metacubex/mihomo/adapter"
|
"github.com/metacubex/mihomo/adapter"
|
||||||
"github.com/metacubex/mihomo/adapter/outboundgroup"
|
"github.com/metacubex/mihomo/adapter/outboundgroup"
|
||||||
"github.com/metacubex/mihomo/adapter/provider"
|
"github.com/metacubex/mihomo/adapter/provider"
|
||||||
"github.com/metacubex/mihomo/common/structure"
|
"github.com/metacubex/mihomo/component/updater"
|
||||||
"github.com/metacubex/mihomo/common/utils"
|
|
||||||
"github.com/metacubex/mihomo/component/mmdb"
|
|
||||||
"github.com/metacubex/mihomo/config"
|
"github.com/metacubex/mihomo/config"
|
||||||
"github.com/metacubex/mihomo/constant"
|
"github.com/metacubex/mihomo/constant"
|
||||||
cp "github.com/metacubex/mihomo/constant/provider"
|
cp "github.com/metacubex/mihomo/constant/provider"
|
||||||
"github.com/metacubex/mihomo/hub/executor"
|
"github.com/metacubex/mihomo/hub/executor"
|
||||||
"github.com/metacubex/mihomo/log"
|
"github.com/metacubex/mihomo/log"
|
||||||
rp "github.com/metacubex/mihomo/rules/provider"
|
|
||||||
"github.com/metacubex/mihomo/tunnel"
|
"github.com/metacubex/mihomo/tunnel"
|
||||||
"github.com/metacubex/mihomo/tunnel/statistic"
|
"github.com/metacubex/mihomo/tunnel/statistic"
|
||||||
"golang.org/x/net/context"
|
|
||||||
"os"
|
|
||||||
"runtime"
|
|
||||||
"time"
|
|
||||||
"unsafe"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var currentConfig = config.DefaultRawConfig()
|
var configParams = ConfigExtendedParams{}
|
||||||
|
|
||||||
|
var externalProviders = map[string]cp.Provider{}
|
||||||
|
|
||||||
var isInit = false
|
var isInit = false
|
||||||
|
|
||||||
|
//export start
|
||||||
|
func start() {
|
||||||
|
runLock.Lock()
|
||||||
|
defer runLock.Unlock()
|
||||||
|
isRunning = true
|
||||||
|
}
|
||||||
|
|
||||||
|
//export stop
|
||||||
|
func stop() {
|
||||||
|
runLock.Lock()
|
||||||
|
go func() {
|
||||||
|
defer runLock.Unlock()
|
||||||
|
isRunning = false
|
||||||
|
stopListeners()
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
//export initClash
|
//export initClash
|
||||||
func initClash(homeDirStr *C.char) bool {
|
func initClash(homeDirStr *C.char) bool {
|
||||||
if !isInit {
|
if !isInit {
|
||||||
@@ -53,10 +77,10 @@ func restartClash() bool {
|
|||||||
|
|
||||||
//export shutdownClash
|
//export shutdownClash
|
||||||
func shutdownClash() bool {
|
func shutdownClash() bool {
|
||||||
|
stopListeners()
|
||||||
executor.Shutdown()
|
executor.Shutdown()
|
||||||
runtime.GC()
|
runtime.GC()
|
||||||
isInit = false
|
isInit = false
|
||||||
currentConfig = nil
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,8 +95,8 @@ func forceGc() {
|
|||||||
//export validateConfig
|
//export validateConfig
|
||||||
func validateConfig(s *C.char, port C.longlong) {
|
func validateConfig(s *C.char, port C.longlong) {
|
||||||
i := int64(port)
|
i := int64(port)
|
||||||
|
bytes := []byte(C.GoString(s))
|
||||||
go func() {
|
go func() {
|
||||||
bytes := []byte(C.GoString(s))
|
|
||||||
_, err := config.UnmarshalRawConfig(bytes)
|
_, err := config.UnmarshalRawConfig(bytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
bridge.SendToPort(i, err.Error())
|
bridge.SendToPort(i, err.Error())
|
||||||
@@ -82,23 +106,28 @@ func validateConfig(s *C.char, port C.longlong) {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var updateLock sync.Mutex
|
||||||
|
|
||||||
//export updateConfig
|
//export updateConfig
|
||||||
func updateConfig(s *C.char, port C.longlong) {
|
func updateConfig(s *C.char, port C.longlong) {
|
||||||
i := int64(port)
|
i := int64(port)
|
||||||
|
paramsString := C.GoString(s)
|
||||||
go func() {
|
go func() {
|
||||||
paramsString := C.GoString(s)
|
updateLock.Lock()
|
||||||
|
defer updateLock.Unlock()
|
||||||
var params = &GenerateConfigParams{}
|
var params = &GenerateConfigParams{}
|
||||||
err := json.Unmarshal([]byte(paramsString), params)
|
err := json.Unmarshal([]byte(paramsString), params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
bridge.SendToPort(i, err.Error())
|
bridge.SendToPort(i, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
prof := decorationConfig(params.ProfilePath, *params.Config, *params.IsCompatible)
|
configParams = params.Params
|
||||||
currentConfig = prof
|
prof := decorationConfig(params.ProfileId, params.Config)
|
||||||
if *params.IsPatch {
|
state.CurrentRawConfig = prof
|
||||||
applyConfig(true)
|
err = applyConfig()
|
||||||
} else {
|
if err != nil {
|
||||||
applyConfig(false)
|
bridge.SendToPort(i, err.Error())
|
||||||
|
return
|
||||||
}
|
}
|
||||||
bridge.SendToPort(i, "")
|
bridge.SendToPort(i, "")
|
||||||
}()
|
}()
|
||||||
@@ -106,34 +135,10 @@ func updateConfig(s *C.char, port C.longlong) {
|
|||||||
|
|
||||||
//export clearEffect
|
//export clearEffect
|
||||||
func clearEffect(s *C.char) {
|
func clearEffect(s *C.char) {
|
||||||
path := C.GoString(s)
|
id := C.GoString(s)
|
||||||
go func() {
|
go func() {
|
||||||
rawCfg := getRawConfigWithPath(&path)
|
_ = removeFile(getProfilePath(id))
|
||||||
for _, mapping := range rawCfg.RuleProvider {
|
_ = removeFile(getProfileProvidersPath(id))
|
||||||
schema := &ruleProviderSchema{}
|
|
||||||
decoder := structure.NewDecoder(structure.Option{TagName: "provider", WeaklyTypedInput: true})
|
|
||||||
if err := decoder.Decode(mapping, schema); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if schema.Type == "http" {
|
|
||||||
_ = removeFile(constant.Path.Resolve(schema.Path))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for _, mapping := range rawCfg.ProxyProvider {
|
|
||||||
schema := &proxyProviderSchema{
|
|
||||||
HealthCheck: healthCheckSchema{
|
|
||||||
Lazy: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
decoder := structure.NewDecoder(structure.Option{TagName: "provider", WeaklyTypedInput: true})
|
|
||||||
if err := decoder.Decode(mapping, schema); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if schema.Type == "http" {
|
|
||||||
_ = removeFile(constant.Path.Resolve(schema.Path))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ = removeFile(path)
|
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,35 +152,38 @@ func getProxies() *C.char {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//export changeProxy
|
//export changeProxy
|
||||||
func changeProxy(s *C.char) bool {
|
func changeProxy(s *C.char) {
|
||||||
go func() {
|
paramsString := C.GoString(s)
|
||||||
paramsString := C.GoString(s)
|
var params = &ChangeProxyParams{}
|
||||||
var params = &ChangeProxyParams{}
|
err := json.Unmarshal([]byte(paramsString), params)
|
||||||
err := json.Unmarshal([]byte(paramsString), params)
|
if err != nil {
|
||||||
if err != nil {
|
log.Infoln("Unmarshal ChangeProxyParams %v", err)
|
||||||
log.Infoln("Unmarshal ChangeProxyParams %v", err)
|
}
|
||||||
}
|
groupName := *params.GroupName
|
||||||
proxies := tunnel.ProxiesWithProviders()
|
proxyName := *params.ProxyName
|
||||||
proxy := proxies[*params.GroupName]
|
proxies := tunnel.ProxiesWithProviders()
|
||||||
if proxy == nil {
|
group, ok := proxies[groupName]
|
||||||
return
|
if !ok {
|
||||||
}
|
return
|
||||||
log.Infoln("change proxy %s", proxy.Name())
|
}
|
||||||
adapterProxy := proxy.(*adapter.Proxy)
|
adapterProxy := group.(*adapter.Proxy)
|
||||||
selector, ok := adapterProxy.ProxyAdapter.(*outboundgroup.Selector)
|
selector, ok := adapterProxy.ProxyAdapter.(outboundgroup.SelectAble)
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := selector.Set(*params.ProxyName); err != nil {
|
if proxyName == "" {
|
||||||
return
|
selector.ForceSet(proxyName)
|
||||||
}
|
} else {
|
||||||
}()
|
err = selector.Set(proxyName)
|
||||||
return true
|
}
|
||||||
|
if err == nil {
|
||||||
|
log.Infoln("[SelectAble] %s selected %s", groupName, proxyName)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//export getTraffic
|
//export getTraffic
|
||||||
func getTraffic() *C.char {
|
func getTraffic() *C.char {
|
||||||
up, down := statistic.DefaultManager.Now()
|
up, down := statistic.DefaultManager.Current(state.CurrentState.OnlyProxy)
|
||||||
traffic := map[string]int64{
|
traffic := map[string]int64{
|
||||||
"up": up,
|
"up": up,
|
||||||
"down": down,
|
"down": down,
|
||||||
@@ -188,20 +196,42 @@ func getTraffic() *C.char {
|
|||||||
return C.CString(string(data))
|
return C.CString(string(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//export getTotalTraffic
|
||||||
|
func getTotalTraffic() *C.char {
|
||||||
|
up, down := statistic.DefaultManager.Total(state.CurrentState.OnlyProxy)
|
||||||
|
traffic := map[string]int64{
|
||||||
|
"up": up,
|
||||||
|
"down": down,
|
||||||
|
}
|
||||||
|
data, err := json.Marshal(traffic)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error:", err)
|
||||||
|
return C.CString("")
|
||||||
|
}
|
||||||
|
return C.CString(string(data))
|
||||||
|
}
|
||||||
|
|
||||||
|
//export resetTraffic
|
||||||
|
func resetTraffic() {
|
||||||
|
statistic.DefaultManager.ResetStatistic()
|
||||||
|
}
|
||||||
|
|
||||||
//export asyncTestDelay
|
//export asyncTestDelay
|
||||||
func asyncTestDelay(s *C.char, port C.longlong) {
|
func asyncTestDelay(s *C.char, port C.longlong) {
|
||||||
i := int64(port)
|
i := int64(port)
|
||||||
go func() {
|
paramsString := C.GoString(s)
|
||||||
paramsString := C.GoString(s)
|
b.Go(paramsString, func() (bool, error) {
|
||||||
var params = &TestDelayParams{}
|
var params = &TestDelayParams{}
|
||||||
err := json.Unmarshal([]byte(paramsString), params)
|
err := json.Unmarshal([]byte(paramsString), params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
bridge.SendToPort(i, "")
|
||||||
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
expectedStatus, err := utils.NewUnsignedRanges[uint16]("")
|
expectedStatus, err := utils.NewUnsignedRanges[uint16]("")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
bridge.SendToPort(i, "")
|
||||||
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*time.Duration(params.Timeout))
|
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*time.Duration(params.Timeout))
|
||||||
@@ -218,7 +248,7 @@ func asyncTestDelay(s *C.char, port C.longlong) {
|
|||||||
delayData.Value = -1
|
delayData.Value = -1
|
||||||
data, _ := json.Marshal(delayData)
|
data, _ := json.Marshal(delayData)
|
||||||
bridge.SendToPort(i, string(data))
|
bridge.SendToPort(i, string(data))
|
||||||
return
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
delay, err := proxy.URLTest(ctx, constant.DefaultTestURL, expectedStatus)
|
delay, err := proxy.URLTest(ctx, constant.DefaultTestURL, expectedStatus)
|
||||||
@@ -226,14 +256,14 @@ func asyncTestDelay(s *C.char, port C.longlong) {
|
|||||||
delayData.Value = -1
|
delayData.Value = -1
|
||||||
data, _ := json.Marshal(delayData)
|
data, _ := json.Marshal(delayData)
|
||||||
bridge.SendToPort(i, string(data))
|
bridge.SendToPort(i, string(data))
|
||||||
return
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
delayData.Value = int32(delay)
|
delayData.Value = int32(delay)
|
||||||
data, _ := json.Marshal(delayData)
|
data, _ := json.Marshal(delayData)
|
||||||
bridge.SendToPort(i, string(data))
|
bridge.SendToPort(i, string(data))
|
||||||
return
|
return false, nil
|
||||||
}()
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
//export getVersionInfo
|
//export getVersionInfo
|
||||||
@@ -262,7 +292,7 @@ func getConnections() *C.char {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//export closeConnections
|
//export closeConnections
|
||||||
func closeConnections() bool {
|
func closeConnections() {
|
||||||
statistic.DefaultManager.Range(func(c statistic.Tracker) bool {
|
statistic.DefaultManager.Range(func(c statistic.Tracker) bool {
|
||||||
err := c.Close()
|
err := c.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -270,27 +300,28 @@ func closeConnections() bool {
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//export closeConnection
|
//export closeConnection
|
||||||
func closeConnection(id *C.char) bool {
|
func closeConnection(id *C.char) {
|
||||||
connectionId := C.GoString(id)
|
connectionId := C.GoString(id)
|
||||||
|
c := statistic.DefaultManager.Get(connectionId)
|
||||||
err := statistic.DefaultManager.Get(connectionId).Close()
|
if c == nil {
|
||||||
if err != nil {
|
return
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
return true
|
_ = c.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
//export getProviders
|
//export getProviders
|
||||||
func getProviders() *C.char {
|
func getProviders() *C.char {
|
||||||
data, err := json.Marshal(tunnel.Providers())
|
data, err := json.Marshal(tunnel.Providers())
|
||||||
|
var msg *C.char
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return C.CString("")
|
msg = C.CString("")
|
||||||
|
return msg
|
||||||
}
|
}
|
||||||
return C.CString(string(data))
|
msg = C.CString(string(data))
|
||||||
|
return msg
|
||||||
}
|
}
|
||||||
|
|
||||||
//export getProvider
|
//export getProvider
|
||||||
@@ -306,73 +337,68 @@ func getProvider(name *C.char) *C.char {
|
|||||||
|
|
||||||
//export getExternalProviders
|
//export getExternalProviders
|
||||||
func getExternalProviders() *C.char {
|
func getExternalProviders() *C.char {
|
||||||
externalProviders := make([]ExternalProvider, 0)
|
eps := make([]ExternalProvider, 0)
|
||||||
providers := tunnel.Providers()
|
for _, p := range externalProviders {
|
||||||
for n, p := range providers {
|
externalProvider, err := toExternalProvider(p)
|
||||||
if p.VehicleType() != cp.Compatible {
|
if err != nil {
|
||||||
p := p.(*provider.ProxySetProvider)
|
continue
|
||||||
externalProviders = append(externalProviders, ExternalProvider{
|
|
||||||
Name: n,
|
|
||||||
Type: p.Type().String(),
|
|
||||||
VehicleType: p.VehicleType().String(),
|
|
||||||
UpdateAt: p.UpdatedAt,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
eps = append(eps, *externalProvider)
|
||||||
}
|
}
|
||||||
for n, p := range tunnel.RuleProviders() {
|
sort.Sort(ExternalProviders(eps))
|
||||||
if p.VehicleType() != cp.Compatible {
|
data, err := json.Marshal(eps)
|
||||||
p := p.(*rp.RuleSetProvider)
|
|
||||||
externalProviders = append(externalProviders, ExternalProvider{
|
|
||||||
Name: n,
|
|
||||||
Type: p.Type().String(),
|
|
||||||
VehicleType: p.VehicleType().String(),
|
|
||||||
UpdateAt: p.UpdatedAt,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
data, err := json.Marshal(externalProviders)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return C.CString("")
|
return C.CString("")
|
||||||
}
|
}
|
||||||
return C.CString(string(data))
|
return C.CString(string(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
//export updateExternalProvider
|
//export getExternalProvider
|
||||||
func updateExternalProvider(providerName *C.char, providerType *C.char, port C.longlong) {
|
func getExternalProvider(name *C.char) *C.char {
|
||||||
i := int64(port)
|
externalProviderName := C.GoString(name)
|
||||||
go func() {
|
externalProvider, exist := externalProviders[externalProviderName]
|
||||||
providerNameString := C.GoString(providerName)
|
if !exist {
|
||||||
providerTypeString := C.GoString(providerType)
|
return C.CString("")
|
||||||
|
}
|
||||||
|
e, err := toExternalProvider(externalProvider)
|
||||||
|
if err != nil {
|
||||||
|
return C.CString("")
|
||||||
|
}
|
||||||
|
data, err := json.Marshal(e)
|
||||||
|
if err != nil {
|
||||||
|
return C.CString("")
|
||||||
|
}
|
||||||
|
return C.CString(string(data))
|
||||||
|
}
|
||||||
|
|
||||||
switch providerTypeString {
|
//export updateGeoData
|
||||||
case "Proxy":
|
func updateGeoData(geoType *C.char, geoName *C.char, port C.longlong) {
|
||||||
providers := tunnel.Providers()
|
i := int64(port)
|
||||||
err := providers[providerNameString].Update()
|
geoTypeString := C.GoString(geoType)
|
||||||
if err != nil {
|
geoNameString := C.GoString(geoName)
|
||||||
bridge.SendToPort(i, err.Error())
|
go func() {
|
||||||
return
|
path := constant.Path.Resolve(geoNameString)
|
||||||
}
|
switch geoTypeString {
|
||||||
case "Rule":
|
case "MMDB":
|
||||||
providers := tunnel.RuleProviders()
|
err := updater.UpdateMMDBWithPath(path)
|
||||||
err := providers[providerNameString].Update()
|
|
||||||
if err != nil {
|
|
||||||
bridge.SendToPort(i, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
case "GeoIp":
|
|
||||||
err := mmdb.DownloadMMDB(constant.Path.Resolve(providerNameString))
|
|
||||||
if err != nil {
|
|
||||||
bridge.SendToPort(i, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
case "GeoSite":
|
|
||||||
err := mmdb.DownloadGeoSite(constant.Path.Resolve(providerNameString))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
bridge.SendToPort(i, err.Error())
|
bridge.SendToPort(i, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case "ASN":
|
case "ASN":
|
||||||
err := mmdb.DownloadASN(constant.Path.Resolve(providerNameString))
|
err := updater.UpdateASNWithPath(path)
|
||||||
|
if err != nil {
|
||||||
|
bridge.SendToPort(i, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
case "GeoIp":
|
||||||
|
err := updater.UpdateGeoIpWithPath(path)
|
||||||
|
if err != nil {
|
||||||
|
bridge.SendToPort(i, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
case "GeoSite":
|
||||||
|
err := updater.UpdateGeoSiteWithPath(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
bridge.SendToPort(i, err.Error())
|
bridge.SendToPort(i, err.Error())
|
||||||
return
|
return
|
||||||
@@ -382,11 +408,59 @@ func updateExternalProvider(providerName *C.char, providerType *C.char, port C.l
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
//export initNativeApiBridge
|
//export updateExternalProvider
|
||||||
func initNativeApiBridge(api unsafe.Pointer, port C.longlong) {
|
func updateExternalProvider(providerName *C.char, port C.longlong) {
|
||||||
bridge.InitDartApi(api)
|
|
||||||
i := int64(port)
|
i := int64(port)
|
||||||
bridge.Port = &i
|
providerNameString := C.GoString(providerName)
|
||||||
|
go func() {
|
||||||
|
externalProvider, exist := externalProviders[providerNameString]
|
||||||
|
if !exist {
|
||||||
|
bridge.SendToPort(i, "external provider is not exist")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := externalProvider.Update()
|
||||||
|
if err != nil {
|
||||||
|
bridge.SendToPort(i, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
bridge.SendToPort(i, "")
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
//export sideLoadExternalProvider
|
||||||
|
func sideLoadExternalProvider(providerName *C.char, data *C.char, port C.longlong) {
|
||||||
|
i := int64(port)
|
||||||
|
bytes := []byte(C.GoString(data))
|
||||||
|
providerNameString := C.GoString(providerName)
|
||||||
|
go func() {
|
||||||
|
externalProvider, exist := externalProviders[providerNameString]
|
||||||
|
if !exist {
|
||||||
|
bridge.SendToPort(i, "external provider is not exist")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := sideUpdateExternalProvider(externalProvider, bytes)
|
||||||
|
if err != nil {
|
||||||
|
bridge.SendToPort(i, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
bridge.SendToPort(i, "")
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
//export initNativeApiBridge
|
||||||
|
func initNativeApiBridge(api unsafe.Pointer) {
|
||||||
|
bridge.InitDartApi(api)
|
||||||
|
}
|
||||||
|
|
||||||
|
//export initMessage
|
||||||
|
func initMessage(port C.longlong) {
|
||||||
|
i := int64(port)
|
||||||
|
Port = i
|
||||||
|
}
|
||||||
|
|
||||||
|
//export freeCString
|
||||||
|
func freeCString(s *C.char) {
|
||||||
|
C.free(unsafe.Pointer(s))
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -399,15 +473,21 @@ func init() {
|
|||||||
} else {
|
} else {
|
||||||
delayData.Value = int32(delay)
|
delayData.Value = int32(delay)
|
||||||
}
|
}
|
||||||
bridge.SendMessage(bridge.Message{
|
SendMessage(Message{
|
||||||
Type: bridge.Delay,
|
Type: DelayMessage,
|
||||||
Data: delayData,
|
Data: delayData,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
statistic.DefaultRequestNotify = func(c statistic.Tracker) {
|
statistic.DefaultRequestNotify = func(c statistic.Tracker) {
|
||||||
bridge.SendMessage(bridge.Message{
|
SendMessage(Message{
|
||||||
Type: bridge.Request,
|
Type: RequestMessage,
|
||||||
Data: c,
|
Data: c,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
executor.DefaultProviderLoadedHook = func(providerName string) {
|
||||||
|
SendMessage(Message{
|
||||||
|
Type: LoadedMessage,
|
||||||
|
Data: providerName,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package main
|
|||||||
|
|
||||||
import "C"
|
import "C"
|
||||||
import (
|
import (
|
||||||
bridge "core/dart-bridge"
|
|
||||||
"github.com/metacubex/mihomo/common/observable"
|
"github.com/metacubex/mihomo/common/observable"
|
||||||
"github.com/metacubex/mihomo/log"
|
"github.com/metacubex/mihomo/log"
|
||||||
)
|
)
|
||||||
@@ -21,11 +20,11 @@ func startLog() {
|
|||||||
if logData.LogLevel < log.Level() {
|
if logData.LogLevel < log.Level() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
message := &bridge.Message{
|
message := &Message{
|
||||||
Type: bridge.Log,
|
Type: LogMessage,
|
||||||
Data: logData,
|
Data: logData,
|
||||||
}
|
}
|
||||||
bridge.SendMessage(*message)
|
SendMessage(*message)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|||||||
77
core/message.go
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
bridge "core/dart-bridge"
|
||||||
|
"encoding/json"
|
||||||
|
"github.com/metacubex/mihomo/constant"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Port int64
|
||||||
|
var ServicePort int64
|
||||||
|
|
||||||
|
type MessageType string
|
||||||
|
|
||||||
|
const (
|
||||||
|
LogMessage MessageType = "log"
|
||||||
|
ProtectMessage MessageType = "protect"
|
||||||
|
DelayMessage MessageType = "delay"
|
||||||
|
ProcessMessage MessageType = "process"
|
||||||
|
RequestMessage MessageType = "request"
|
||||||
|
StartedMessage MessageType = "started"
|
||||||
|
LoadedMessage MessageType = "loaded"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Delay struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Value int32 `json:"value"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Process struct {
|
||||||
|
Id int64 `json:"id"`
|
||||||
|
Metadata *constant.Metadata `json:"metadata"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Message struct {
|
||||||
|
Type MessageType `json:"type"`
|
||||||
|
Data interface{} `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (message *Message) Json() (string, error) {
|
||||||
|
data, err := json.Marshal(message)
|
||||||
|
return string(data), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func SendMessage(message Message) {
|
||||||
|
s, err := message.Json()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if handler, ok := messageHandlers[message.Type]; ok {
|
||||||
|
handler(s)
|
||||||
|
} else {
|
||||||
|
sendToPort(s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var messageHandlers = map[MessageType]func(string) bool{
|
||||||
|
ProtectMessage: sendToServicePort,
|
||||||
|
ProcessMessage: sendToServicePort,
|
||||||
|
StartedMessage: conditionalSend,
|
||||||
|
LoadedMessage: conditionalSend,
|
||||||
|
}
|
||||||
|
|
||||||
|
func sendToPort(s string) bool {
|
||||||
|
return bridge.SendToPort(Port, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
func sendToServicePort(s string) bool {
|
||||||
|
return bridge.SendToPort(ServicePort, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
func conditionalSend(s string) bool {
|
||||||
|
isSuccess := sendToPort(s)
|
||||||
|
if !isSuccess {
|
||||||
|
return sendToServicePort(s)
|
||||||
|
}
|
||||||
|
return isSuccess
|
||||||
|
}
|
||||||
@@ -1,171 +0,0 @@
|
|||||||
//go:build android
|
|
||||||
|
|
||||||
package platform
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bufio"
|
|
||||||
"encoding/binary"
|
|
||||||
"encoding/hex"
|
|
||||||
"fmt"
|
|
||||||
"net"
|
|
||||||
"os"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
"unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
var netIndexOfLocal = -1
|
|
||||||
var netIndexOfUid = -1
|
|
||||||
|
|
||||||
var nativeEndian binary.ByteOrder
|
|
||||||
|
|
||||||
func QuerySocketUidFromProcFs(source, _ net.Addr) int {
|
|
||||||
if netIndexOfLocal < 0 || netIndexOfUid < 0 {
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
|
|
||||||
network := source.Network()
|
|
||||||
|
|
||||||
if strings.HasSuffix(network, "4") || strings.HasSuffix(network, "6") {
|
|
||||||
network = network[:len(network)-1]
|
|
||||||
}
|
|
||||||
|
|
||||||
path := "/proc/net/" + network
|
|
||||||
|
|
||||||
var sIP net.IP
|
|
||||||
var sPort int
|
|
||||||
|
|
||||||
switch s := source.(type) {
|
|
||||||
case *net.TCPAddr:
|
|
||||||
sIP = s.IP
|
|
||||||
sPort = s.Port
|
|
||||||
case *net.UDPAddr:
|
|
||||||
sIP = s.IP
|
|
||||||
sPort = s.Port
|
|
||||||
default:
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
|
|
||||||
sIP = sIP.To16()
|
|
||||||
if sIP == nil {
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
|
|
||||||
uid := doQuery(path+"6", sIP, sPort)
|
|
||||||
if uid == -1 {
|
|
||||||
sIP = sIP.To4()
|
|
||||||
if sIP == nil {
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
uid = doQuery(path, sIP, sPort)
|
|
||||||
}
|
|
||||||
|
|
||||||
return uid
|
|
||||||
}
|
|
||||||
|
|
||||||
func doQuery(path string, sIP net.IP, sPort int) int {
|
|
||||||
file, err := os.Open(path)
|
|
||||||
if err != nil {
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
|
|
||||||
defer file.Close()
|
|
||||||
|
|
||||||
reader := bufio.NewReader(file)
|
|
||||||
|
|
||||||
var bytes [2]byte
|
|
||||||
|
|
||||||
binary.BigEndian.PutUint16(bytes[:], uint16(sPort))
|
|
||||||
|
|
||||||
local := fmt.Sprintf("%s:%s", hex.EncodeToString(nativeEndianIP(sIP)), hex.EncodeToString(bytes[:]))
|
|
||||||
|
|
||||||
for {
|
|
||||||
row, _, err := reader.ReadLine()
|
|
||||||
if err != nil {
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
|
|
||||||
fields := strings.Fields(string(row))
|
|
||||||
|
|
||||||
if len(fields) <= netIndexOfLocal || len(fields) <= netIndexOfUid {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if strings.EqualFold(local, fields[netIndexOfLocal]) {
|
|
||||||
uid, err := strconv.Atoi(fields[netIndexOfUid])
|
|
||||||
if err != nil {
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
|
|
||||||
return uid
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func nativeEndianIP(ip net.IP) []byte {
|
|
||||||
result := make([]byte, len(ip))
|
|
||||||
|
|
||||||
for i := 0; i < len(ip); i += 4 {
|
|
||||||
value := binary.BigEndian.Uint32(ip[i:])
|
|
||||||
|
|
||||||
nativeEndian.PutUint32(result[i:], value)
|
|
||||||
}
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
file, err := os.Open("/proc/net/tcp")
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
defer file.Close()
|
|
||||||
|
|
||||||
reader := bufio.NewReader(file)
|
|
||||||
|
|
||||||
header, _, err := reader.ReadLine()
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
columns := strings.Fields(string(header))
|
|
||||||
|
|
||||||
var txQueue, rxQueue, tr, tmWhen bool
|
|
||||||
|
|
||||||
for idx, col := range columns {
|
|
||||||
offset := 0
|
|
||||||
|
|
||||||
if txQueue && rxQueue {
|
|
||||||
offset--
|
|
||||||
}
|
|
||||||
|
|
||||||
if tr && tmWhen {
|
|
||||||
offset--
|
|
||||||
}
|
|
||||||
|
|
||||||
switch col {
|
|
||||||
case "tx_queue":
|
|
||||||
txQueue = true
|
|
||||||
case "rx_queue":
|
|
||||||
rxQueue = true
|
|
||||||
case "tr":
|
|
||||||
tr = true
|
|
||||||
case "tm->when":
|
|
||||||
tmWhen = true
|
|
||||||
case "local_address":
|
|
||||||
netIndexOfLocal = idx + offset
|
|
||||||
case "uid":
|
|
||||||
netIndexOfUid = idx + offset
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
var x uint32 = 0x01020304
|
|
||||||
if *(*byte)(unsafe.Pointer(&x)) == 0x01 {
|
|
||||||
nativeEndian = binary.BigEndian
|
|
||||||
} else {
|
|
||||||
nativeEndian = binary.LittleEndian
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,21 +4,34 @@ package main
|
|||||||
|
|
||||||
import "C"
|
import "C"
|
||||||
import (
|
import (
|
||||||
bridge "core/dart-bridge"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/metacubex/mihomo/component/process"
|
"github.com/metacubex/mihomo/component/process"
|
||||||
"github.com/metacubex/mihomo/constant"
|
"github.com/metacubex/mihomo/constant"
|
||||||
"github.com/metacubex/mihomo/log"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
type ProcessMap struct {
|
||||||
counter int64
|
m sync.Map
|
||||||
)
|
}
|
||||||
|
|
||||||
var processMap = make(map[int64]*string)
|
func (cm *ProcessMap) Store(key int64, value string) {
|
||||||
|
cm.m.Store(key, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cm *ProcessMap) Load(key int64) (string, bool) {
|
||||||
|
value, ok := cm.m.Load(key)
|
||||||
|
if !ok || value == nil {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
return value.(string), true
|
||||||
|
}
|
||||||
|
|
||||||
|
var counter int64 = 0
|
||||||
|
|
||||||
|
var processMap ProcessMap
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
process.DefaultPackageNameResolver = func(metadata *constant.Metadata) (string, error) {
|
process.DefaultPackageNameResolver = func(metadata *constant.Metadata) (string, error) {
|
||||||
@@ -29,31 +42,24 @@ func init() {
|
|||||||
|
|
||||||
timeout := time.After(200 * time.Millisecond)
|
timeout := time.After(200 * time.Millisecond)
|
||||||
|
|
||||||
message := &bridge.Message{
|
SendMessage(Message{
|
||||||
Type: bridge.Process,
|
Type: ProcessMessage,
|
||||||
Data: Process{
|
Data: Process{
|
||||||
Id: id,
|
Id: id,
|
||||||
Metadata: *metadata,
|
Metadata: metadata,
|
||||||
},
|
},
|
||||||
}
|
})
|
||||||
|
|
||||||
bridge.SendMessage(*message)
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-timeout:
|
case <-timeout:
|
||||||
return "", errors.New("package resolver timeout")
|
return "", errors.New("package resolver timeout")
|
||||||
default:
|
default:
|
||||||
value, exists := processMap[counter]
|
value, exists := processMap.Load(id)
|
||||||
if exists {
|
if exists {
|
||||||
if value != nil {
|
return value, nil
|
||||||
log.Infoln("[PKG] %s --> %s by [%s]", metadata.SourceAddress(), metadata.RemoteAddress(), *value)
|
|
||||||
return *value, nil
|
|
||||||
} else {
|
|
||||||
return "", process.ErrInvalidNetwork
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
time.Sleep(10 * time.Millisecond)
|
time.Sleep(20 * time.Millisecond)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,12 +67,15 @@ func init() {
|
|||||||
|
|
||||||
//export setProcessMap
|
//export setProcessMap
|
||||||
func setProcessMap(s *C.char) {
|
func setProcessMap(s *C.char) {
|
||||||
|
if s == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
paramsString := C.GoString(s)
|
||||||
go func() {
|
go func() {
|
||||||
paramsString := C.GoString(s)
|
|
||||||
var processMapItem = &ProcessMapItem{}
|
var processMapItem = &ProcessMapItem{}
|
||||||
err := json.Unmarshal([]byte(paramsString), processMapItem)
|
err := json.Unmarshal([]byte(paramsString), processMapItem)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
processMap[processMapItem.Id] = processMapItem.Value
|
processMap.Store(processMapItem.Id, processMapItem.Value)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|||||||
46
core/state.go
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import "C"
|
||||||
|
import (
|
||||||
|
"core/state"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
//export getCurrentProfileName
|
||||||
|
func getCurrentProfileName() *C.char {
|
||||||
|
if state.CurrentState == nil {
|
||||||
|
return C.CString("")
|
||||||
|
}
|
||||||
|
return C.CString(state.CurrentState.CurrentProfileName)
|
||||||
|
}
|
||||||
|
|
||||||
|
//export getAndroidVpnOptions
|
||||||
|
func getAndroidVpnOptions() *C.char {
|
||||||
|
options := state.AndroidVpnOptions{
|
||||||
|
Enable: state.CurrentState.Enable,
|
||||||
|
Port: state.CurrentRawConfig.MixedPort,
|
||||||
|
Ipv4Address: state.DefaultIpv4Address,
|
||||||
|
Ipv6Address: state.GetIpv6Address(),
|
||||||
|
AccessControl: state.CurrentState.AccessControl,
|
||||||
|
SystemProxy: state.CurrentState.SystemProxy,
|
||||||
|
AllowBypass: state.CurrentState.AllowBypass,
|
||||||
|
BypassDomain: state.CurrentState.BypassDomain,
|
||||||
|
DnsServerAddress: state.GetDnsServerAddress(),
|
||||||
|
}
|
||||||
|
data, err := json.Marshal(options)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error:", err)
|
||||||
|
return C.CString("")
|
||||||
|
}
|
||||||
|
return C.CString(string(data))
|
||||||
|
}
|
||||||
|
|
||||||
|
//export setState
|
||||||
|
func setState(s *C.char) {
|
||||||
|
paramsString := C.GoString(s)
|
||||||
|
err := json.Unmarshal([]byte(paramsString), state.CurrentState)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
59
core/state/state.go
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
package state
|
||||||
|
|
||||||
|
import "github.com/metacubex/mihomo/config"
|
||||||
|
|
||||||
|
var DefaultIpv4Address = "172.19.0.1/30"
|
||||||
|
var DefaultDnsAddress = "172.19.0.2"
|
||||||
|
var DefaultIpv6Address = "fdfe:dcba:9876::1/126"
|
||||||
|
|
||||||
|
var CurrentRawConfig = config.DefaultRawConfig()
|
||||||
|
|
||||||
|
type AndroidVpnOptions struct {
|
||||||
|
Enable bool `json:"enable"`
|
||||||
|
Port int `json:"port"`
|
||||||
|
AccessControl *AccessControl `json:"accessControl"`
|
||||||
|
AllowBypass bool `json:"allowBypass"`
|
||||||
|
SystemProxy bool `json:"systemProxy"`
|
||||||
|
BypassDomain []string `json:"bypassDomain"`
|
||||||
|
Ipv4Address string `json:"ipv4Address"`
|
||||||
|
Ipv6Address string `json:"ipv6Address"`
|
||||||
|
DnsServerAddress string `json:"dnsServerAddress"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AccessControl struct {
|
||||||
|
Mode string `json:"mode"`
|
||||||
|
AcceptList []string `json:"acceptList"`
|
||||||
|
RejectList []string `json:"rejectList"`
|
||||||
|
IsFilterSystemApp bool `json:"isFilterSystemApp"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AndroidVpnRawOptions struct {
|
||||||
|
Enable bool `json:"enable"`
|
||||||
|
AccessControl *AccessControl `json:"accessControl"`
|
||||||
|
AllowBypass bool `json:"allowBypass"`
|
||||||
|
SystemProxy bool `json:"systemProxy"`
|
||||||
|
Ipv6 bool `json:"ipv6"`
|
||||||
|
BypassDomain []string `json:"bypassDomain"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type State struct {
|
||||||
|
AndroidVpnRawOptions
|
||||||
|
CurrentProfileName string `json:"currentProfileName"`
|
||||||
|
OnlyProxy bool `json:"onlyProxy"`
|
||||||
|
}
|
||||||
|
|
||||||
|
var CurrentState = &State{}
|
||||||
|
|
||||||
|
func GetIpv6Address() string {
|
||||||
|
if CurrentState.Ipv6 {
|
||||||
|
return DefaultIpv6Address
|
||||||
|
} else {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetDnsServerAddress() string {
|
||||||
|
//prefix, _ := netip.ParsePrefix(DefaultIpv4Address)
|
||||||
|
//return prefix.Addr().String()
|
||||||
|
return DefaultDnsAddress
|
||||||
|
}
|
||||||
146
core/tun.go
@@ -7,52 +7,72 @@ import (
|
|||||||
"core/platform"
|
"core/platform"
|
||||||
t "core/tun"
|
t "core/tun"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/metacubex/mihomo/component/dialer"
|
"github.com/metacubex/mihomo/listener/sing_tun"
|
||||||
"github.com/metacubex/mihomo/log"
|
|
||||||
"golang.org/x/sync/semaphore"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/metacubex/mihomo/component/dialer"
|
||||||
|
"github.com/metacubex/mihomo/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var tunLock sync.Mutex
|
var tunLock sync.Mutex
|
||||||
var tun *t.Tun
|
|
||||||
var runTime *time.Time
|
var runTime *time.Time
|
||||||
|
|
||||||
|
type FdMap struct {
|
||||||
|
m sync.Map
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cm *FdMap) Store(key int64) {
|
||||||
|
cm.m.Store(key, struct{}{})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cm *FdMap) Load(key int64) bool {
|
||||||
|
_, ok := cm.m.Load(key)
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
tunListener *sing_tun.Listener
|
||||||
|
fdMap FdMap
|
||||||
|
fdCounter int64 = 0
|
||||||
|
)
|
||||||
|
|
||||||
//export startTUN
|
//export startTUN
|
||||||
func startTUN(fd C.int) {
|
func startTUN(fd C.int, port C.longlong) {
|
||||||
tunLock.Lock()
|
i := int64(port)
|
||||||
|
ServicePort = i
|
||||||
now := time.Now()
|
if fd == 0 {
|
||||||
runTime = &now
|
tunLock.Lock()
|
||||||
|
defer tunLock.Unlock()
|
||||||
go func() {
|
now := time.Now()
|
||||||
|
runTime = &now
|
||||||
|
SendMessage(Message{
|
||||||
|
Type: StartedMessage,
|
||||||
|
Data: strconv.FormatInt(runTime.UnixMilli(), 10),
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
initSocketHook()
|
||||||
|
go func() {
|
||||||
|
tunLock.Lock()
|
||||||
defer tunLock.Unlock()
|
defer tunLock.Unlock()
|
||||||
|
|
||||||
if tun != nil {
|
|
||||||
tun.Close()
|
|
||||||
tun = nil
|
|
||||||
}
|
|
||||||
f := int(fd)
|
f := int(fd)
|
||||||
gateway := "172.16.0.1/30"
|
tunListener, _ = t.Start(f)
|
||||||
portal := "172.16.0.2"
|
if tunListener != nil {
|
||||||
dns := "0.0.0.0"
|
log.Infoln("TUN address: %v", tunListener.Address())
|
||||||
|
|
||||||
tempTun := &t.Tun{Closed: false, Limit: semaphore.NewWeighted(4)}
|
|
||||||
|
|
||||||
closer, err := t.Start(f, gateway, portal, dns)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
log.Errorln("startTUN error: %v", err)
|
|
||||||
tempTun.Close()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tempTun.Closer = closer
|
now := time.Now()
|
||||||
|
|
||||||
tun = tempTun
|
runTime = &now
|
||||||
|
|
||||||
applyConfig(true)
|
SendMessage(Message{
|
||||||
|
Type: StartedMessage,
|
||||||
|
Data: strconv.FormatInt(runTime.UnixMilli(), 10),
|
||||||
|
})
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,30 +86,72 @@ func getRunTime() *C.char {
|
|||||||
|
|
||||||
//export stopTun
|
//export stopTun
|
||||||
func stopTun() {
|
func stopTun() {
|
||||||
tunLock.Lock()
|
removeSocketHook()
|
||||||
|
|
||||||
runTime = nil
|
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
tunLock.Lock()
|
||||||
defer tunLock.Unlock()
|
defer tunLock.Unlock()
|
||||||
|
|
||||||
if tun != nil {
|
runTime = nil
|
||||||
tun.Close()
|
|
||||||
tun = nil
|
if tunListener != nil {
|
||||||
|
_ = tunListener.Close()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
var errBlocked = errors.New("blocked")
|
||||||
|
|
||||||
|
//export setFdMap
|
||||||
|
func setFdMap(fd C.long) {
|
||||||
|
fdInt := int64(fd)
|
||||||
|
go func() {
|
||||||
|
fdMap.Store(fdInt)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
type Fd struct {
|
||||||
|
Id int64 `json:"id"`
|
||||||
|
Value int64 `json:"value"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func markSocket(fd Fd) {
|
||||||
|
SendMessage(Message{
|
||||||
|
Type: ProtectMessage,
|
||||||
|
Data: fd,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func initSocketHook() {
|
||||||
dialer.DefaultSocketHook = func(network, address string, conn syscall.RawConn) error {
|
dialer.DefaultSocketHook = func(network, address string, conn syscall.RawConn) error {
|
||||||
if platform.ShouldBlockConnection() {
|
if platform.ShouldBlockConnection() {
|
||||||
return errors.New("blocked")
|
return errBlocked
|
||||||
}
|
}
|
||||||
return conn.Control(func(fd uintptr) {
|
return conn.Control(func(fd uintptr) {
|
||||||
if tun != nil {
|
fdInt := int64(fd)
|
||||||
tun.MarkSocket(int(fd))
|
timeout := time.After(100 * time.Millisecond)
|
||||||
time.Sleep(time.Millisecond * 100)
|
id := atomic.AddInt64(&fdCounter, 1)
|
||||||
|
|
||||||
|
markSocket(Fd{
|
||||||
|
Id: id,
|
||||||
|
Value: fdInt,
|
||||||
|
})
|
||||||
|
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-timeout:
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
exists := fdMap.Load(id)
|
||||||
|
if exists {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
time.Sleep(10 * time.Millisecond)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func removeSocketHook() {
|
||||||
|
dialer.DefaultSocketHook = nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
//go:build android
|
|
||||||
|
|
||||||
package tun
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/metacubex/mihomo/dns"
|
|
||||||
D "github.com/miekg/dns"
|
|
||||||
"net"
|
|
||||||
)
|
|
||||||
|
|
||||||
func shouldHijackDns(dns net.IP, target net.IP, targetPort int) bool {
|
|
||||||
if targetPort != 53 {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return net.IPv4zero.Equal(dns) || target.Equal(dns)
|
|
||||||
}
|
|
||||||
|
|
||||||
func relayDns(payload []byte) ([]byte, error) {
|
|
||||||
msg := &D.Msg{}
|
|
||||||
if err := msg.Unpack(payload); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
r, err := dns.ServeDNSWithDefaultServer(msg)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
r.SetRcode(msg, r.Rcode)
|
|
||||||
|
|
||||||
return r.Pack()
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
//go:build android
|
|
||||||
|
|
||||||
package tun
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/metacubex/mihomo/constant"
|
|
||||||
"net"
|
|
||||||
)
|
|
||||||
|
|
||||||
func createMetadata(lAddr, rAddr *net.TCPAddr) *constant.Metadata {
|
|
||||||
return &constant.Metadata{
|
|
||||||
NetWork: constant.TCP,
|
|
||||||
Type: constant.SOCKS5,
|
|
||||||
SrcIP: lAddr.AddrPort().Addr(),
|
|
||||||
DstIP: rAddr.AddrPort().Addr(),
|
|
||||||
SrcPort: uint16(lAddr.Port),
|
|
||||||
DstPort: uint16(rAddr.Port),
|
|
||||||
Host: "",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
230
core/tun/tun.go
@@ -4,201 +4,65 @@ package tun
|
|||||||
|
|
||||||
import "C"
|
import "C"
|
||||||
import (
|
import (
|
||||||
"context"
|
"core/state"
|
||||||
bridge "core/dart-bridge"
|
LC "github.com/metacubex/mihomo/listener/config"
|
||||||
"encoding/binary"
|
"github.com/metacubex/mihomo/listener/sing_tun"
|
||||||
"github.com/Kr328/tun2socket"
|
|
||||||
"github.com/Kr328/tun2socket/nat"
|
|
||||||
"github.com/metacubex/mihomo/adapter/inbound"
|
|
||||||
"github.com/metacubex/mihomo/common/pool"
|
|
||||||
"github.com/metacubex/mihomo/constant"
|
|
||||||
"github.com/metacubex/mihomo/log"
|
"github.com/metacubex/mihomo/log"
|
||||||
"github.com/metacubex/mihomo/transport/socks5"
|
|
||||||
"github.com/metacubex/mihomo/tunnel"
|
"github.com/metacubex/mihomo/tunnel"
|
||||||
"golang.org/x/sync/semaphore"
|
|
||||||
"io"
|
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"net/netip"
|
||||||
"strconv"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Tun struct {
|
type Props struct {
|
||||||
Closer io.Closer
|
Fd int `json:"fd"`
|
||||||
|
Gateway string `json:"gateway"`
|
||||||
Closed bool
|
Gateway6 string `json:"gateway6"`
|
||||||
Limit *semaphore.Weighted
|
Portal string `json:"portal"`
|
||||||
|
Portal6 string `json:"portal6"`
|
||||||
|
Dns string `json:"dns"`
|
||||||
|
Dns6 string `json:"dns6"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Tun) Close() {
|
func Start(fd int) (*sing_tun.Listener, error) {
|
||||||
_ = t.Limit.Acquire(context.TODO(), 4)
|
var prefix4 []netip.Prefix
|
||||||
defer t.Limit.Release(4)
|
tempPrefix4, err := netip.ParsePrefix(state.DefaultIpv4Address)
|
||||||
|
|
||||||
t.Closed = true
|
|
||||||
|
|
||||||
if t.Closer != nil {
|
|
||||||
_ = t.Closer.Close()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var _, ipv4LoopBack, _ = net.ParseCIDR("127.0.0.0/8")
|
|
||||||
|
|
||||||
func Start(fd int, gateway, portal, dns string) (io.Closer, error) {
|
|
||||||
device := os.NewFile(uintptr(fd), "/dev/tun")
|
|
||||||
ip, network, err := net.ParseCIDR(gateway)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err.Error())
|
log.Errorln("startTUN error:", err)
|
||||||
} else {
|
return nil, err
|
||||||
network.IP = ip
|
|
||||||
}
|
}
|
||||||
stack, err := tun2socket.StartTun2Socket(device, network, net.ParseIP(portal))
|
prefix4 = append(prefix4, tempPrefix4)
|
||||||
|
var prefix6 []netip.Prefix
|
||||||
|
if state.CurrentState.Ipv6 {
|
||||||
|
tempPrefix6, err := netip.ParsePrefix(state.DefaultIpv6Address)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorln("startTUN error:", err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
prefix6 = append(prefix6, tempPrefix6)
|
||||||
|
}
|
||||||
|
|
||||||
|
var dnsHijack []string
|
||||||
|
dnsHijack = append(dnsHijack, net.JoinHostPort(state.GetDnsServerAddress(), "53"))
|
||||||
|
|
||||||
|
options := LC.Tun{
|
||||||
|
Enable: true,
|
||||||
|
Device: state.CurrentRawConfig.Tun.Device,
|
||||||
|
Stack: state.CurrentRawConfig.Tun.Stack,
|
||||||
|
DNSHijack: dnsHijack,
|
||||||
|
AutoRoute: false,
|
||||||
|
AutoDetectInterface: false,
|
||||||
|
Inet4Address: prefix4,
|
||||||
|
Inet6Address: prefix6,
|
||||||
|
MTU: 9000,
|
||||||
|
FileDescriptor: fd,
|
||||||
|
}
|
||||||
|
|
||||||
|
listener, err := sing_tun.New(options, tunnel.Tunnel)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_ = device.Close()
|
log.Errorln("startTUN error:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
dnsAddr := net.ParseIP(dns)
|
return listener, nil
|
||||||
|
|
||||||
tcp := func() {
|
|
||||||
defer func(tcp *nat.TCP) {
|
|
||||||
_ = tcp.Close()
|
|
||||||
}(stack.TCP())
|
|
||||||
defer log.Debugln("TCP: closed")
|
|
||||||
|
|
||||||
for stack.TCP().SetDeadline(time.Time{}) == nil {
|
|
||||||
conn, err := stack.TCP().Accept()
|
|
||||||
if err != nil {
|
|
||||||
log.Errorln("Accept connection: %v", err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
lAddr := conn.LocalAddr().(*net.TCPAddr)
|
|
||||||
rAddr := conn.RemoteAddr().(*net.TCPAddr)
|
|
||||||
|
|
||||||
if ipv4LoopBack.Contains(rAddr.IP) {
|
|
||||||
_ = conn.Close()
|
|
||||||
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if shouldHijackDns(dnsAddr, rAddr.IP, rAddr.Port) {
|
|
||||||
go func() {
|
|
||||||
defer func(conn net.Conn) {
|
|
||||||
_ = conn.Close()
|
|
||||||
}(conn)
|
|
||||||
|
|
||||||
buf := pool.Get(pool.UDPBufferSize)
|
|
||||||
defer func(buf []byte) {
|
|
||||||
_ = pool.Put(buf)
|
|
||||||
}(buf)
|
|
||||||
|
|
||||||
for {
|
|
||||||
_ = conn.SetReadDeadline(time.Now().Add(constant.DefaultTCPTimeout))
|
|
||||||
|
|
||||||
length := uint16(0)
|
|
||||||
if err := binary.Read(conn, binary.BigEndian, &length); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if int(length) > len(buf) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
n, err := conn.Read(buf[:length])
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := relayDns(buf[:n])
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
_, _ = conn.Write(msg)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
go tunnel.Tunnel.HandleTCPConn(conn, createMetadata(lAddr, rAddr))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
udp := func() {
|
|
||||||
defer func(udp *nat.UDP) {
|
|
||||||
_ = udp.Close()
|
|
||||||
}(stack.UDP())
|
|
||||||
defer log.Debugln("UDP: closed")
|
|
||||||
|
|
||||||
for {
|
|
||||||
buf := pool.Get(pool.UDPBufferSize)
|
|
||||||
|
|
||||||
n, lRAddr, rRAddr, err := stack.UDP().ReadFrom(buf)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
raw := buf[:n]
|
|
||||||
lAddr := lRAddr.(*net.UDPAddr)
|
|
||||||
rAddr := rRAddr.(*net.UDPAddr)
|
|
||||||
|
|
||||||
if ipv4LoopBack.Contains(rAddr.IP) {
|
|
||||||
_ = pool.Put(buf)
|
|
||||||
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if shouldHijackDns(dnsAddr, rAddr.IP, rAddr.Port) {
|
|
||||||
go func() {
|
|
||||||
defer func(buf []byte) {
|
|
||||||
_ = pool.Put(buf)
|
|
||||||
}(buf)
|
|
||||||
|
|
||||||
msg, err := relayDns(raw)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
_, _ = stack.UDP().WriteTo(msg, rAddr, lAddr)
|
|
||||||
}()
|
|
||||||
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
pkt := &packet{
|
|
||||||
local: lAddr,
|
|
||||||
data: raw,
|
|
||||||
writeBack: func(b []byte, addr net.Addr) (int, error) {
|
|
||||||
return stack.UDP().WriteTo(b, addr, lAddr)
|
|
||||||
},
|
|
||||||
drop: func() {
|
|
||||||
_ = pool.Put(buf)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
tunnel.Tunnel.HandleUDPPacket(inbound.NewPacket(socks5.ParseAddrToSocksAddr(rAddr), pkt, constant.SOCKS5))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
go tcp()
|
|
||||||
go udp()
|
|
||||||
|
|
||||||
return stack, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *Tun) MarkSocket(fd int) {
|
|
||||||
_ = t.Limit.Acquire(context.Background(), 1)
|
|
||||||
defer t.Limit.Release(1)
|
|
||||||
|
|
||||||
if t.Closed {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
message := &bridge.Message{
|
|
||||||
Type: bridge.Tun,
|
|
||||||
Data: strconv.Itoa(fd),
|
|
||||||
}
|
|
||||||
|
|
||||||
bridge.SendMessage(*message)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
//go:build android
|
|
||||||
|
|
||||||
package tun
|
|
||||||
|
|
||||||
import "net"
|
|
||||||
|
|
||||||
type packet struct {
|
|
||||||
local *net.UDPAddr
|
|
||||||
data []byte
|
|
||||||
writeBack func(b []byte, addr net.Addr) (int, error)
|
|
||||||
drop func()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (pkt *packet) Data() []byte {
|
|
||||||
return pkt.data
|
|
||||||
}
|
|
||||||
|
|
||||||
func (pkt *packet) WriteBack(b []byte, addr net.Addr) (n int, err error) {
|
|
||||||
return pkt.writeBack(b, addr)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (pkt *packet) Drop() {
|
|
||||||
pkt.drop()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (pkt *packet) LocalAddr() net.Addr {
|
|
||||||
return pkt.local
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:dynamic_color/dynamic_color.dart';
|
import 'package:dynamic_color/dynamic_color.dart';
|
||||||
import 'package:fl_clash/l10n/l10n.dart';
|
import 'package:fl_clash/l10n/l10n.dart';
|
||||||
import 'package:fl_clash/common/common.dart';
|
import 'package:fl_clash/common/common.dart';
|
||||||
|
import 'package:fl_clash/manager/hotkey_manager.dart';
|
||||||
|
import 'package:fl_clash/manager/manager.dart';
|
||||||
import 'package:fl_clash/state.dart';
|
import 'package:fl_clash/state.dart';
|
||||||
import 'package:fl_clash/widgets/widgets.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
@@ -27,11 +27,13 @@ runAppWithPreferences(
|
|||||||
ChangeNotifierProvider<Config>(
|
ChangeNotifierProvider<Config>(
|
||||||
create: (_) => config,
|
create: (_) => config,
|
||||||
),
|
),
|
||||||
|
ChangeNotifierProvider<AppFlowingState>(
|
||||||
|
create: (_) => AppFlowingState(),
|
||||||
|
),
|
||||||
ChangeNotifierProxyProvider2<Config, ClashConfig, AppState>(
|
ChangeNotifierProxyProvider2<Config, ClashConfig, AppState>(
|
||||||
create: (_) => appState,
|
create: (_) => appState,
|
||||||
update: (_, config, clashConfig, appState) {
|
update: (_, config, clashConfig, appState) {
|
||||||
appState?.mode = clashConfig.mode;
|
appState?.mode = clashConfig.mode;
|
||||||
appState?.isCompatible = config.isCompatible;
|
|
||||||
appState?.selectedMap = config.currentSelectedMap;
|
appState?.selectedMap = config.currentSelectedMap;
|
||||||
return appState!;
|
return appState!;
|
||||||
},
|
},
|
||||||
@@ -52,6 +54,7 @@ class Application extends StatefulWidget {
|
|||||||
|
|
||||||
class ApplicationState extends State<Application> {
|
class ApplicationState extends State<Application> {
|
||||||
late SystemColorSchemes systemColorSchemes;
|
late SystemColorSchemes systemColorSchemes;
|
||||||
|
Timer? timer;
|
||||||
|
|
||||||
final _pageTransitionsTheme = const PageTransitionsTheme(
|
final _pageTransitionsTheme = const PageTransitionsTheme(
|
||||||
builders: <TargetPlatform, PageTransitionsBuilder>{
|
builders: <TargetPlatform, PageTransitionsBuilder>{
|
||||||
@@ -80,7 +83,9 @@ class ApplicationState extends State<Application> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
_initTimer();
|
||||||
globalState.appController = AppController(context);
|
globalState.appController = AppController(context);
|
||||||
|
globalState.measure = Measure.of(context);
|
||||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||||
final currentContext = globalState.navigatorKey.currentContext;
|
final currentContext = globalState.navigatorKey.currentContext;
|
||||||
if (currentContext != null) {
|
if (currentContext != null) {
|
||||||
@@ -88,25 +93,55 @@ class ApplicationState extends State<Application> {
|
|||||||
}
|
}
|
||||||
await globalState.appController.init();
|
await globalState.appController.init();
|
||||||
globalState.appController.initLink();
|
globalState.appController.initLink();
|
||||||
_updateGroups();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_initTimer() {
|
||||||
|
_cancelTimer();
|
||||||
|
timer = Timer.periodic(const Duration(milliseconds: 20000), (_) {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
globalState.appController.updateGroupDebounce();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_cancelTimer() {
|
||||||
|
if (timer != null) {
|
||||||
|
timer?.cancel();
|
||||||
|
timer = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_buildApp(Widget app) {
|
_buildApp(Widget app) {
|
||||||
if (system.isDesktop) {
|
if (system.isDesktop) {
|
||||||
return WindowContainer(
|
return WindowManager(
|
||||||
child: TrayContainer(
|
child: TrayManager(
|
||||||
child: app,
|
child: HotKeyManager(
|
||||||
|
child: ProxyManager(
|
||||||
|
child: app,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return AndroidContainer(
|
return AndroidManager(
|
||||||
child: TileContainer(
|
child: TileManager(
|
||||||
child: app,
|
child: app,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_buildPage(Widget page) {
|
||||||
|
if (system.isDesktop) {
|
||||||
|
return WindowHeaderContainer(
|
||||||
|
child: page,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return VpnManager(
|
||||||
|
child: page,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
_updateSystemColorSchemes(
|
_updateSystemColorSchemes(
|
||||||
ColorScheme? lightDynamic,
|
ColorScheme? lightDynamic,
|
||||||
ColorScheme? darkDynamic,
|
ColorScheme? darkDynamic,
|
||||||
@@ -115,36 +150,22 @@ class ApplicationState extends State<Application> {
|
|||||||
lightColorScheme: lightDynamic,
|
lightColorScheme: lightDynamic,
|
||||||
darkColorScheme: darkDynamic,
|
darkColorScheme: darkDynamic,
|
||||||
);
|
);
|
||||||
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
globalState.appController.updateSystemColorSchemes(systemColorSchemes);
|
globalState.appController.updateSystemColorSchemes(systemColorSchemes);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateGroups() {
|
|
||||||
if (globalState.groupsUpdateTimer != null) {
|
|
||||||
globalState.groupsUpdateTimer?.cancel();
|
|
||||||
globalState.groupsUpdateTimer = null;
|
|
||||||
}
|
|
||||||
globalState.groupsUpdateTimer ??= Timer.periodic(
|
|
||||||
httpTimeoutDuration,
|
|
||||||
(timer) async {
|
|
||||||
await globalState.appController.updateGroups();
|
|
||||||
globalState.appController.appState.sortNum++;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(context) {
|
Widget build(context) {
|
||||||
return AppStateContainer(
|
return _buildApp(
|
||||||
child: ClashMessageContainer(
|
AppStateManager(
|
||||||
child: _buildApp(
|
child: ClashManager(
|
||||||
Selector2<AppState, Config, ApplicationSelectorState>(
|
child: Selector2<AppState, Config, ApplicationSelectorState>(
|
||||||
selector: (_, appState, config) => ApplicationSelectorState(
|
selector: (_, appState, config) => ApplicationSelectorState(
|
||||||
locale: config.locale,
|
locale: config.appSetting.locale,
|
||||||
themeMode: config.themeMode,
|
themeMode: config.themeMode,
|
||||||
primaryColor: config.primaryColor,
|
primaryColor: config.primaryColor,
|
||||||
|
prueBlack: config.prueBlack,
|
||||||
),
|
),
|
||||||
builder: (_, state, child) {
|
builder: (_, state, child) {
|
||||||
return DynamicColorBuilder(
|
return DynamicColorBuilder(
|
||||||
@@ -158,6 +179,19 @@ class ApplicationState extends State<Application> {
|
|||||||
GlobalCupertinoLocalizations.delegate,
|
GlobalCupertinoLocalizations.delegate,
|
||||||
GlobalWidgetsLocalizations.delegate
|
GlobalWidgetsLocalizations.delegate
|
||||||
],
|
],
|
||||||
|
builder: (_, child) {
|
||||||
|
return LayoutBuilder(
|
||||||
|
builder: (_, container) {
|
||||||
|
final appController = globalState.appController;
|
||||||
|
final maxWidth = container.maxWidth;
|
||||||
|
if (appController.appState.viewWidth != maxWidth) {
|
||||||
|
globalState.appController.updateViewWidth(maxWidth);
|
||||||
|
}
|
||||||
|
return _buildPage(child!);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
scrollBehavior: BaseScrollBehavior(),
|
||||||
title: appName,
|
title: appName,
|
||||||
locale: other.getLocaleForString(state.locale),
|
locale: other.getLocaleForString(state.locale),
|
||||||
supportedLocales:
|
supportedLocales:
|
||||||
@@ -165,7 +199,6 @@ class ApplicationState extends State<Application> {
|
|||||||
themeMode: state.themeMode,
|
themeMode: state.themeMode,
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
fontFamily: '',
|
|
||||||
pageTransitionsTheme: _pageTransitionsTheme,
|
pageTransitionsTheme: _pageTransitionsTheme,
|
||||||
colorScheme: _getAppColorScheme(
|
colorScheme: _getAppColorScheme(
|
||||||
brightness: Brightness.light,
|
brightness: Brightness.light,
|
||||||
@@ -175,13 +208,12 @@ class ApplicationState extends State<Application> {
|
|||||||
),
|
),
|
||||||
darkTheme: ThemeData(
|
darkTheme: ThemeData(
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
fontFamily: '',
|
|
||||||
pageTransitionsTheme: _pageTransitionsTheme,
|
pageTransitionsTheme: _pageTransitionsTheme,
|
||||||
colorScheme: _getAppColorScheme(
|
colorScheme: _getAppColorScheme(
|
||||||
brightness: Brightness.dark,
|
brightness: Brightness.dark,
|
||||||
systemColorSchemes: systemColorSchemes,
|
systemColorSchemes: systemColorSchemes,
|
||||||
primaryColor: state.primaryColor,
|
primaryColor: state.primaryColor,
|
||||||
),
|
).toPrueBlack(state.prueBlack),
|
||||||
),
|
),
|
||||||
home: child,
|
home: child,
|
||||||
);
|
);
|
||||||
@@ -200,5 +232,6 @@ class ApplicationState extends State<Application> {
|
|||||||
linkManager.destroy();
|
linkManager.destroy();
|
||||||
await globalState.appController.savePreferences();
|
await globalState.appController.savePreferences();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
|
_cancelTimer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ class ClashCore {
|
|||||||
clashFFI = ClashFFI(lib);
|
clashFFI = ClashFFI(lib);
|
||||||
clashFFI.initNativeApiBridge(
|
clashFFI.initNativeApiBridge(
|
||||||
NativeApi.initializeApiDLData,
|
NativeApi.initializeApiDLData,
|
||||||
receiver.sendPort.nativePort,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,10 +44,10 @@ class ClashCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool init(String homeDir) {
|
bool init(String homeDir) {
|
||||||
return clashFFI.initClash(
|
final homeDirChar = homeDir.toNativeUtf8().cast<Char>();
|
||||||
homeDir.toNativeUtf8().cast(),
|
final isInit = clashFFI.initClash(homeDirChar) == 1;
|
||||||
) ==
|
malloc.free(homeDirChar);
|
||||||
1;
|
return isInit;
|
||||||
}
|
}
|
||||||
|
|
||||||
shutdown() {
|
shutdown() {
|
||||||
@@ -67,10 +66,12 @@ class ClashCore {
|
|||||||
receiver.close();
|
receiver.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
final dataChar = data.toNativeUtf8().cast<Char>();
|
||||||
clashFFI.validateConfig(
|
clashFFI.validateConfig(
|
||||||
data.toNativeUtf8().cast(),
|
dataChar,
|
||||||
receiver.sendPort.nativePort,
|
receiver.sendPort.nativePort,
|
||||||
);
|
);
|
||||||
|
malloc.free(dataChar);
|
||||||
return completer.future;
|
return completer.future;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,23 +85,34 @@ class ClashCore {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
final params = json.encode(updateConfigParams);
|
final params = json.encode(updateConfigParams);
|
||||||
|
final paramsChar = params.toNativeUtf8().cast<Char>();
|
||||||
clashFFI.updateConfig(
|
clashFFI.updateConfig(
|
||||||
params.toNativeUtf8().cast(),
|
paramsChar,
|
||||||
receiver.sendPort.nativePort,
|
receiver.sendPort.nativePort,
|
||||||
);
|
);
|
||||||
|
malloc.free(paramsChar);
|
||||||
return completer.future;
|
return completer.future;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initMessage() {
|
||||||
|
clashFFI.initMessage(
|
||||||
|
receiver.sendPort.nativePort,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Future<List<Group>> getProxiesGroups() {
|
Future<List<Group>> getProxiesGroups() {
|
||||||
final proxiesRaw = clashFFI.getProxies();
|
final proxiesRaw = clashFFI.getProxies();
|
||||||
final proxiesRawString = proxiesRaw.cast<Utf8>().toDartString();
|
final proxiesRawString = proxiesRaw.cast<Utf8>().toDartString();
|
||||||
|
clashFFI.freeCString(proxiesRaw);
|
||||||
return Isolate.run<List<Group>>(() {
|
return Isolate.run<List<Group>>(() {
|
||||||
final proxies = json.decode(proxiesRawString);
|
if (proxiesRawString.isEmpty) return [];
|
||||||
|
final proxies = (json.decode(proxiesRawString) ?? {}) as Map;
|
||||||
|
if (proxies.isEmpty) return [];
|
||||||
final groupNames = [
|
final groupNames = [
|
||||||
UsedProxy.GLOBAL.name,
|
UsedProxy.GLOBAL.name,
|
||||||
...(proxies[UsedProxy.GLOBAL.name]["all"] as List).where((e) {
|
...(proxies[UsedProxy.GLOBAL.name]["all"] as List).where((e) {
|
||||||
final proxy = proxies[e] ?? {};
|
final proxy = proxies[e] ?? {};
|
||||||
return GroupTypeExtension.valueList.contains(proxy['type']) && proxy['hidden'] != true;
|
return GroupTypeExtension.valueList.contains(proxy['type']);
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
final groupsRaw = groupNames.map((groupName) {
|
final groupsRaw = groupNames.map((groupName) {
|
||||||
@@ -109,10 +121,15 @@ class ClashCore {
|
|||||||
.map(
|
.map(
|
||||||
(name) => proxies[name],
|
(name) => proxies[name],
|
||||||
)
|
)
|
||||||
|
.where((proxy) => proxy != null)
|
||||||
.toList();
|
.toList();
|
||||||
return group;
|
return group;
|
||||||
}).toList();
|
}).toList();
|
||||||
return groupsRaw.map((e) => Group.fromJson(e)).toList();
|
return groupsRaw
|
||||||
|
.map(
|
||||||
|
(e) => Group.fromJson(e),
|
||||||
|
)
|
||||||
|
.toList();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,6 +137,7 @@ class ClashCore {
|
|||||||
final externalProvidersRaw = clashFFI.getExternalProviders();
|
final externalProvidersRaw = clashFFI.getExternalProviders();
|
||||||
final externalProvidersRawString =
|
final externalProvidersRawString =
|
||||||
externalProvidersRaw.cast<Utf8>().toDartString();
|
externalProvidersRaw.cast<Utf8>().toDartString();
|
||||||
|
clashFFI.freeCString(externalProvidersRaw);
|
||||||
return Isolate.run<List<ExternalProvider>>(() {
|
return Isolate.run<List<ExternalProvider>>(() {
|
||||||
final externalProviders =
|
final externalProviders =
|
||||||
(json.decode(externalProvidersRawString) as List<dynamic>)
|
(json.decode(externalProvidersRawString) as List<dynamic>)
|
||||||
@@ -131,9 +149,22 @@ class ClashCore {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> updateExternalProvider({
|
ExternalProvider? getExternalProvider(String externalProviderName) {
|
||||||
required String providerName,
|
final externalProviderNameChar =
|
||||||
required String providerType,
|
externalProviderName.toNativeUtf8().cast<Char>();
|
||||||
|
final externalProviderRaw =
|
||||||
|
clashFFI.getExternalProvider(externalProviderNameChar);
|
||||||
|
malloc.free(externalProviderNameChar);
|
||||||
|
final externalProviderRawString =
|
||||||
|
externalProviderRaw.cast<Utf8>().toDartString();
|
||||||
|
clashFFI.freeCString(externalProviderRaw);
|
||||||
|
if (externalProviderRawString.isEmpty) return null;
|
||||||
|
return ExternalProvider.fromJson(json.decode(externalProviderRawString));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String> updateGeoData({
|
||||||
|
required String geoType,
|
||||||
|
required String geoName,
|
||||||
}) {
|
}) {
|
||||||
final completer = Completer<String>();
|
final completer = Completer<String>();
|
||||||
final receiver = ReceivePort();
|
final receiver = ReceivePort();
|
||||||
@@ -143,17 +174,75 @@ class ClashCore {
|
|||||||
receiver.close();
|
receiver.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
clashFFI.updateExternalProvider(
|
final geoTypeChar = geoType.toNativeUtf8().cast<Char>();
|
||||||
providerName.toNativeUtf8().cast(),
|
final geoNameChar = geoName.toNativeUtf8().cast<Char>();
|
||||||
providerType.toNativeUtf8().cast(),
|
clashFFI.updateGeoData(
|
||||||
|
geoTypeChar,
|
||||||
|
geoNameChar,
|
||||||
receiver.sendPort.nativePort,
|
receiver.sendPort.nativePort,
|
||||||
);
|
);
|
||||||
|
malloc.free(geoTypeChar);
|
||||||
|
malloc.free(geoNameChar);
|
||||||
return completer.future;
|
return completer.future;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool changeProxy(ChangeProxyParams changeProxyParams) {
|
Future<String> sideLoadExternalProvider({
|
||||||
|
required String providerName,
|
||||||
|
required String data,
|
||||||
|
}) {
|
||||||
|
final completer = Completer<String>();
|
||||||
|
final receiver = ReceivePort();
|
||||||
|
receiver.listen((message) {
|
||||||
|
if (!completer.isCompleted) {
|
||||||
|
completer.complete(message);
|
||||||
|
receiver.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
final providerNameChar = providerName.toNativeUtf8().cast<Char>();
|
||||||
|
final dataChar = data.toNativeUtf8().cast<Char>();
|
||||||
|
clashFFI.sideLoadExternalProvider(
|
||||||
|
providerNameChar,
|
||||||
|
dataChar,
|
||||||
|
receiver.sendPort.nativePort,
|
||||||
|
);
|
||||||
|
malloc.free(providerNameChar);
|
||||||
|
malloc.free(dataChar);
|
||||||
|
return completer.future;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String> updateExternalProvider({
|
||||||
|
required String providerName,
|
||||||
|
}) {
|
||||||
|
final completer = Completer<String>();
|
||||||
|
final receiver = ReceivePort();
|
||||||
|
receiver.listen((message) {
|
||||||
|
if (!completer.isCompleted) {
|
||||||
|
completer.complete(message);
|
||||||
|
receiver.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
final providerNameChar = providerName.toNativeUtf8().cast<Char>();
|
||||||
|
clashFFI.updateExternalProvider(
|
||||||
|
providerNameChar,
|
||||||
|
receiver.sendPort.nativePort,
|
||||||
|
);
|
||||||
|
malloc.free(providerNameChar);
|
||||||
|
return completer.future;
|
||||||
|
}
|
||||||
|
|
||||||
|
changeProxy(ChangeProxyParams changeProxyParams) {
|
||||||
final params = json.encode(changeProxyParams);
|
final params = json.encode(changeProxyParams);
|
||||||
return clashFFI.changeProxy(params.toNativeUtf8().cast()) == 1;
|
final paramsChar = params.toNativeUtf8().cast<Char>();
|
||||||
|
clashFFI.changeProxy(paramsChar);
|
||||||
|
malloc.free(paramsChar);
|
||||||
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
clashFFI.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
clashFFI.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Delay> getDelay(String proxyName) {
|
Future<Delay> getDelay(String proxyName) {
|
||||||
@@ -169,35 +258,67 @@ class ClashCore {
|
|||||||
receiver.close();
|
receiver.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
final delayParamsChar =
|
||||||
|
json.encode(delayParams).toNativeUtf8().cast<Char>();
|
||||||
clashFFI.asyncTestDelay(
|
clashFFI.asyncTestDelay(
|
||||||
json.encode(delayParams).toNativeUtf8().cast(),
|
delayParamsChar,
|
||||||
receiver.sendPort.nativePort,
|
receiver.sendPort.nativePort,
|
||||||
);
|
);
|
||||||
Future.delayed(httpTimeoutDuration + moreDuration, () {
|
malloc.free(delayParamsChar);
|
||||||
receiver.close();
|
|
||||||
completer.complete(
|
|
||||||
Delay(name: proxyName, value: -1),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
return completer.future;
|
return completer.future;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearEffect(String path) {
|
clearEffect(String profileId) {
|
||||||
clashFFI.clearEffect(path.toNativeUtf8().cast());
|
final profileIdChar = profileId.toNativeUtf8().cast<Char>();
|
||||||
|
clashFFI.clearEffect(profileIdChar);
|
||||||
|
malloc.free(profileIdChar);
|
||||||
}
|
}
|
||||||
|
|
||||||
VersionInfo getVersionInfo() {
|
VersionInfo getVersionInfo() {
|
||||||
final versionInfoRaw = clashFFI.getVersionInfo();
|
final versionInfoRaw = clashFFI.getVersionInfo();
|
||||||
final versionInfo = json.decode(versionInfoRaw.cast<Utf8>().toDartString());
|
final versionInfo = json.decode(versionInfoRaw.cast<Utf8>().toDartString());
|
||||||
|
clashFFI.freeCString(versionInfoRaw);
|
||||||
return VersionInfo.fromJson(versionInfo);
|
return VersionInfo.fromJson(versionInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setState(CoreState state) {
|
||||||
|
final stateChar = json.encode(state).toNativeUtf8().cast<Char>();
|
||||||
|
clashFFI.setState(stateChar);
|
||||||
|
malloc.free(stateChar);
|
||||||
|
}
|
||||||
|
|
||||||
|
String getCurrentProfileName() {
|
||||||
|
final currentProfileRaw = clashFFI.getCurrentProfileName();
|
||||||
|
final currentProfile = currentProfileRaw.cast<Utf8>().toDartString();
|
||||||
|
clashFFI.freeCString(currentProfileRaw);
|
||||||
|
return currentProfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
AndroidVpnOptions getAndroidVpnOptions() {
|
||||||
|
final vpnOptionsRaw = clashFFI.getAndroidVpnOptions();
|
||||||
|
final vpnOptions = json.decode(vpnOptionsRaw.cast<Utf8>().toDartString());
|
||||||
|
clashFFI.freeCString(vpnOptionsRaw);
|
||||||
|
return AndroidVpnOptions.fromJson(vpnOptions);
|
||||||
|
}
|
||||||
|
|
||||||
Traffic getTraffic() {
|
Traffic getTraffic() {
|
||||||
final trafficRaw = clashFFI.getTraffic();
|
final trafficRaw = clashFFI.getTraffic();
|
||||||
final trafficMap = json.decode(trafficRaw.cast<Utf8>().toDartString());
|
final trafficMap = json.decode(trafficRaw.cast<Utf8>().toDartString());
|
||||||
|
clashFFI.freeCString(trafficRaw);
|
||||||
return Traffic.fromMap(trafficMap);
|
return Traffic.fromMap(trafficMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Traffic getTotalTraffic() {
|
||||||
|
final trafficRaw = clashFFI.getTotalTraffic();
|
||||||
|
final trafficMap = json.decode(trafficRaw.cast<Utf8>().toDartString());
|
||||||
|
clashFFI.freeCString(trafficRaw);
|
||||||
|
return Traffic.fromMap(trafficMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
void resetTraffic() {
|
||||||
|
clashFFI.resetTraffic();
|
||||||
|
}
|
||||||
|
|
||||||
void startLog() {
|
void startLog() {
|
||||||
clashFFI.startLog();
|
clashFFI.startLog();
|
||||||
}
|
}
|
||||||
@@ -206,8 +327,16 @@ class ClashCore {
|
|||||||
clashFFI.stopLog();
|
clashFFI.stopLog();
|
||||||
}
|
}
|
||||||
|
|
||||||
startTun(int fd) {
|
startTun(int fd, int port) {
|
||||||
clashFFI.startTUN(fd);
|
if (!Platform.isAndroid) return;
|
||||||
|
clashFFI.startTUN(fd, port);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateDns(String dns) {
|
||||||
|
if (!Platform.isAndroid) return;
|
||||||
|
final dnsChar = dns.toNativeUtf8().cast<Char>();
|
||||||
|
clashFFI.updateDns(dnsChar);
|
||||||
|
malloc.free(dnsChar);
|
||||||
}
|
}
|
||||||
|
|
||||||
requestGc() {
|
requestGc() {
|
||||||
@@ -219,11 +348,20 @@ class ClashCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setProcessMap(ProcessMapItem processMapItem) {
|
void setProcessMap(ProcessMapItem processMapItem) {
|
||||||
clashFFI.setProcessMap(json.encode(processMapItem).toNativeUtf8().cast());
|
final processMapItemChar =
|
||||||
|
json.encode(processMapItem).toNativeUtf8().cast<Char>();
|
||||||
|
clashFFI.setProcessMap(processMapItemChar);
|
||||||
|
malloc.free(processMapItemChar);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setFdMap(int fd) {
|
||||||
|
clashFFI.setFdMap(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
DateTime? getRunTime() {
|
DateTime? getRunTime() {
|
||||||
final runTimeString = clashFFI.getRunTime().cast<Utf8>().toDartString();
|
final runTimeRaw = clashFFI.getRunTime();
|
||||||
|
final runTimeString = runTimeRaw.cast<Utf8>().toDartString();
|
||||||
|
clashFFI.freeCString(runTimeRaw);
|
||||||
if (runTimeString.isEmpty) return null;
|
if (runTimeString.isEmpty) return null;
|
||||||
return DateTime.fromMillisecondsSinceEpoch(int.parse(runTimeString));
|
return DateTime.fromMillisecondsSinceEpoch(int.parse(runTimeString));
|
||||||
}
|
}
|
||||||
@@ -232,9 +370,20 @@ class ClashCore {
|
|||||||
final connectionsDataRaw = clashFFI.getConnections();
|
final connectionsDataRaw = clashFFI.getConnections();
|
||||||
final connectionsData =
|
final connectionsData =
|
||||||
json.decode(connectionsDataRaw.cast<Utf8>().toDartString()) as Map;
|
json.decode(connectionsDataRaw.cast<Utf8>().toDartString()) as Map;
|
||||||
|
clashFFI.freeCString(connectionsDataRaw);
|
||||||
final connectionsRaw = connectionsData['connections'] as List? ?? [];
|
final connectionsRaw = connectionsData['connections'] as List? ?? [];
|
||||||
return connectionsRaw.map((e) => Connection.fromJson(e)).toList();
|
return connectionsRaw.map((e) => Connection.fromJson(e)).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
closeConnection(String id) {
|
||||||
|
final idChar = id.toNativeUtf8().cast<Char>();
|
||||||
|
clashFFI.closeConnection(idChar);
|
||||||
|
malloc.free(idChar);
|
||||||
|
}
|
||||||
|
|
||||||
|
closeConnections() {
|
||||||
|
clashFFI.closeConnections();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final clashCore = ClashCore();
|
final clashCore = ClashCore();
|
||||||
|
|||||||
@@ -7,20 +7,6 @@ import 'package:flutter/foundation.dart';
|
|||||||
|
|
||||||
import 'core.dart';
|
import 'core.dart';
|
||||||
|
|
||||||
abstract mixin class ClashMessageListener {
|
|
||||||
void onLog(Log log) {}
|
|
||||||
|
|
||||||
void onTun(String fd) {}
|
|
||||||
|
|
||||||
void onDelay(Delay delay) {}
|
|
||||||
|
|
||||||
void onProcess(Process process) {}
|
|
||||||
|
|
||||||
void onRequest(Connection connection) {}
|
|
||||||
|
|
||||||
void onNow(Now now) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ClashMessage {
|
class ClashMessage {
|
||||||
StreamSubscription? subscription;
|
StreamSubscription? subscription;
|
||||||
|
|
||||||
@@ -30,27 +16,24 @@ class ClashMessage {
|
|||||||
subscription = null;
|
subscription = null;
|
||||||
}
|
}
|
||||||
subscription = ClashCore.receiver.listen((message) {
|
subscription = ClashCore.receiver.listen((message) {
|
||||||
final m = Message.fromJson(json.decode(message));
|
final m = AppMessage.fromJson(json.decode(message));
|
||||||
for (final ClashMessageListener listener in _listeners) {
|
for (final AppMessageListener listener in _listeners) {
|
||||||
switch (m.type) {
|
switch (m.type) {
|
||||||
case MessageType.log:
|
case AppMessageType.log:
|
||||||
listener.onLog(Log.fromJson(m.data));
|
listener.onLog(Log.fromJson(m.data));
|
||||||
break;
|
break;
|
||||||
case MessageType.tun:
|
case AppMessageType.delay:
|
||||||
listener.onTun(m.data);
|
|
||||||
break;
|
|
||||||
case MessageType.delay:
|
|
||||||
listener.onDelay(Delay.fromJson(m.data));
|
listener.onDelay(Delay.fromJson(m.data));
|
||||||
break;
|
break;
|
||||||
case MessageType.process:
|
case AppMessageType.request:
|
||||||
listener.onProcess(Process.fromJson(m.data));
|
|
||||||
break;
|
|
||||||
case MessageType.now:
|
|
||||||
listener.onNow(Now.fromJson(m.data));
|
|
||||||
break;
|
|
||||||
case MessageType.request:
|
|
||||||
listener.onRequest(Connection.fromJson(m.data));
|
listener.onRequest(Connection.fromJson(m.data));
|
||||||
break;
|
break;
|
||||||
|
case AppMessageType.started:
|
||||||
|
listener.onStarted(m.data);
|
||||||
|
break;
|
||||||
|
case AppMessageType.loaded:
|
||||||
|
listener.onLoaded(m.data);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -58,18 +41,18 @@ class ClashMessage {
|
|||||||
|
|
||||||
static final ClashMessage instance = ClashMessage._();
|
static final ClashMessage instance = ClashMessage._();
|
||||||
|
|
||||||
final ObserverList<ClashMessageListener> _listeners =
|
final ObserverList<AppMessageListener> _listeners =
|
||||||
ObserverList<ClashMessageListener>();
|
ObserverList<AppMessageListener>();
|
||||||
|
|
||||||
bool get hasListeners {
|
bool get hasListeners {
|
||||||
return _listeners.isNotEmpty;
|
return _listeners.isNotEmpty;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addListener(ClashMessageListener listener) {
|
void addListener(AppMessageListener listener) {
|
||||||
_listeners.add(listener);
|
_listeners.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeListener(ClashMessageListener listener) {
|
void removeListener(AppMessageListener listener) {
|
||||||
_listeners.remove(listener);
|
_listeners.remove(listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ class ClashService {
|
|||||||
}
|
}
|
||||||
const geoFileNameList = [
|
const geoFileNameList = [
|
||||||
mmdbFileName,
|
mmdbFileName,
|
||||||
|
geoIpFileName,
|
||||||
geoSiteFileName,
|
geoSiteFileName,
|
||||||
asnFileName,
|
asnFileName,
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:fl_clash/clash/clash.dart';
|
|
||||||
import 'package:fl_clash/plugins/app.dart';
|
import 'package:fl_clash/plugins/app.dart';
|
||||||
|
import 'package:fl_clash/state.dart';
|
||||||
|
|
||||||
class Android {
|
class Android {
|
||||||
init() async {
|
init() async {
|
||||||
app?.onExit = () {
|
app?.onExit = () async {
|
||||||
clashCore.shutdown();
|
await globalState.appController.savePreferences();
|
||||||
print("adsadda==>");
|
|
||||||
exit(0);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
28
lib/common/archive.dart
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
|
import 'package:archive/archive_io.dart';
|
||||||
|
import 'package:path/path.dart';
|
||||||
|
|
||||||
|
extension ArchiveExt on Archive {
|
||||||
|
addDirectoryToArchive(String dirPath, String parentPath) {
|
||||||
|
final dir = Directory(dirPath);
|
||||||
|
final entities = dir.listSync(recursive: false);
|
||||||
|
for (final entity in entities) {
|
||||||
|
final relativePath = relative(entity.path, from: parentPath);
|
||||||
|
if (entity is File) {
|
||||||
|
final data = entity.readAsBytesSync();
|
||||||
|
final archiveFile = ArchiveFile(relativePath, data.length, data);
|
||||||
|
addFile(archiveFile);
|
||||||
|
} else if (entity is Directory) {
|
||||||
|
addDirectoryToArchive(entity.path, parentPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
add<T>(String name, T raw) {
|
||||||
|
final data = json.encode(raw);
|
||||||
|
addFile(
|
||||||
|
ArchiveFile(name, data.length, data),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,4 +16,21 @@ extension ColorExtension on Color {
|
|||||||
toLittle() {
|
toLittle() {
|
||||||
return withOpacity(0.03);
|
return withOpacity(0.03);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Color darken([double amount = .1]) {
|
||||||
|
assert(amount >= 0 && amount <= 1);
|
||||||
|
final hsl = HSLColor.fromColor(this);
|
||||||
|
final hslDark = hsl.withLightness((hsl.lightness - amount).clamp(0.0, 1.0));
|
||||||
|
return hslDark.toColor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension ColorSchemeExtension on ColorScheme {
|
||||||
|
ColorScheme toPrueBlack(bool isPrueBlack) => isPrueBlack
|
||||||
|
? copyWith(
|
||||||
|
surface: Colors.black,
|
||||||
|
background: Colors.black,
|
||||||
|
surfaceContainer: surfaceContainer.darken(0.05),
|
||||||
|
)
|
||||||
|
: this;
|
||||||
|
}
|
||||||
|
|||||||