mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-09-29 07:56:37 +08:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a155bc64c0 | |||
| 62bd8ea469 | |||
| f3a9684be4 |
@@ -2,12 +2,13 @@ name: Build and Push Images Based on Version
|
|||||||
|
|
||||||
# 在这里定义统一版本号
|
# 在这里定义统一版本号
|
||||||
env:
|
env:
|
||||||
VERSION: "1.4.2"
|
VERSION: "1.4.3"
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
- beta
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check-version:
|
check-version:
|
||||||
@@ -16,30 +17,45 @@ jobs:
|
|||||||
outputs:
|
outputs:
|
||||||
version: ${{ env.VERSION }}
|
version: ${{ env.VERSION }}
|
||||||
should_build: ${{ steps.check-tag.outputs.should_build }}
|
should_build: ${{ steps.check-tag.outputs.should_build }}
|
||||||
|
should_build_gost: ${{ steps.check-tag.outputs.should_build_gost }}
|
||||||
|
tag_exists: ${{ steps.check-tag.outputs.tag_exists }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # 获取所有历史和 tags
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Display version
|
- name: Display version
|
||||||
run: |
|
run: |
|
||||||
echo "Current version: ${{ env.VERSION }}"
|
echo "Current version: ${{ env.VERSION }}"
|
||||||
|
|
||||||
- name: Check if tag exists
|
- name: Check if tag exists and detect changes
|
||||||
id: check-tag
|
id: check-tag
|
||||||
run: |
|
run: |
|
||||||
if git rev-parse "${{ env.VERSION }}" >/dev/null 2>&1; then
|
if git rev-parse "${{ env.VERSION }}" >/dev/null 2>&1; then
|
||||||
echo "Tag ${{ env.VERSION }} already exists, skip build"
|
echo "Tag ${{ env.VERSION }} already exists"
|
||||||
|
echo "tag_exists=true" >> $GITHUB_OUTPUT
|
||||||
echo "should_build=false" >> $GITHUB_OUTPUT
|
echo "should_build=false" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
# 检查从tag到现在,go-gost目录下的文件是否有变化
|
||||||
|
TAG_COMMIT=$(git rev-list -n 1 "${{ env.VERSION }}")
|
||||||
|
if git diff --quiet $TAG_COMMIT HEAD -- go-gost/; then
|
||||||
|
echo "✅ GOST files unchanged since tag"
|
||||||
|
echo "should_build_gost=false" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "🔄 GOST files changed since tag, will rebuild GOST binary"
|
||||||
|
echo "should_build_gost=true" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "Tag ${{ env.VERSION }} does not exist, will build all components"
|
echo "Tag ${{ env.VERSION }} does not exist, will build all components"
|
||||||
echo "should_build=true" >> $GITHUB_OUTPUT
|
echo "should_build=true" >> $GITHUB_OUTPUT
|
||||||
|
echo "should_build_gost=true" >> $GITHUB_OUTPUT
|
||||||
|
echo "tag_exists=false" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
build-gost:
|
build-gost:
|
||||||
name: Build & Compress GOST Binary
|
name: Build & Compress GOST Binary
|
||||||
needs: check-version
|
needs: check-version
|
||||||
if: needs.check-version.outputs.should_build == 'true'
|
if: needs.check-version.outputs.should_build_gost == 'true'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
@@ -66,21 +82,37 @@ jobs:
|
|||||||
sudo mv upx-4.2.1-amd64_linux/upx /usr/local/bin/
|
sudo mv upx-4.2.1-amd64_linux/upx /usr/local/bin/
|
||||||
rm -rf upx-4.2.1-amd64_linux*
|
rm -rf upx-4.2.1-amd64_linux*
|
||||||
|
|
||||||
- name: Build GOST binary
|
- name: Build GOST binary (AMD64)
|
||||||
working-directory: ./go-gost
|
working-directory: ./go-gost
|
||||||
run: |
|
run: |
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o gost
|
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o gost-amd64
|
||||||
|
|
||||||
- name: Compress with UPX
|
- name: Build GOST binary (ARM64)
|
||||||
working-directory: ./go-gost
|
working-directory: ./go-gost
|
||||||
run: |
|
run: |
|
||||||
upx --best --lzma gost
|
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="-s -w" -o gost-arm64
|
||||||
|
|
||||||
- name: Upload GOST artifact
|
- name: Compress with UPX (AMD64)
|
||||||
|
working-directory: ./go-gost
|
||||||
|
run: |
|
||||||
|
upx --best --lzma gost-amd64
|
||||||
|
|
||||||
|
- name: Compress with UPX (ARM64)
|
||||||
|
working-directory: ./go-gost
|
||||||
|
run: |
|
||||||
|
upx --best --lzma gost-arm64
|
||||||
|
|
||||||
|
- name: Upload GOST AMD64 artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: gost-binary
|
name: gost-binary-amd64
|
||||||
path: ./go-gost/gost
|
path: ./go-gost/gost-amd64
|
||||||
|
|
||||||
|
- name: Upload GOST ARM64 artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: gost-binary-arm64
|
||||||
|
path: ./go-gost/gost-arm64
|
||||||
|
|
||||||
build-vite:
|
build-vite:
|
||||||
name: Build & Push Vite Frontend
|
name: Build & Push Vite Frontend
|
||||||
@@ -108,7 +140,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
VERSION="${{ needs.check-version.outputs.version }}"
|
VERSION="${{ needs.check-version.outputs.version }}"
|
||||||
docker buildx build \
|
docker buildx build \
|
||||||
--platform linux/amd64 \
|
--platform linux/amd64,linux/arm64 \
|
||||||
--push \
|
--push \
|
||||||
-t bqlpfy/vite-frontend:latest \
|
-t bqlpfy/vite-frontend:latest \
|
||||||
-t bqlpfy/vite-frontend:${VERSION} \
|
-t bqlpfy/vite-frontend:${VERSION} \
|
||||||
@@ -152,7 +184,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
VERSION="${{ needs.check-version.outputs.version }}"
|
VERSION="${{ needs.check-version.outputs.version }}"
|
||||||
docker buildx build \
|
docker buildx build \
|
||||||
--platform linux/amd64 \
|
--platform linux/amd64,linux/arm64 \
|
||||||
--push \
|
--push \
|
||||||
-t bqlpfy/springboot-backend:latest \
|
-t bqlpfy/springboot-backend:latest \
|
||||||
-t bqlpfy/springboot-backend:${VERSION} \
|
-t bqlpfy/springboot-backend:${VERSION} \
|
||||||
@@ -168,11 +200,22 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Download GOST binary
|
- name: Download GOST AMD64 binary
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: gost-binary
|
name: gost-binary-amd64
|
||||||
path: ./artifacts
|
path: ./artifacts/amd64
|
||||||
|
|
||||||
|
- name: Download GOST ARM64 binary
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: gost-binary-arm64
|
||||||
|
path: ./artifacts/arm64
|
||||||
|
|
||||||
|
- name: Rename binaries
|
||||||
|
run: |
|
||||||
|
mv ./artifacts/amd64/gost-amd64 ./artifacts/gost-amd64
|
||||||
|
mv ./artifacts/arm64/gost-arm64 ./artifacts/gost-arm64
|
||||||
|
|
||||||
- name: Create Release
|
- name: Create Release
|
||||||
env:
|
env:
|
||||||
@@ -184,39 +227,104 @@ jobs:
|
|||||||
git tag "${VERSION}" ${{ github.sha }}
|
git tag "${VERSION}" ${{ github.sha }}
|
||||||
git push origin "${VERSION}"
|
git push origin "${VERSION}"
|
||||||
|
|
||||||
|
# 获取 commit 信息
|
||||||
|
COMMIT_MSG=$(git log -1 --pretty=format:"%s")
|
||||||
|
COMMIT_AUTHOR=$(git log -1 --pretty=format:"%an")
|
||||||
|
COMMIT_DATE=$(git log -1 --pretty=format:"%ai")
|
||||||
|
|
||||||
# 创建 release
|
# 创建 release
|
||||||
gh release create "${VERSION}" \
|
gh release create "${VERSION}" \
|
||||||
--title "Release ${VERSION}" \
|
--title "Release ${VERSION}" \
|
||||||
--notes "Version ${VERSION}
|
--notes "## 📝 Commit Information
|
||||||
|
- **Message**: ${COMMIT_MSG}
|
||||||
## Components
|
- **Author**: ${COMMIT_AUTHOR}
|
||||||
- **GOST Binary** (Linux AMD64, compressed with UPX)
|
- **Date**: ${COMMIT_DATE}
|
||||||
- **Vite Frontend** Docker Image: \`bqlpfy/vite-frontend:${VERSION}\` / \`bqlpfy/vite-frontend:latest\`
|
- **Commit**: [\`${GITHUB_SHA:0:7}\`](https://github.com/${{ github.repository }}/commit/${{ github.sha }})" \
|
||||||
- **Spring Boot Backend** Docker Image: \`bqlpfy/springboot-backend:${VERSION}\` / \`bqlpfy/springboot-backend:latest\`
|
|
||||||
|
|
||||||
## Installation Files
|
|
||||||
- \`install.sh\` - GOST 客户端安装脚本
|
|
||||||
- \`panel_install.sh\` - 面板安装脚本
|
|
||||||
- \`gost.sql\` - 数据库初始化文件
|
|
||||||
- \`docker-compose-v4.yml\` - Docker Compose 配置 (IPv4)
|
|
||||||
- \`docker-compose-v6.yml\` - Docker Compose 配置 (IPv6)
|
|
||||||
|
|
||||||
## Details
|
|
||||||
- Build date: $(date -u +%Y-%m-%dT%H:%M:%SZ)
|
|
||||||
- Commit: ${{ github.sha }}" \
|
|
||||||
--repo ${{ github.repository }}
|
--repo ${{ github.repository }}
|
||||||
|
|
||||||
# 上传所有文件到 release
|
# 上传所有文件到 release
|
||||||
echo "📤 上传 GOST 二进制..."
|
echo "📤 上传 GOST 二进制文件..."
|
||||||
gh release upload "${VERSION}" ./artifacts/gost --clobber
|
gh release upload "${VERSION}" ./artifacts/gost-amd64 --clobber
|
||||||
|
gh release upload "${VERSION}" ./artifacts/gost-arm64 --clobber
|
||||||
|
|
||||||
echo "📤 上传安装脚本..."
|
echo "📤 上传安装脚本..."
|
||||||
gh release upload "${VERSION}" ./install.sh --clobber
|
gh release upload "${VERSION}" ./install.sh --clobber
|
||||||
gh release upload "${VERSION}" ./panel_install.sh --clobber
|
gh release upload "${VERSION}" ./panel_install.sh --clobber
|
||||||
|
|
||||||
echo "📤 上传配置文件..."
|
echo "📤 上传 Docker Compose 配置文件..."
|
||||||
gh release upload "${VERSION}" ./gost.sql --clobber
|
|
||||||
gh release upload "${VERSION}" ./docker-compose-v4.yml --clobber
|
gh release upload "${VERSION}" ./docker-compose-v4.yml --clobber
|
||||||
gh release upload "${VERSION}" ./docker-compose-v6.yml --clobber
|
gh release upload "${VERSION}" ./docker-compose-v6.yml --clobber
|
||||||
|
|
||||||
echo "✅ 所有文件已上传到 Release ${VERSION}"
|
echo "✅ 所有文件已上传到 Release ${VERSION}"
|
||||||
|
|
||||||
|
update-release-gost:
|
||||||
|
name: Update GOST Binaries in Release
|
||||||
|
needs: [check-version, build-gost]
|
||||||
|
if: needs.check-version.outputs.should_build == 'false' && needs.check-version.outputs.should_build_gost == 'true'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Download GOST AMD64 binary
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: gost-binary-amd64
|
||||||
|
path: ./artifacts/amd64
|
||||||
|
|
||||||
|
- name: Download GOST ARM64 binary
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: gost-binary-arm64
|
||||||
|
path: ./artifacts/arm64
|
||||||
|
|
||||||
|
- name: Rename binaries
|
||||||
|
run: |
|
||||||
|
mv ./artifacts/amd64/gost-amd64 ./artifacts/gost-amd64
|
||||||
|
mv ./artifacts/arm64/gost-arm64 ./artifacts/gost-arm64
|
||||||
|
|
||||||
|
- name: Update GOST binaries in Release
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
run: |
|
||||||
|
VERSION="${{ needs.check-version.outputs.version }}"
|
||||||
|
|
||||||
|
echo "🔄 更新 Release ${VERSION} 中的 GOST 二进制文件..."
|
||||||
|
|
||||||
|
gh release upload "${VERSION}" ./artifacts/gost-amd64 --clobber
|
||||||
|
gh release upload "${VERSION}" ./artifacts/gost-arm64 --clobber
|
||||||
|
|
||||||
|
echo "✅ GOST 二进制文件更新完成!"
|
||||||
|
echo "ℹ️ Docker 镜像未重新构建"
|
||||||
|
|
||||||
|
update-release-files:
|
||||||
|
name: Update Release Files Only
|
||||||
|
needs: check-version
|
||||||
|
if: needs.check-version.outputs.tag_exists == 'true' && needs.check-version.outputs.should_build == 'false' && needs.check-version.outputs.should_build_gost == 'false'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Update Release Files
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
run: |
|
||||||
|
VERSION="${{ needs.check-version.outputs.version }}"
|
||||||
|
|
||||||
|
echo "📤 更新 Release ${VERSION} 中的脚本和配置文件..."
|
||||||
|
|
||||||
|
# 上传安装脚本(覆盖)
|
||||||
|
echo "📤 更新安装脚本..."
|
||||||
|
gh release upload "${VERSION}" ./install.sh --clobber
|
||||||
|
gh release upload "${VERSION}" ./panel_install.sh --clobber
|
||||||
|
|
||||||
|
# 上传 Docker Compose 配置文件(覆盖)
|
||||||
|
echo "📤 更新 Docker Compose 配置文件..."
|
||||||
|
gh release upload "${VERSION}" ./docker-compose-v4.yml --clobber
|
||||||
|
gh release upload "${VERSION}" ./docker-compose-v6.yml --clobber
|
||||||
|
|
||||||
|
echo "✅ 文件更新完成!Release ${VERSION} 中的脚本和配置已更新"
|
||||||
|
echo "ℹ️ Docker 镜像和 GOST 二进制未重新构建"
|
||||||
@@ -1,6 +1,22 @@
|
|||||||
|
|
||||||
# flux-panel转发面板 哆啦A梦转发面板
|
# flux-panel转发面板 哆啦A梦转发面板
|
||||||
|
|
||||||
|
# 赞助商
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://vps.town" style="margin: 0 20px; text-align:center;">
|
||||||
|
<img src="./doc/vpstown.png" width="300">
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a href="https://whmcs.as211392.com" style="margin: 0 20px; text-align:center;">
|
||||||
|
<img src="./doc/as211392.png" width="300">
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
使用1.x版本的请使用上面给出的脚本,不要使用最新的,最新的默认2.x
|
||||||
|
嫌弃麻烦或者想稳定的我不推荐你升级到2.x版本 目前还在beta阶段,很多问题。
|
||||||
|
|
||||||
|
|
||||||
本项目基于 [go-gost/gost](https://github.com/go-gost/gost) 和 [go-gost/x](https://github.com/go-gost/x) 两个开源库,实现了转发面板。
|
本项目基于 [go-gost/gost](https://github.com/go-gost/gost) 和 [go-gost/x](https://github.com/go-gost/x) 两个开源库,实现了转发面板。
|
||||||
---
|
---
|
||||||
@@ -17,10 +33,26 @@
|
|||||||
## 部署流程
|
## 部署流程
|
||||||
---
|
---
|
||||||
### Docker Compose部署
|
### Docker Compose部署
|
||||||
|
#### 快速部署
|
||||||
|
面板端(稳定版):
|
||||||
```bash
|
```bash
|
||||||
curl -L https://raw.githubusercontent.com/bqlpfy/flux-panel/refs/heads/main/panel_install.sh -o panel_install.sh && chmod +x panel_install.sh && ./panel_install.sh
|
curl -L https://raw.githubusercontent.com/bqlpfy/flux-panel/refs/heads/main/panel_install.sh -o panel_install.sh && chmod +x panel_install.sh && ./panel_install.sh
|
||||||
```
|
```
|
||||||
|
节点端(稳定版):
|
||||||
|
```bash
|
||||||
|
curl -L https://raw.githubusercontent.com/bqlpfy/flux-panel/refs/heads/main/install.sh -o install.sh && chmod +x install.sh && ./install.sh
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
面板端(开发版):
|
||||||
|
```bash
|
||||||
|
curl -L https://raw.githubusercontent.com/bqlpfy/flux-panel/refs/heads/beta/panel_install.sh -o panel_install.sh && chmod +x panel_install.sh && ./panel_install.sh
|
||||||
|
```
|
||||||
|
节点端(开发版):
|
||||||
|
```bash
|
||||||
|
curl -L https://raw.githubusercontent.com/bqlpfy/flux-panel/refs/heads/beta/install.sh -o install.sh && chmod +x install.sh && ./install.sh
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
#### 默认管理员账号
|
#### 默认管理员账号
|
||||||
|
|
||||||
@@ -55,7 +87,7 @@ curl -L https://raw.githubusercontent.com/bqlpfy/flux-panel/refs/heads/main/pane
|
|||||||
请务必在合法、合规、安全的前提下使用本项目。
|
请务必在合法、合规、安全的前提下使用本项目。
|
||||||
|
|
||||||
---
|
---
|
||||||
## ⭐ 喝杯咖啡!
|
## ⭐ 喝杯咖啡!(USDT)
|
||||||
|
|
||||||
| 网络 | 地址 |
|
| 网络 | 地址 |
|
||||||
|------------|----------------------------------------------------------------------|
|
|------------|----------------------------------------------------------------------|
|
||||||
@@ -65,4 +97,3 @@ curl -L https://raw.githubusercontent.com/bqlpfy/flux-panel/refs/heads/main/pane
|
|||||||
|
|
||||||
[](https://www.star-history.com/#bqlpfy/flux-panel&Date)
|
[](https://www.star-history.com/#bqlpfy/flux-panel&Date)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ services:
|
|||||||
retries: 10
|
retries: 10
|
||||||
|
|
||||||
backend:
|
backend:
|
||||||
image: bqlpfy/springboot-backend:1.4.2
|
image: bqlpfy/springboot-backend:1.4.3
|
||||||
container_name: springboot-backend
|
container_name: springboot-backend
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
@@ -54,7 +54,7 @@ services:
|
|||||||
start_period: 90s
|
start_period: 90s
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
image: bqlpfy/vite-frontend:1.4.2
|
image: bqlpfy/vite-frontend:1.4.3
|
||||||
container_name: vite-frontend
|
container_name: vite-frontend
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ services:
|
|||||||
retries: 10
|
retries: 10
|
||||||
|
|
||||||
backend:
|
backend:
|
||||||
image: bqlpfy/springboot-backend:1.4.2
|
image: bqlpfy/springboot-backend:1.4.3
|
||||||
container_name: springboot-backend
|
container_name: springboot-backend
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
@@ -54,7 +54,7 @@ services:
|
|||||||
start_period: 90s
|
start_period: 90s
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
image: bqlpfy/vite-frontend:1.4.2
|
image: bqlpfy/vite-frontend:1.4.3
|
||||||
container_name: vite-frontend
|
container_name: vite-frontend
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
+1
-1
@@ -119,7 +119,7 @@ func main() {
|
|||||||
log := xlogger.NewLogger()
|
log := xlogger.NewLogger()
|
||||||
logger.SetDefault(log)
|
logger.SetDefault(log)
|
||||||
|
|
||||||
wsReporter := socket.StartWebSocketReporterWithConfig(config.Addr, config.Secret, config.Http, config.Tls, config.Socks, "1.2.3")
|
wsReporter := socket.StartWebSocketReporterWithConfig(config.Addr, config.Secret, config.Http, config.Tls, config.Socks, "1.2.4")
|
||||||
defer wsReporter.Stop()
|
defer wsReporter.Stop()
|
||||||
service.SetHTTPReportURL(config.Addr, config.Secret)
|
service.SetHTTPReportURL(config.Addr, config.Secret)
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-gost/x/config"
|
"github.com/go-gost/x/config"
|
||||||
"github.com/go-gost/x/service"
|
|
||||||
"github.com/go-gost/x/internal/util/crypto"
|
"github.com/go-gost/x/internal/util/crypto"
|
||||||
|
"github.com/go-gost/x/service"
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"github.com/shirou/gopsutil/v3/cpu"
|
"github.com/shirou/gopsutil/v3/cpu"
|
||||||
"github.com/shirou/gopsutil/v3/host"
|
"github.com/shirou/gopsutil/v3/host"
|
||||||
@@ -87,6 +87,9 @@ type TcpPingResponse struct {
|
|||||||
|
|
||||||
type WebSocketReporter struct {
|
type WebSocketReporter struct {
|
||||||
url string
|
url string
|
||||||
|
addr string // 保存服务器地址
|
||||||
|
secret string // 保存密钥
|
||||||
|
version string // 保存版本号
|
||||||
conn *websocket.Conn
|
conn *websocket.Conn
|
||||||
reconnectTime time.Duration
|
reconnectTime time.Duration
|
||||||
pingInterval time.Duration
|
pingInterval time.Duration
|
||||||
@@ -195,7 +198,25 @@ func (w *WebSocketReporter) connect() error {
|
|||||||
w.connecting = false
|
w.connecting = false
|
||||||
}()
|
}()
|
||||||
|
|
||||||
u, err := url.Parse(w.url)
|
// 重新读取 config.json 获取最新的协议配置
|
||||||
|
type LocalConfig struct {
|
||||||
|
Addr string `json:"addr"`
|
||||||
|
Secret string `json:"secret"`
|
||||||
|
Http int `json:"http"`
|
||||||
|
Tls int `json:"tls"`
|
||||||
|
Socks int `json:"socks"`
|
||||||
|
}
|
||||||
|
|
||||||
|
var cfg LocalConfig
|
||||||
|
if b, err := os.ReadFile("config.json"); err == nil {
|
||||||
|
json.Unmarshal(b, &cfg)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 使用最新的配置重新构建 URL
|
||||||
|
currentURL := "ws://" + w.addr + "/system-info?type=1&secret=" + w.secret + "&version=" + w.version +
|
||||||
|
"&http=" + strconv.Itoa(cfg.Http) + "&tls=" + strconv.Itoa(cfg.Tls) + "&socks=" + strconv.Itoa(cfg.Socks)
|
||||||
|
|
||||||
|
u, err := url.Parse(currentURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("解析URL失败: %v", err)
|
return fmt.Errorf("解析URL失败: %v", err)
|
||||||
}
|
}
|
||||||
@@ -225,7 +246,7 @@ func (w *WebSocketReporter) connect() error {
|
|||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
fmt.Printf("✅ WebSocket连接建立成功\n")
|
fmt.Printf("✅ WebSocket连接建立成功 (http=%d, tls=%d, socks=%d)\n", cfg.Http, cfg.Tls, cfg.Socks)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -775,81 +796,81 @@ func (w *WebSocketReporter) handleDeleteLimiter(data interface{}) error {
|
|||||||
|
|
||||||
// handleSetProtocol 处理设置屏蔽协议的命令
|
// handleSetProtocol 处理设置屏蔽协议的命令
|
||||||
func (w *WebSocketReporter) handleSetProtocol(data interface{}) error {
|
func (w *WebSocketReporter) handleSetProtocol(data interface{}) error {
|
||||||
jsonData, err := json.Marshal(data)
|
jsonData, err := json.Marshal(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("序列化协议设置失败: %v", err)
|
return fmt.Errorf("序列化协议设置失败: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 支持 {"http":0/1, "tls":0/1, "socks":0/1}
|
// 支持 {"http":0/1, "tls":0/1, "socks":0/1}
|
||||||
var req struct {
|
var req struct {
|
||||||
HTTP *int `json:"http"`
|
HTTP *int `json:"http"`
|
||||||
TLS *int `json:"tls"`
|
TLS *int `json:"tls"`
|
||||||
SOCKS *int `json:"socks"`
|
SOCKS *int `json:"socks"`
|
||||||
}
|
}
|
||||||
if err := json.Unmarshal(jsonData, &req); err != nil {
|
if err := json.Unmarshal(jsonData, &req); err != nil {
|
||||||
return fmt.Errorf("解析协议设置失败: %v", err)
|
return fmt.Errorf("解析协议设置失败: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 读取当前值作为默认
|
// 读取当前值作为默认
|
||||||
httpVal, tlsVal, socksVal := 0, 0, 0
|
httpVal, tlsVal, socksVal := 0, 0, 0
|
||||||
|
|
||||||
if req.HTTP != nil {
|
if req.HTTP != nil {
|
||||||
if *req.HTTP != 0 && *req.HTTP != 1 {
|
if *req.HTTP != 0 && *req.HTTP != 1 {
|
||||||
return fmt.Errorf("http 取值必须为0或1")
|
return fmt.Errorf("http 取值必须为0或1")
|
||||||
}
|
}
|
||||||
httpVal = *req.HTTP
|
httpVal = *req.HTTP
|
||||||
}
|
}
|
||||||
if req.TLS != nil {
|
if req.TLS != nil {
|
||||||
if *req.TLS != 0 && *req.TLS != 1 {
|
if *req.TLS != 0 && *req.TLS != 1 {
|
||||||
return fmt.Errorf("tls 取值必须为0或1")
|
return fmt.Errorf("tls 取值必须为0或1")
|
||||||
}
|
}
|
||||||
tlsVal = *req.TLS
|
tlsVal = *req.TLS
|
||||||
}
|
}
|
||||||
if req.SOCKS != nil {
|
if req.SOCKS != nil {
|
||||||
if *req.SOCKS != 0 && *req.SOCKS != 1 {
|
if *req.SOCKS != 0 && *req.SOCKS != 1 {
|
||||||
return fmt.Errorf("socks 取值必须为0或1")
|
return fmt.Errorf("socks 取值必须为0或1")
|
||||||
}
|
}
|
||||||
socksVal = *req.SOCKS
|
socksVal = *req.SOCKS
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置至 service,全量传递(未提供的值沿用0)
|
// 设置至 service,全量传递(未提供的值沿用0)
|
||||||
service.SetProtocolBlock(httpVal, tlsVal, socksVal)
|
service.SetProtocolBlock(httpVal, tlsVal, socksVal)
|
||||||
|
|
||||||
// 同步写入本地 config.json
|
// 同步写入本地 config.json
|
||||||
if err := updateLocalConfigJSON(httpVal, tlsVal, socksVal); err != nil {
|
if err := updateLocalConfigJSON(httpVal, tlsVal, socksVal); err != nil {
|
||||||
return fmt.Errorf("写入config.json失败: %v", err)
|
return fmt.Errorf("写入config.json失败: %v", err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// updateLocalConfigJSON 将 http/tls/socks 写入工作目录下的 config.json
|
// updateLocalConfigJSON 将 http/tls/socks 写入工作目录下的 config.json
|
||||||
func updateLocalConfigJSON(httpVal int, tlsVal int, socksVal int) error {
|
func updateLocalConfigJSON(httpVal int, tlsVal int, socksVal int) error {
|
||||||
path := "config.json"
|
path := "config.json"
|
||||||
|
|
||||||
// 读取现有配置
|
// 读取现有配置
|
||||||
type LocalConfig struct {
|
type LocalConfig struct {
|
||||||
Addr string `json:"addr"`
|
Addr string `json:"addr"`
|
||||||
Secret string `json:"secret"`
|
Secret string `json:"secret"`
|
||||||
Http int `json:"http"`
|
Http int `json:"http"`
|
||||||
Tls int `json:"tls"`
|
Tls int `json:"tls"`
|
||||||
Socks int `json:"socks"`
|
Socks int `json:"socks"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var cfg LocalConfig
|
var cfg LocalConfig
|
||||||
if b, err := os.ReadFile(path); err == nil {
|
if b, err := os.ReadFile(path); err == nil {
|
||||||
_ = json.Unmarshal(b, &cfg)
|
_ = json.Unmarshal(b, &cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg.Http = httpVal
|
cfg.Http = httpVal
|
||||||
cfg.Tls = tlsVal
|
cfg.Tls = tlsVal
|
||||||
cfg.Socks = socksVal
|
cfg.Socks = socksVal
|
||||||
|
|
||||||
// 写回
|
// 写回
|
||||||
data, err := json.MarshalIndent(cfg, "", " ")
|
data, err := json.MarshalIndent(cfg, "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return os.WriteFile(path, data, 0644)
|
return os.WriteFile(path, data, 0644)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleCall 处理服务端的call回调消息
|
// handleCall 处理服务端的call回调消息
|
||||||
@@ -1021,12 +1042,16 @@ func getMemoryInfo() MemoryInfo {
|
|||||||
// StartWebSocketReporterWithConfig 使用配置字段启动WebSocket报告器
|
// StartWebSocketReporterWithConfig 使用配置字段启动WebSocket报告器
|
||||||
func StartWebSocketReporterWithConfig(addr string, secret string, http int, tls int, socks int, version string) *WebSocketReporter {
|
func StartWebSocketReporterWithConfig(addr string, secret string, http int, tls int, socks int, version string) *WebSocketReporter {
|
||||||
|
|
||||||
// 构建包含本机IP的WebSocket URL
|
// 构建初始 WebSocket URL
|
||||||
fullURL := "ws://" + addr + "/system-info?type=1&secret=" + secret + "&version=" + version + "&http=" + strconv.Itoa(http) + "&tls=" + strconv.Itoa(tls) + "&socks=" + strconv.Itoa(socks)
|
fullURL := "ws://" + addr + "/system-info?type=1&secret=" + secret + "&version=" + version + "&http=" + strconv.Itoa(http) + "&tls=" + strconv.Itoa(tls) + "&socks=" + strconv.Itoa(socks)
|
||||||
|
|
||||||
fmt.Printf("🔗 WebSocket连接URL: %s\n", fullURL)
|
fmt.Printf("🔗 WebSocket连接URL: %s\n", fullURL)
|
||||||
|
|
||||||
reporter := NewWebSocketReporter(fullURL, secret)
|
reporter := NewWebSocketReporter(fullURL, secret)
|
||||||
|
// 保存 addr, secret, version 供重连时使用
|
||||||
|
reporter.addr = addr
|
||||||
|
reporter.secret = secret
|
||||||
|
reporter.version = version
|
||||||
reporter.Start()
|
reporter.Start()
|
||||||
return reporter
|
return reporter
|
||||||
}
|
}
|
||||||
@@ -1107,6 +1132,32 @@ func tcpPingHost(ip string, port int, count int, timeoutMs int) (float64, float6
|
|||||||
|
|
||||||
fmt.Printf("🔍 开始TCP ping测试: %s,次数: %d,超时: %dms\n", target, count, timeoutMs)
|
fmt.Printf("🔍 开始TCP ping测试: %s,次数: %d,超时: %dms\n", target, count, timeoutMs)
|
||||||
|
|
||||||
|
// 如果是域名,先解析一次DNS,避免每次连接都重新解析导致延迟累加
|
||||||
|
if net.ParseIP(ip) == nil {
|
||||||
|
// 是域名,需要解析
|
||||||
|
fmt.Printf("🔍 检测到域名,正在解析DNS...\n")
|
||||||
|
dnsStart := time.Now()
|
||||||
|
|
||||||
|
addrs, err := net.LookupHost(ip)
|
||||||
|
dnsDuration := time.Since(dnsStart)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return 0, 100.0, fmt.Errorf("DNS解析失败: %v", err)
|
||||||
|
}
|
||||||
|
if len(addrs) == 0 {
|
||||||
|
return 0, 100.0, fmt.Errorf("DNS解析未返回任何IP地址")
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("✅ DNS解析完成 (%.2fms),解析到 %d 个IP: %v\n",
|
||||||
|
dnsDuration.Seconds()*1000, len(addrs), addrs)
|
||||||
|
|
||||||
|
// 使用第一个解析到的IP进行测试
|
||||||
|
target = net.JoinHostPort(addrs[0], fmt.Sprintf("%d", port))
|
||||||
|
fmt.Printf("🎯 使用IP地址进行测试: %s\n", target)
|
||||||
|
} else {
|
||||||
|
fmt.Printf("🎯 使用IP地址进行测试: %s\n", target)
|
||||||
|
}
|
||||||
|
|
||||||
for i := 0; i < count; i++ {
|
for i := 0; i < count; i++ {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# 下载地址
|
# 下载地址
|
||||||
DOWNLOAD_URL="https://github.com/bqlpfy/flux-panel/releases/download/1.4.2/gost"
|
DOWNLOAD_URL="https://github.com/bqlpfy/flux-panel/releases/download/1.4.3/gost"
|
||||||
INSTALL_DIR="/etc/gost"
|
INSTALL_DIR="/etc/gost"
|
||||||
COUNTRY=$(curl -s https://ipinfo.io/country)
|
COUNTRY=$(curl -s https://ipinfo.io/country)
|
||||||
if [ "$COUNTRY" = "CN" ]; then
|
if [ "$COUNTRY" = "CN" ]; then
|
||||||
|
|||||||
+3
-3
@@ -8,9 +8,9 @@ export LC_ALL=C
|
|||||||
|
|
||||||
|
|
||||||
# 全局下载地址配置
|
# 全局下载地址配置
|
||||||
DOCKER_COMPOSEV4_URL="https://github.com/bqlpfy/flux-panel/releases/download/1.4.2/docker-compose-v4.yml"
|
DOCKER_COMPOSEV4_URL="https://github.com/bqlpfy/flux-panel/releases/download/1.4.3/docker-compose-v4.yml"
|
||||||
DOCKER_COMPOSEV6_URL="https://github.com/bqlpfy/flux-panel/releases/download/1.4.2/docker-compose-v6.yml"
|
DOCKER_COMPOSEV6_URL="https://github.com/bqlpfy/flux-panel/releases/download/1.4.3/docker-compose-v6.yml"
|
||||||
GOST_SQL_URL="https://github.com/bqlpfy/flux-panel/releases/download/1.4.2/gost.sql"
|
GOST_SQL_URL="https://github.com/bqlpfy/flux-panel/releases/download/1.4.3/gost.sql"
|
||||||
|
|
||||||
COUNTRY=$(curl -s https://ipinfo.io/country)
|
COUNTRY=$(curl -s https://ipinfo.io/country)
|
||||||
if [ "$COUNTRY" = "CN" ]; then
|
if [ "$COUNTRY" = "CN" ]; then
|
||||||
|
|||||||
@@ -363,7 +363,7 @@ public class NodeServiceImpl extends ServiceImpl<NodeMapper, Node> implements No
|
|||||||
StringBuilder command = new StringBuilder();
|
StringBuilder command = new StringBuilder();
|
||||||
|
|
||||||
// 第一部分:下载安装脚本
|
// 第一部分:下载安装脚本
|
||||||
command.append("curl -L https://github.com/bqlpfy/flux-panel/releases/download/1.4.2/install.sh")
|
command.append("curl -L https://github.com/bqlpfy/flux-panel/releases/download/1.4.3/install.sh")
|
||||||
.append(" -o ./install.sh && chmod +x ./install.sh && ");
|
.append(" -o ./install.sh && chmod +x ./install.sh && ");
|
||||||
|
|
||||||
// 处理服务器地址,如果是IPv6需要添加方括号
|
// 处理服务器地址,如果是IPv6需要添加方括号
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ export type SiteConfig = typeof siteConfig;
|
|||||||
|
|
||||||
// 缓存相关常量
|
// 缓存相关常量
|
||||||
const CACHE_PREFIX = 'vite_config_';
|
const CACHE_PREFIX = 'vite_config_';
|
||||||
const VERSION = "1.4.2";
|
const VERSION = "1.4.3";
|
||||||
const APP_VERSION = "1.0.3";
|
const APP_VERSION = "1.0.3";
|
||||||
|
|
||||||
const getInitialConfig = () => {
|
const getInitialConfig = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user