добавил защиту от двойного обновления прошивки, добавил настройки TCP-акселерации в веб (они пока не работает из-за API)
This commit is contained in:
parent
24cb1061a7
commit
be6c8023c5
@ -105,8 +105,8 @@
|
||||
|
||||
cinc: {
|
||||
mode: null, // 'positional' | 'delay'
|
||||
searchBandwidth: 0, // полоса поиска в кГц
|
||||
position: {
|
||||
searchBandwidth: 0, // полоса поиска в кГц
|
||||
position: {
|
||||
station: {
|
||||
latitude: 0,
|
||||
longitude: 0
|
||||
|
23
src/main.cpp
23
src/main.cpp
@ -84,6 +84,8 @@ class ServerResources {
|
||||
std::unique_ptr<api_driver::ApiDriver> api;
|
||||
http::auth::AuthProvider auth{};
|
||||
|
||||
bool upgradeOrRebootRunning = false;
|
||||
|
||||
static void onUploadFirmware(const http::server::Request& req) {
|
||||
std::ofstream f("/tmp/firmware.zip", std::ios::binary);
|
||||
|
||||
@ -415,7 +417,7 @@ public:
|
||||
}
|
||||
}));
|
||||
|
||||
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/api/reboot", this->auth, 0, [](const auto& req, auto& rep) {
|
||||
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/api/reboot", this->auth, 0, [this](const auto& req, auto& rep) {
|
||||
if (req.method != "POST") {
|
||||
http::server::stockReply(http::server::bad_request, rep);
|
||||
}
|
||||
@ -424,6 +426,7 @@ public:
|
||||
rep.headers.push_back({.name = "Content-Type", .value = toString(mime_types::json)});
|
||||
const std::string result = R"({"status":"ok"})";
|
||||
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
||||
this->upgradeOrRebootRunning = true;
|
||||
system(REBOOT_COMMAND);
|
||||
}));
|
||||
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/api/resetSettings", this->auth, http::auth::User::SUPERUSER, [this](const auto& req, auto& rep) {
|
||||
@ -439,10 +442,11 @@ public:
|
||||
system(REBOOT_COMMAND);
|
||||
}));
|
||||
|
||||
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/api/firmwareUpdate", this->auth, http::auth::User::UPDATE_FIRMWARE, [](const auto& req, auto& rep) {
|
||||
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/api/firmwareUpdate", this->auth, http::auth::User::UPDATE_FIRMWARE, [this](const auto& req, auto& rep) {
|
||||
if (req.method != "PUT") {
|
||||
http::server::stockReply(http::server::bad_request, rep);
|
||||
}
|
||||
this->upgradeOrRebootRunning = true;
|
||||
onUploadFirmware(req);
|
||||
|
||||
rep.status = http::server::ok;
|
||||
@ -454,12 +458,14 @@ public:
|
||||
result += http::utils::sha256(req.payload.data(), req.payload.size());
|
||||
result += "\"}";
|
||||
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
||||
this->upgradeOrRebootRunning = false;
|
||||
}));
|
||||
|
||||
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/api/doFirmwareUpgrade", this->auth, http::auth::User::UPDATE_FIRMWARE, [this](const auto& req, auto& rep) {
|
||||
if (req.method != "POST") {
|
||||
http::server::stockReply(http::server::bad_request, rep);
|
||||
}
|
||||
this->upgradeOrRebootRunning = true;
|
||||
doTerminalUpgrade();
|
||||
rep.status = http::server::ok;
|
||||
rep.headers.clear();
|
||||
@ -467,6 +473,19 @@ public:
|
||||
const auto result = api->loadFirmwareVersion();
|
||||
rep.content.insert(rep.content.end(), result.c_str(), result.c_str() + result.size());
|
||||
}));
|
||||
|
||||
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/dev", this->auth, http::auth::User::SUPERUSER, [this](const auto& req, auto& rep) {
|
||||
boost::ignore_unused(req);
|
||||
sf->serve(INTERNET_JPG, rep);
|
||||
}));
|
||||
|
||||
s.resources.emplace_back(std::make_unique<http::auth::AuthRequiredResource>("/dev/fetchParams", this->auth, http::auth::User::SUPERUSER, [this](const auto& req, auto& rep) {
|
||||
rep.headers.push_back({.name = "Content-Type", .value = toString(mime_types::json)});
|
||||
std::string result = R"({"status":"ok","fwsize":)";
|
||||
result += std::to_string(req.payload.size());
|
||||
result += R"(,"sha256":")";
|
||||
result += "\"}";
|
||||
}));
|
||||
}
|
||||
|
||||
~ServerResources() = default;
|
||||
|
@ -540,8 +540,8 @@
|
||||
</template>
|
||||
<button class="action-button" @click="settingsSubmitQoS()">Применить <span class="submit-spinner" v-show="submitStatus.qos"></span></button>
|
||||
|
||||
<h2 hidden>Настройки TCP-акселерации</h2>
|
||||
<div hidden class="settings-set-container">
|
||||
<h2>Настройки TCP-акселерации</h2>
|
||||
<div class="settings-set-container">
|
||||
<label>
|
||||
<span>Активировать акселерацию</span>
|
||||
<span class="toggle-input"><input type="checkbox" v-model="param.tcpAccel.en" /><span class="slider"></span></span>
|
||||
@ -551,7 +551,7 @@
|
||||
<input type="number" v-model="param.tcpAccel.maxConnections" min="1" max="10000" />
|
||||
</label>
|
||||
</div>
|
||||
<button hidden class="action-button" @click="settingsSubmitTcpAccel()">Применить <span class="submit-spinner" v-show="submitStatus.tcpAccel"></span></button>
|
||||
<button class="action-button" @click="settingsSubmitTcpAccel()">Применить <span class="submit-spinner" v-show="submitStatus.tcpAccel"></span></button>
|
||||
</div>
|
||||
<div class="tabs-body-item" v-if="activeTab === 'admin' && settingFetchComplete">
|
||||
<h2>Настройки сети</h2>
|
||||
|
Loading…
x
Reference in New Issue
Block a user