mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-18 20:50:09 +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
|
||||
mkdir 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 ..
|
||||
ninja -j2
|
||||
cd ..
|
||||
@ -175,6 +176,7 @@ jobs:
|
||||
export OPENSSL_ROOT_DIR=$PWD/openssl
|
||||
mkdir 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 ..
|
||||
ninja -j2
|
||||
cd ..
|
||||
@ -193,6 +195,7 @@ jobs:
|
||||
sudo apt update && sudo apt upgrade -y
|
||||
mkdir 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++" ..
|
||||
ninja
|
||||
cd ..
|
||||
@ -203,6 +206,7 @@ jobs:
|
||||
run: |
|
||||
mkdir 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 }} ..
|
||||
ninja
|
||||
cd ..
|
||||
|
||||
@ -20,9 +20,6 @@ cp $BUILD/Throne $DEST
|
||||
#### copy Throne.png ####
|
||||
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 *linux-$ARCH
|
||||
tar xvzf artifacts.tgz -C ../../
|
||||
|
||||
@ -20,9 +20,6 @@ cd ../..
|
||||
|
||||
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 ####
|
||||
pushd $BUILD
|
||||
macdeployqt Throne.app -verbose=3
|
||||
|
||||
@ -28,9 +28,6 @@ cd ..
|
||||
rm tmp.exe
|
||||
mv Throne.pdb $DEST
|
||||
|
||||
#### download srslist ####
|
||||
curl -fLso $DEST/srslist "https://raw.githubusercontent.com/throneproj/routeprofiles/rule-set/list"
|
||||
|
||||
#### copy exe ####
|
||||
cp $BUILD/Throne.exe $DEST
|
||||
|
||||
|
||||
@ -57,6 +57,8 @@
|
||||
|
||||
#include "include/sys/macos/MacOS.h"
|
||||
|
||||
#include <srslist.h>
|
||||
|
||||
void UI_InitMainWindow() {
|
||||
mainwindow = new MainWindow;
|
||||
}
|
||||
@ -426,36 +428,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
||||
}
|
||||
});
|
||||
|
||||
auto srslist = QFile(QApplication::applicationDirPath() + "/srslist");
|
||||
if (srslist.exists()) {
|
||||
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);
|
||||
}
|
||||
std::vector<uint8_t> srsvec(std::begin(srslist), std::end(srslist));
|
||||
ruleSetMap = spb::pb::deserialize<libcore::RuleSet>(srsvec).items;
|
||||
|
||||
auto getRemoteRouteProfiles = [=,this]
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user