mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-19 05:30:06 +08:00
refactor: hardcode srslist as byte array
This commit is contained in:
parent
84f935c3d1
commit
16788baa87
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@ -159,6 +159,7 @@ jobs:
|
|||||||
export CMAKE_PREFIX_PATH=$PWD/qt6/build/lib/cmake
|
export CMAKE_PREFIX_PATH=$PWD/qt6/build/lib/cmake
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
|
curl -fLso srslist.h "https://raw.githubusercontent.com/throneproj/routeprofiles/rule-set/srslist.h"
|
||||||
cmake -GNinja -DCMAKE_CXX_FLAGS="-static" -DCMAKE_BUILD_TYPE=Debug ..
|
cmake -GNinja -DCMAKE_CXX_FLAGS="-static" -DCMAKE_BUILD_TYPE=Debug ..
|
||||||
ninja -j2
|
ninja -j2
|
||||||
cd ..
|
cd ..
|
||||||
@ -175,6 +176,7 @@ jobs:
|
|||||||
export OPENSSL_ROOT_DIR=$PWD/openssl
|
export OPENSSL_ROOT_DIR=$PWD/openssl
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
|
curl -fLso srslist.h "https://raw.githubusercontent.com/throneproj/routeprofiles/rule-set/srslist.h"
|
||||||
cmake -GNinja -DCMAKE_CXX_FLAGS="-static" -DCMAKE_BUILD_TYPE=Debug ..
|
cmake -GNinja -DCMAKE_CXX_FLAGS="-static" -DCMAKE_BUILD_TYPE=Debug ..
|
||||||
ninja -j2
|
ninja -j2
|
||||||
cd ..
|
cd ..
|
||||||
@ -193,6 +195,7 @@ jobs:
|
|||||||
sudo apt update && sudo apt upgrade -y
|
sudo apt update && sudo apt upgrade -y
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
|
curl -fLso srslist.h "https://raw.githubusercontent.com/throneproj/routeprofiles/rule-set/srslist.h"
|
||||||
cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXE_LINKER_FLAGS="-static-libgcc -static-libstdc++" ..
|
cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXE_LINKER_FLAGS="-static-libgcc -static-libstdc++" ..
|
||||||
ninja
|
ninja
|
||||||
cd ..
|
cd ..
|
||||||
@ -203,6 +206,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
|
curl -fLso srslist.h "https://raw.githubusercontent.com/throneproj/routeprofiles/rule-set/srslist.h"
|
||||||
cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DNKR_PACKAGE_MACOS=1 -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DCMAKE_OSX_ARCHITECTURES=${{ matrix.target }} ..
|
cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DNKR_PACKAGE_MACOS=1 -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DCMAKE_OSX_ARCHITECTURES=${{ matrix.target }} ..
|
||||||
ninja
|
ninja
|
||||||
cd ..
|
cd ..
|
||||||
|
|||||||
@ -20,9 +20,6 @@ cp $BUILD/Throne $DEST
|
|||||||
#### copy Throne.png ####
|
#### copy Throne.png ####
|
||||||
cp ./res/public/Throne.png $DEST
|
cp ./res/public/Throne.png $DEST
|
||||||
|
|
||||||
#### download srslist ####
|
|
||||||
curl -fLso $DEST/srslist "https://raw.githubusercontent.com/throneproj/routeprofiles/rule-set/list"
|
|
||||||
|
|
||||||
cd download-artifact
|
cd download-artifact
|
||||||
cd *linux-$ARCH
|
cd *linux-$ARCH
|
||||||
tar xvzf artifacts.tgz -C ../../
|
tar xvzf artifacts.tgz -C ../../
|
||||||
|
|||||||
@ -20,9 +20,6 @@ cd ../..
|
|||||||
|
|
||||||
mv deployment/macos-$ARCH/* $BUILD/Throne.app/Contents/MacOS
|
mv deployment/macos-$ARCH/* $BUILD/Throne.app/Contents/MacOS
|
||||||
|
|
||||||
#### download srslist ####
|
|
||||||
curl -fLso $BUILD/Throne.app/Contents/MacOS/srslist "https://raw.githubusercontent.com/throneproj/routeprofiles/rule-set/list"
|
|
||||||
|
|
||||||
#### deploy qt & DLL runtime => .app ####
|
#### deploy qt & DLL runtime => .app ####
|
||||||
pushd $BUILD
|
pushd $BUILD
|
||||||
macdeployqt Throne.app -verbose=3
|
macdeployqt Throne.app -verbose=3
|
||||||
|
|||||||
@ -28,9 +28,6 @@ cd ..
|
|||||||
rm tmp.exe
|
rm tmp.exe
|
||||||
mv Throne.pdb $DEST
|
mv Throne.pdb $DEST
|
||||||
|
|
||||||
#### download srslist ####
|
|
||||||
curl -fLso $DEST/srslist "https://raw.githubusercontent.com/throneproj/routeprofiles/rule-set/list"
|
|
||||||
|
|
||||||
#### copy exe ####
|
#### copy exe ####
|
||||||
cp $BUILD/Throne.exe $DEST
|
cp $BUILD/Throne.exe $DEST
|
||||||
|
|
||||||
|
|||||||
@ -57,6 +57,8 @@
|
|||||||
|
|
||||||
#include "include/sys/macos/MacOS.h"
|
#include "include/sys/macos/MacOS.h"
|
||||||
|
|
||||||
|
#include <srslist.h>
|
||||||
|
|
||||||
void UI_InitMainWindow() {
|
void UI_InitMainWindow() {
|
||||||
mainwindow = new MainWindow;
|
mainwindow = new MainWindow;
|
||||||
}
|
}
|
||||||
@ -426,36 +428,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
auto srslist = QFile(QApplication::applicationDirPath() + "/srslist");
|
std::vector<uint8_t> srsvec(std::begin(srslist), std::end(srslist));
|
||||||
if (srslist.exists()) {
|
ruleSetMap = spb::pb::deserialize<libcore::RuleSet>(srsvec).items;
|
||||||
if (srslist.open(QIODevice::ReadOnly)) {
|
|
||||||
QByteArray byteArray = srslist.readAll();
|
|
||||||
srslist.close();
|
|
||||||
std::vector<uint8_t> srsvec;
|
|
||||||
srsvec.assign(byteArray.begin(), byteArray.end());
|
|
||||||
ruleSetMap = spb::pb::deserialize<libcore::RuleSet>(srsvec).items;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
auto getRuleSet = [=,this]
|
|
||||||
{
|
|
||||||
QString err;
|
|
||||||
for(int retry = 0; retry < 5; retry++) {
|
|
||||||
auto resp = NetworkRequestHelper::HttpGet(Configs::get_jsdelivr_link("https://raw.githubusercontent.com/throneproj/routeprofiles/rule-set/list"));
|
|
||||||
if (resp.error.isEmpty()) {
|
|
||||||
std::vector<uint8_t> respvec;
|
|
||||||
respvec.assign(resp.data.begin(), resp.data.end());
|
|
||||||
auto reply = spb::pb::deserialize<libcore::RuleSet>(respvec);
|
|
||||||
ruleSetMap = reply.items;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
err = resp.error;
|
|
||||||
QThread::sleep(30);
|
|
||||||
}
|
|
||||||
MW_show_log(QObject::tr("Requesting rule-set list error: %1").arg(err));
|
|
||||||
};
|
|
||||||
runOnNewThread(getRuleSet);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto getRemoteRouteProfiles = [=,this]
|
auto getRemoteRouteProfiles = [=,this]
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user