update build

This commit is contained in:
arm64v8a
2022-12-25 09:26:44 +09:00
parent 647f20cb95
commit 255d95ef98
23 changed files with 101 additions and 138 deletions

View File

@@ -9,6 +9,9 @@ on:
publish:
description: 'Publish: If want ignore'
required: false
artifact-pack:
description: 'artifact-pack: If want ignore'
required: false
jobs:
build-go:
strategy:
@@ -16,8 +19,8 @@ jobs:
cross_os: [ windows, linux, darwin ]
cross_arch: [ amd64 ]
include:
- cross_os: asset
cross_arch: asset
- cross_os: public_res
cross_arch: public_res
fail-fast: false
runs-on: ubuntu-latest
steps:
@@ -40,10 +43,10 @@ jobs:
if: steps.cache-common.outputs.cache-hit != 'true'
shell: bash
run: |
[ ${{ matrix.cross_os }} == asset ] || ./libs/get_source.sh
[ ${{ matrix.cross_os }} == asset ] || GOOS=${{ matrix.cross_os }} GOARCH=${{ matrix.cross_arch }} ./libs/build_go.sh
[ ${{ matrix.cross_os }} == asset ] || exit 0
./libs/build_asset.sh
[ ${{ matrix.cross_os }} == public_res ] || ./libs/get_source.sh
[ ${{ matrix.cross_os }} == public_res ] || GOOS=${{ matrix.cross_os }} GOARCH=${{ matrix.cross_arch }} ./libs/build_go.sh
[ ${{ matrix.cross_os }} == public_res ] || exit 0
./libs/build_public_res.sh
- name: Tar files
if: steps.cache-common.outputs.cache-hit != 'true'
run: tar czvf artifacts.tgz ./deployment
@@ -166,7 +169,8 @@ jobs:
name: NekoRay-${{ github.sha }}-${{ matrix.platform }}-${{ matrix.arch }}
path: artifacts.tgz
publish:
name: Publish Release
name: Pack & Publish Release
if: github.event.inputs.artifact-pack != 'y'
runs-on: ubuntu-latest
needs:
- build-cpp
@@ -185,9 +189,9 @@ jobs:
mv ghr*linux_amd64/ghr .
find . -name artifacts.tgz | xargs -n1 tar xvzf
cd deployment
cp -r assets/* linux64
cp -r assets/* windows64
rm -rf assets *.pdb
cp -r public_res/* linux64
cp -r public_res/* windows64
rm -rf public_res *.pdb
####
mv linux64 nekoray
zip -r $version_standalone-linux64.zip nekoray

View File

@@ -5,12 +5,12 @@ if (WIN32)
include(cmake/fuck_windows/generate_product_version.cmake)
generate_product_version(
QV2RAY_RC
NAME "Nekoray"
BUNDLE "Nekoray Project Family"
ICON "${CMAKE_SOURCE_DIR}/res/nekoray.ico"
COMPANY_NAME "Nekoray Workgroup"
COMPANY_COPYRIGHT "Nekoray Workgroup"
FILE_DESCRIPTION "Nekoray Main Application"
NAME "nekoray"
BUNDLE "nekoray"
COMPANY_NAME "nekoray"
COMPANY_COPYRIGHT "nekoray"
FILE_DESCRIPTION "nekoray"
)
add_definitions(-DUNICODE -D_UNICODE -DNOMINMAX)
set(GUI_TYPE WIN32)

View File

@@ -1,18 +1,18 @@
在 Linux 下编译 Nekoray
### git clone 源码
## git clone 源码
```
git clone https://github.com/MatsuriDayo/nekoray.git --recursive
```
### 简单编译法
## 简单编译法
条件:
1. C++ 依赖:`protobuf yaml-cpp zxing-cpp` 已用包管理器安装,并符合版本要求
1. C++ 依赖:`protobuf yaml-cpp zxing-cpp` 已用包管理器安装,并符合版本要求
2. 已安装 `qtbase` `qtsvg` `qttools` `qtx11extras`
3. Qt 版本必须大于等于 5.15
3. 已安装 Qt `5.12.x``5.15.x`
4. 系统为 `x86-64-linux-gnu`
```shell
@@ -26,37 +26,43 @@ ninja
解压 Release 的压缩包,替换其中的 `nekoray`,删除 `launcher` 即可使用。
### 复杂编译法
## 复杂编译法
#### CMake 参数
### CMake 参数
| CMake 参数 | 默认值 | 含义 |
|------------------|-----|-------------------------|
| QT_VERSION_MAJOR | 5 | QT版本 |
| NKR_NO_EXTERNAL | | 不包含外部C++依赖(以下所有) |
| NKR_NO_YAML | | 不包含yaml-cpp |
| NKR_NO_QHOTKEY | | 不包含qhotkey |
| NKR_NO_ZXING | | 不包含zxing |
| NKR_NO_GRPC | | 不包含gRPC |
| NKR_NO_QUICKJS | | 不包含quickjs |
| CMake 参数 | 默认值 | 含义 |
|-------------------|-------------------|-----------------------|
| QT_VERSION_MAJOR | 5 | QT版本 |
| NKR_NO_EXTERNAL | | 不包含外部 C/C++ 依赖 (以下所有) |
| NKR_NO_YAML | | 不包含 yaml-cpp |
| NKR_NO_QHOTKEY | | 不包含 qhotkey |
| NKR_NO_ZXING | | 不包含 zxing |
| NKR_NO_GRPC | | 不包含 gRPC |
| NKR_NO_QUICKJS | | 不包含 quickjs |
| NKR_PACKAGE | | 编译 package 版本 (aur) |
| NKR_PACKAGE_MACOS | | 编译 macos 版本 |
| NKR_LIBS | ./libs/deps/built | 依赖搜索目录 |
| NKR_DISABLE_LIBS | | 禁用 NKR_LIBS |
#### C++ 部分
1. `NKR_LIBS` 的值会被追加到 `CMAKE_PREFIX_PATH`
2. `NKR_PACKAGE` 打开后,`NKR_LIBS` 的默认值为 `./libs/deps/package` ,具体依赖请看 `build_deps_all.sh`
3. `NKR_PACKAGE_MACOS``NKR_PACKAGE` 打开后,应用将使用 appdata 目录存放配置,自动更新等功能将被禁用。
当您的发行版没有上面几个 C++ 依赖包,或者版本不符合要求时,可以参考 libs 文件夹内的默认编译脚本自行编译。
### C++ 部分
依赖搜寻 prefix 为 `libs/deps/bulit`
当您的发行版没有上面几个 C++ 依赖包,或者版本不符合要求时,可以参考 `build_deps_all.sh` 编译脚本自行编译。
条件:
条件: 已安装 Qt `5.12.x``5.15.x`
1. Qt 版本必须大于等于 5.15
#### 编译安装 C/C++ 依赖
首先编译安装C++依赖(这一步可能要挂梯)
(这一步可能要挂梯)
```shell
./libs/build_deps_all.sh
```
然后编译本体
#### 编译本体
```shell
mkdir build
@@ -67,7 +73,7 @@ ninja
编译完成后得到 `nekoray`
#### Go 部分
### Go 部分
1.`Matsuridayo/Matsuri` `Matsuridayo/v2ray-core` 置于 `../`
2. 进入 `go/cmd/nekoray_core` 文件夹 `go build` 得到 `nekoray_core`

View File

@@ -16,23 +16,39 @@ git clone https://github.com/MatsuriDayo/nekoray.git --recursive
### 下载 Qt SDK
目前使用的版本是 Qt 5.15.7 其他版本未测试
目前使用的版本是 Qt 5.15.x
暂时不建议使用 Qt 6.x
下载解压后,将 bin 目录添加到环境变量。
#### Qt 5.15.7 MSVC2019 x86_64
https://github.com/MatsuriDayo/nekoray_qt_runtime/releases/download/20220503/Qt5.15.7-Windows-x86_64-VS2019-16.11.20-20221103.7z
#### 官方签名版 Qt 5.15.2 可选已知有内存泄漏的BUG
在此下载 `qtbase` `qtsvg` `qttools` 的包并解压到同一个目录。
https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/qt5_5152/qt.qt5.5152.win64_msvc2019_64/
将 bin 目录添加到环境变量。
### C++ 部分编译
首先编译安装C++依赖(这一步可能要挂梯)
#### 编译安装 C/C++ 依赖
(这一步可能要挂梯)
```shell
bash ./libs/build_deps_all.sh
```
然后编译本体(根据你的 QT Sdk 的位置替换命令)
目前只有 bash 脚本,没有批处理或 powershell如果 Windows 没有带 bash 建议自行安装。
CMake 参数等细节与 Linux 大同小异,有问题可以参照 Build_Linux 文档。
#### 编译本体
请根据你的 QT Sdk 的位置替换命令
```shell
mkdir build

1
examples/.gitignore vendored
View File

@@ -1 +0,0 @@
tun2socks

View File

@@ -1,5 +0,0 @@
alpine 3.16
all use package
apk add git cmake g++ ninja zxing-cpp-dev yaml-cpp-dev grpc-dev protobuf-dev qt5-qtbase-dev qt5-qtsvg-dev qt5-qttools-dev qt5-qtx11extras-dev c-ares-dev re2-dev

View File

@@ -1,30 +0,0 @@
#!/bin/sh
set -e
set -x
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit
fi
# add netns
ip netns add nekoray
# ip netns exec nekoray readlink /proc/self/ns/net
# add lo: lo is not shared
ip -n nekoray addr add 127.0.0.1/8 dev lo
ip -n nekoray link set dev lo up
# add tun
ip -n nekoray tuntap add tun0 user $USERID mode tun
ip -n nekoray addr add 26.0.0.1/30 dev tun0
ip -n nekoray link set dev tun0 up
ip -n nekoray route add default dev tun0
# set veth to use the socks port
ip link add dev nekoray-ve1 type veth peer name nekoray-ve2
ip addr add 26.1.0.1/30 dev nekoray-ve1
ip link set nekoray-ve1 up
ip link set nekoray-ve2 netns nekoray
ip -n nekoray addr add 26.1.0.2/30 dev nekoray-ve2
ip -n nekoray link set nekoray-ve2 up

View File

@@ -1,13 +0,0 @@
#!/bin/sh
set -e
set -x
BASEDIR=$(dirname "$0")
# netns
[ -f /var/run/netns/nekoray ] || pkexec env USERID=`id -u` sh -c "cd $PWD && $BASEDIR/netns-root.sh" || true
# run xjasonlyu/tun2socks to provide vpn
firejail --noprofile --netns=nekoray ./tun2socks -device tun0 -proxy socks5://26.1.0.1:2080 -interface nekoray-ve2 -drop-multicast
# use "firejail --noprofile --netns=nekoray ..." to run your program in VPN

View File

@@ -1,9 +0,0 @@
Linux Only
此处为配置 VPN 的脚本,仅供参考,使用时要按实际情况替换某些参数(如 socks 端口)
vpn.sh 配置全局 VPN
ctrl-c 退出后自动删除 VPN
vpn-netns.sh 配置 netns
分应用代理,用法参考脚本内容

View File

@@ -1,14 +0,0 @@
#!/bin/sh
set -e
set -x
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
killall nekoray_core || true
cp nekoray_core /opt/nekoray_core
cp geo* /opt/
setcap cap_net_admin+ep /opt/nekoray_core
ln -sf /opt/nekoray_core nekoray_core_cap

View File

@@ -3,9 +3,17 @@ set -e
cd libs
# 参数
if [ -z $cmake ]; then
cmake="cmake"
fi
if [ -z $deps ]; then
deps="deps"
fi
# libs/deps/...
mkdir -p deps
cd deps
mkdir -p $deps
cd $deps
if [ -z $NKR_PACKAGE ]; then
INSTALL_PREFIX=$PWD/built
else
@@ -27,7 +35,7 @@ cd zxing-*
mkdir -p build
cd build
cmake .. -GNinja -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_EXAMPLES=OFF -DBUILD_BLACKBOX_TESTS=OFF -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX
$cmake .. -GNinja -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_EXAMPLES=OFF -DBUILD_BLACKBOX_TESTS=OFF -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX
ninja && ninja install
cd ../..
@@ -46,7 +54,7 @@ cd yaml-*
mkdir -p build
cd build
cmake .. -GNinja -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX
$cmake .. -GNinja -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX
ninja && ninja install
cd ../..
@@ -59,7 +67,7 @@ git clone --recurse-submodules -b v21.4 --depth 1 --shallow-submodules https://g
mkdir -p protobuf/build
cd protobuf/build
cmake .. -GNinja \
$cmake .. -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-Dprotobuf_MSVC_STATIC_RUNTIME=OFF \

View File

@@ -2,15 +2,15 @@
set -e
source libs/deploy_common.sh
DEST=$DEPLOYMENT/assets
DEST=$DEPLOYMENT/public_res
rm -rf $DEST
mkdir -p $DEST
#### Download: geoip ####
#### Download geodata ####
curl -Lso $DEST/geoip.dat "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat"
curl -Lso $DEST/geosite.dat "https://github.com/v2fly/domain-list-community/releases/latest/download/dlc.dat"
curl -Lso $DEST/geoip.db "https://github.com/SagerNet/sing-geoip/releases/latest/download/geoip.db"
curl -Lso $DEST/geosite.db "https://github.com/SagerNet/sing-geosite/releases/latest/download/geosite.db"
#### copy assets ####
cp assets/* $DEST
#### copy res/public ####
cp res/public/* $DEST

View File

@@ -12,10 +12,10 @@ DEST=$DEPLOYMENT/macos-$ARCH
rm -rf $DEST
mkdir -p $DEST
#### copy golang & asset => .app ####
#### copy golang & public_res => .app ####
pushd download-artifact
find . -name artifacts.tgz | xargs -n1 tar xvzf
mv deployment/assets/* deployment/macos-$ARCH
mv deployment/public_res/* deployment/macos-$ARCH
mv deployment/macos-$ARCH/* $BUILD/nekoray.app/Contents/MacOS
popd

View File

@@ -57,7 +57,7 @@ int main(int argc, char *argv[]) {
if (args.contains("-tray")) NekoRay::dataStore->flag_tray = true;
if (args.contains("-debug")) NekoRay::dataStore->flag_debug = true;
#ifdef NKR_CPP_USE_APPDATA
NekoRay::dataStore->flag_use_appdata = true;
NekoRay::dataStore->flag_use_appdata = true; // Example: Package & MacOS
#endif
#ifdef NKR_CPP_DEBUG
NekoRay::dataStore->flag_debug = true;

View File

@@ -8,10 +8,10 @@
<file alias="icon/b-system-software-update.svg">icon/system-software-update.svg</file>
</qresource>
<qresource prefix="/neko">
<file alias="nekobox.png">../assets/nekobox.png</file>
<file alias="nekoray.png">../assets/nekoray.png</file>
<file alias="nekobox.png">public/nekobox.png</file>
<file alias="nekoray.png">public/nekoray.png</file>
<file>neko.css</file>
<file alias="vpn/vpn-run-root.sh">../examples/vpn-run-root.sh</file>
<file alias="vpn/sing-box-vpn.json">../examples/sing-box-vpn.json</file>
<file>vpn/vpn-run-root.sh</file>
<file>vpn/sing-box-vpn.json</file>
</qresource>
</RCC>

View File

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 63 KiB

View File

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 60 KiB

View File

@@ -550,7 +550,7 @@ void MainWindow::on_menu_exit_triggered() {
//
NekoRay::dataStore->core_prepare_exit = true;
hide();
ExitNekorayCore();
stop_core_daemon();
//
MF_release_runguard();
if (exit_reason == 1) {
@@ -1394,7 +1394,7 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
auto mouseEvent = dynamic_cast<QMouseEvent *>(event);
if (obj == ui->label_running && mouseEvent->button() == Qt::LeftButton && running != nullptr) {
test_current();
speedtest_current();
return true;
} else if (obj == ui->label_inbound && mouseEvent->button() == Qt::LeftButton) {
on_menu_basic_settings_triggered();

View File

@@ -173,13 +173,13 @@ private:
// grpc and ...
static void ExitNekorayCore();
void setup_grpc();
void speedtest_current_group(int mode);
void test_current();
void speedtest_current();
void setup_grpc();
static void stop_core_daemon();
void CheckUpdate();

View File

@@ -157,7 +157,7 @@ void MainWindow::speedtest_current_group(int mode) {
#endif
}
void MainWindow::test_current() {
void MainWindow::speedtest_current() {
#ifndef NKR_NO_GRPC
last_test_time = QTime::currentTime();
ui->label_running->setText(tr("Testing"));
@@ -186,7 +186,7 @@ void MainWindow::test_current() {
#endif
}
void MainWindow::ExitNekorayCore() {
void MainWindow::stop_core_daemon() {
#ifndef NKR_NO_GRPC
NekoRay::rpc::defaultClient->Exit();
#endif
@@ -287,6 +287,7 @@ void MainWindow::neko_stop(bool crash) {
}
void MainWindow::CheckUpdate() {
// on new thread...
#ifndef NKR_NO_GRPC
bool ok;
libcore::UpdateReq request;