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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: "[Bug] "
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '...'
3. Scroll down to '...'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[Feature] "
labels: enhancement
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
42 changes: 21 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
IFS="." read -r -a VERSION_ARRAY <<< "${github_ref_name#v}"
VERSION_STR="${VERSION_ARRAY[0]}.${VERSION_ARRAY[1]}.${VERSION_ARRAY[2]}"
sed -i "s|PKG_VERSION:=.*|PKG_VERSION:=${VERSION_STR}|g" wrt/Makefile
sed -i "s|PKG_HASH:=.*|PKG_HASH:=${HIDDIFY_CORE_WRT_HASH}|g" wrt/Makefile
sed -i "s|PKG_HASH:=.*|PKG_HASH:=${HIDDIFY_CORE_WRT_HASH}|g" wrt/Makefile
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Update WRT package HASH."
Expand All @@ -43,26 +43,26 @@ jobs:
matrix:
job:
- { name: 'hiddify-core-android', os: 'ubuntu-latest', target: 'android' }
- { name: 'hiddify-core-linux-amd64', os: 'ubuntu-20.04', target: 'linux-amd64' }
- { name: 'hiddify-core-linux-amd64', os: 'ubuntu-22.04', target: 'linux-amd64' }
- { name: "hiddify-core-windows-amd64", os: 'ubuntu-latest', target: 'windows-amd64', aarch: 'x64' }
- { name: "hiddify-core-macos-universal", os: 'macos-12', target: 'macos-universal' }
- { name: "hiddify-core-ios", os: "macos-12", target: "ios" }
# linux custom
- {name: hiddify-cli-linux-amd64, goos: linux, goarch: amd64, goamd64: v1, target: 'linux-custom', os: 'ubuntu-20.04'}
- {name: hiddify-cli-linux-amd64-v3, goos: linux, goarch: amd64, goamd64: v3, target: 'linux-custom', os: 'ubuntu-20.04'}
- {name: hiddify-cli-linux-386, goos: linux, goarch: 386, target: 'linux-custom', os: 'ubuntu-20.04'}
- {name: hiddify-cli-linux-arm64, goos: linux, goarch: arm64, target: 'linux-custom', os: 'ubuntu-20.04'}
- {name: hiddify-cli-linux-armv5, goos: linux, goarch: arm, goarm: 5, target: 'linux-custom', os: 'ubuntu-20.04'}
- {name: hiddify-cli-linux-armv6, goos: linux, goarch: arm, goarm: 6, target: 'linux-custom', os: 'ubuntu-20.04'}
- {name: hiddify-cli-linux-armv7, goos: linux, goarch: arm, goarm: 7, target: 'linux-custom', os: 'ubuntu-20.04'}
- {name: hiddify-cli-linux-mips-softfloat, goos: linux, goarch: mips, gomips: softfloat, target: 'linux-custom', os: 'ubuntu-20.04'}
- {name: hiddify-cli-linux-mips-hardfloat, goos: linux, goarch: mips, gomips: hardfloat, target: 'linux-custom', os: 'ubuntu-20.04'}
- {name: hiddify-cli-linux-mipsel-softfloat, goos: linux, goarch: mipsle, gomips: softfloat, target: 'linux-custom', os: 'ubuntu-20.04'}
- {name: hiddify-cli-linux-mipsel-hardfloat, goos: linux, goarch: mipsle, gomips: hardfloat, target: 'linux-custom', os: 'ubuntu-20.04'}
- {name: hiddify-cli-linux-mips64, goos: linux, goarch: mips64, target: 'linux-custom', os: 'ubuntu-20.04'}
- {name: hiddify-cli-linux-mips64el, goos: linux, goarch: mips64le, target: 'linux-custom', os: 'ubuntu-20.04'}
- {name: hiddify-cli-linux-s390x, goos: linux, goarch: s390x, target: 'linux-custom', os: 'ubuntu-20.04'}
- {name: hiddify-cli-linux-amd64, goos: linux, goarch: amd64, goamd64: v1, target: 'linux-custom', os: 'ubuntu-22.04'}
- {name: hiddify-cli-linux-amd64-v3, goos: linux, goarch: amd64, goamd64: v3, target: 'linux-custom', os: 'ubuntu-22.04'}
- {name: hiddify-cli-linux-386, goos: linux, goarch: 386, target: 'linux-custom', os: 'ubuntu-22.04'}
- {name: hiddify-cli-linux-arm64, goos: linux, goarch: arm64, target: 'linux-custom', os: 'ubuntu-22.04'}
- {name: hiddify-cli-linux-armv5, goos: linux, goarch: arm, goarm: 5, target: 'linux-custom', os: 'ubuntu-22.04'}
- {name: hiddify-cli-linux-armv6, goos: linux, goarch: arm, goarm: 6, target: 'linux-custom', os: 'ubuntu-22.04'}
- {name: hiddify-cli-linux-armv7, goos: linux, goarch: arm, goarm: 7, target: 'linux-custom', os: 'ubuntu-22.04'}
- {name: hiddify-cli-linux-mips-softfloat, goos: linux, goarch: mips, gomips: softfloat, target: 'linux-custom', os: 'ubuntu-22.04'}
- {name: hiddify-cli-linux-mips-hardfloat, goos: linux, goarch: mips, gomips: hardfloat, target: 'linux-custom', os: 'ubuntu-22.04'}
- {name: hiddify-cli-linux-mipsel-softfloat, goos: linux, goarch: mipsle, gomips: softfloat, target: 'linux-custom', os: 'ubuntu-22.04'}
- {name: hiddify-cli-linux-mipsel-hardfloat, goos: linux, goarch: mipsle, gomips: hardfloat, target: 'linux-custom', os: 'ubuntu-22.04'}
- {name: hiddify-cli-linux-mips64, goos: linux, goarch: mips64, target: 'linux-custom', os: 'ubuntu-22.04'}
- {name: hiddify-cli-linux-mips64el, goos: linux, goarch: mips64le, target: 'linux-custom', os: 'ubuntu-22.04'}
- {name: hiddify-cli-linux-s390x, goos: linux, goarch: s390x, target: 'linux-custom', os: 'ubuntu-22.04'}

runs-on: ${{ matrix.job.os }}
env:
GOOS: ${{ matrix.job.goos }}
Expand Down Expand Up @@ -115,14 +115,14 @@ jobs:

- name: zip
run: |
tree
tree
rm -f /*.h */*.h
rm ./hiddify-libcore*sources* ||echo "no source"
rm ./hiddify-libcore-macos-a*.dylib || echo "no macos arm and amd"
files=$(ls | grep -E '^(libcore\.(dll|so|dylib|aar)|webui|Libcore.xcframework|lib|HiddifyCli(\.exe)?)$')
echo tar -czvf ${{ matrix.job.name }}.tar.gz $files
tar -czvf ${{ matrix.job.name }}.tar.gz $files

working-directory: bin
- uses: actions/upload-artifact@v4
if: ${{ success() }}
Expand Down Expand Up @@ -206,7 +206,7 @@ jobs:
permissions: write-all
if: ${{ inputs.channel=='prod' }}
needs: [upload-release]

runs-on: ubuntu-latest
strategy:
fail-fast: true
Expand Down Expand Up @@ -297,7 +297,7 @@ jobs:
-t "${{ env.REGISTRY_IMAGE }}:${{ inputs.tag-name }}" \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
- name: Inspect image

run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ env.LATEST }}
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ inputs.tag-name }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ cert
**/*.syso
node_modules
*.db
*.json
*.json
*.tar.gz
hiddify-cli.exe
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ protos:


lib_install:
go install -v github.com/sagernet/gomobile/cmd/[email protected].1
go install -v github.com/sagernet/gomobile/cmd/[email protected].1
go install -v github.com/sagernet/gomobile/cmd/[email protected].8
go install -v github.com/sagernet/gomobile/cmd/[email protected].8
npm install

headers:
Expand Down
84 changes: 67 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
# hiddify-core


## Docker
To Run our docker image see https://github.com/hiddify/hiddify-core/pkgs/container/hiddify-core

To Run our docker image see <https://github.com/hiddify/hiddify-core/pkgs/container/hiddify-core>

Docker
```

```bash
docker pull ghcr.io/hiddify/hiddify-core:latest
```

Docker Compose
```

```bash
git clone https://github.com/hiddify/hiddify-core
cd hiddify-core/docker
docker-compose up
```

## WRT

...

## Extension
Expand All @@ -31,23 +34,70 @@ Features and Road map:

- [x] Add Third Party Extension capability
- [x] Test Extension from Browser without any dependency to android/mac/.... `./cmd.sh extension` the open browser `https://127.0.0.1:12346`
- [x] Show Custom UI from Extension `github.com/hiddify/hiddify-core/extension.UpdateUI()`
- [x] Show Custom UI from Extension `github.com/hiddify/hiddify-core/extension.UpdateUI()`
- [x] Show Custom Dialog from Extension `github.com/hiddify/hiddify-core/extension.ShowDialog()`
- [x] Show Alert Dialog from Extension `github.com/hiddify/hiddify-core/extension.ShowMessage()`
- [x] Get Data from UI `github.com/hiddify/hiddify-core/extension.SubmitData()`
- [x] Show Alert Dialog from Extension `github.com/hiddify/hiddify-core/extension.ShowMessage()`
- [x] Get Data from UI `github.com/hiddify/hiddify-core/extension.SubmitData()`
- [x] Save Extension Data from `e.Base.Data`
- [x] Load Extension Data to `e.Base.Data`
- [x] Disable / Enable Extension
- [x] Update user proxies before connecting `github.com/hiddify/hiddify-core/extension.BeforeAppConnect()`
- [x] Run Tiny Independent Instance `github.com/hiddify/hiddify-core/extension/sdk.RunInstance()`
- [x] Parse Any type of configs/url `github.com/hiddify/hiddify-core/extension/sdk.ParseConfig()`
- [x] Disable / Enable Extension
- [x] Update user proxies before connecting `github.com/hiddify/hiddify-core/extension.BeforeAppConnect()`
- [x] Parse Any type of configs/url `github.com/hiddify/hiddify-core/extension/sdk.ParseConfig()`
- [ ] ToDo: Add Support for MultiLanguage Interface
- [ ] ToDo: Custom Extension Outbound
- [ ] ToDo: Custom Extension Inbound
- [ ] ToDo: Custom Extension ProxyConfig

Demo Screenshots from HTML:

<img width="531" alt="image" src="https://github.com/user-attachments/assets/0fbef76f-896f-4c45-a6b8-7a2687c47013">
<img width="531" alt="image" src="https://github.com/user-attachments/assets/15bccfa0-d03e-4354-9368-241836d82948">

Demo Screenshots from HTML:

![image](https://github.com/user-attachments/assets/0fbef76f-896f-4c45-a6b8-7a2687c47013)
![image](https://github.com/user-attachments/assets/15bccfa0-d03e-4354-9368-241836d82948)

## SingBox

Hiddify-core به صورت پیش‌فرض بر پایه `sing-box` نسخه `v1.13.0-alpha.20` (مطابق `go.mod`) اجرا می‌شود و از ساختار رسمی معرفی‌شده در [مستندات sing-box](https://sing-box.sagernet.org/configuration/) پیروی می‌کند.

### مفاهیم پایه

- **ساختار پیکربندی**

```jsonc
{
"log": {},
"dns": {},
"ntp": {},
"certificate": {},
"endpoints": [],
"inbounds": [],
"outbounds": [],
"route": {},
"services": [],
"experimental": {}
}
```

این اسکلت با سند `index.md` در مستندات رسمی هم‌راستاست و توسط توابع `config.BuildConfig()` و `config.BuildConfigJson()` ایجاد و تکمیل می‌شود.
- **راستی‌آزمایی و قالب‌بندی**

- اجرای `sing-box check` برای اعتبارسنجی نهایی.
- اجرای `sing-box format -w -c config.json` جهت یکسان‌سازی قالب.
- در صورت نیاز به ادغام چند فایل: `sing-box merge output.json -c config.json`.

- **منابع رسمی برای فیلدها**

- ورودی‌ها (Inbound): [Inbound](https://sing-box.sagernet.org/configuration/inbound/)
- خروجی‌ها (Outbound): [Outbound](https://sing-box.sagernet.org/configuration/outbound/)
- مسیریابی (Route): [Route](https://sing-box.sagernet.org/configuration/route/)

### گردش کار در هسته

- **تجمیع گزینه‌ها**: ساختار `config.HiddifyOptions` تنظیمات برنامه را نگهداری می‌کند و با `option.Options` کتابخانه sing-box ادغام می‌شود.
- **تولید خودکار کانفیگ**:
- تابع `config.BuildConfig()` ماژول‌های DNS، Inbound، Outbound، و Rules را با آخرین استانداردهای sing-box تنظیم می‌کند.
- تابع `config.ParseConfigContent()` ورودی‌های Clash، V2Ray یا JSON را به ساختار sing-box تبدیل و با `libbox.CheckConfig` اعتبارسنجی می‌کند.
- **به‌روزرسانی Warp و گزینه‌های پویا**: ماژول‌های `config/warp.go` و `config/outbound.go` پروفایل‌های WireGuard/WARP را مطابق API‌های sing-box 1.13 نگاشت می‌کنند.

### نکات نسخه‌ای و مهاجرت

- **توجه به تغییرات 1.11 تا 1.13**: قوانین DNS و Route در نسخه‌های اخیر به Rule-Setها منتقل شده‌اند. برای مهاجرت کانفیگ‌های قدیمی از راهنمای [Migration](https://sing-box.sagernet.org/migration/) استفاده کنید.
- **فعال‌سازی ویژگی‌های جدید**: گزینه‌های `Route.AutoDetectInterface` و `Experimental.ClashAPI` در `config/config.go` مطابق توصیه‌های رسمی فعال شده‌اند.
- **پیگیری انتشارها**: به‌منظور همگام‌سازی با تغییرات آینده، به مخزن [SagerNet/sing-box](https://github.com/SagerNet/sing-box) و صفحه انتشار نسخه‌ها مراجعه کنید.
4 changes: 3 additions & 1 deletion bridge/bridge.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// +build cgo
//go:build cgo
package bridge

// #include "stdint.h"
// #include "stdlib.h"
// #include "include/dart_api_dl.c"
//
// // Go does not allow calling C function pointers directly. So we are
Expand All @@ -26,6 +27,7 @@ func SendStringToPort(port int64, msg string) {
var obj C.Dart_CObject
obj._type = C.Dart_CObject_kString
msg_obj := C.CString(msg) // go string -> char*s
defer C.free(unsafe.Pointer(msg_obj))
// union type, we do a force conversion
ptr := unsafe.Pointer(&obj.value[0])
*(**C.char)(ptr) = msg_obj
Expand Down
1 change: 1 addition & 0 deletions cli/bydll/clibydll.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ func main() {

// Call the C function
result := C.parseCli(C.int(len(cArgs)), (**C.char)(unsafe.Pointer(&cArgs[0])))
defer C.free(unsafe.Pointer(result))
fmt.Println(C.GoString(result))
}
Loading