Compare commits
3 Commits
90b1f221ea
...
9577ac844d
Author | SHA1 | Date | |
---|---|---|---|
9577ac844d | |||
ed0bfce64d | |||
8da8c054bf |
2
dependencies/control_system/CMakeLists.txt
vendored
2
dependencies/control_system/CMakeLists.txt
vendored
@ -14,7 +14,7 @@ include(CheckCXXCompilerFlag)
|
||||
set(CMAKE_CXX_FLAGS -fPIC)
|
||||
|
||||
set(default_build_type "Release")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-ggdb -O0 -fprofile-arcs -ftest-coverage")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -s -DNDEBUG ")
|
||||
message(${CMAKE_CXX_FLAGS})
|
||||
|
@ -98,9 +98,9 @@ namespace http::auth {
|
||||
~AuthRequiredResource() override;
|
||||
|
||||
private:
|
||||
uint32_t perms;
|
||||
resource::respGenerator generator_;
|
||||
AuthProvider& provider_;
|
||||
resource::respGenerator generator_;
|
||||
uint32_t perms;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,8 @@ namespace http::server {
|
||||
}
|
||||
|
||||
void Connection::start() {
|
||||
request_parser_.reset();
|
||||
request_.reset();
|
||||
doRead();
|
||||
}
|
||||
|
||||
@ -23,9 +25,6 @@ namespace http::server {
|
||||
Connection::~Connection() = default;
|
||||
|
||||
void Connection::doRead() {
|
||||
request_parser_.reset();
|
||||
request_.reset();
|
||||
|
||||
auto self(shared_from_this());
|
||||
socket_.async_read_some(boost::asio::buffer(buffer_), [this, self](boost::system::error_code ec, std::size_t bytes_transferred) {
|
||||
if (!ec) {
|
||||
@ -38,6 +37,7 @@ namespace http::server {
|
||||
doWrite();
|
||||
} else if (result == RequestParser::bad) {
|
||||
stockReply(bad_request, reply_);
|
||||
needClose = true;
|
||||
doWrite();
|
||||
} else {
|
||||
doRead();
|
||||
@ -59,8 +59,10 @@ namespace http::server {
|
||||
|
||||
auto self(shared_from_this());
|
||||
async_write(socket_, reply_.to_buffers(), [this, self](boost::system::error_code ec, std::size_t) {
|
||||
if (!ec) {
|
||||
if (!ec && !needClose) {
|
||||
// keep alive Connection
|
||||
request_parser_.reset();
|
||||
request_.reset();
|
||||
doRead();
|
||||
} else {
|
||||
connection_manager_.stop(shared_from_this());
|
||||
@ -74,6 +76,8 @@ namespace http::server {
|
||||
|
||||
void SslConnection::start() {
|
||||
get_lowest_layer(stream_).expires_after(std::chrono::seconds(30));
|
||||
request_parser_.reset();
|
||||
request_.reset();
|
||||
|
||||
// Perform the SSL handshake
|
||||
stream_.async_handshake(boost::asio::ssl::stream_base::server, boost::beast::bind_front_handler([this](auto ec) {
|
||||
@ -83,6 +87,7 @@ namespace http::server {
|
||||
}
|
||||
|
||||
void SslConnection::stop() {
|
||||
stream_.shutdown();
|
||||
}
|
||||
|
||||
SslConnection::~SslConnection() = default;
|
||||
@ -90,9 +95,6 @@ namespace http::server {
|
||||
void SslConnection::doRead() {
|
||||
get_lowest_layer(stream_).expires_after(std::chrono::seconds(30));
|
||||
|
||||
request_parser_.reset();
|
||||
request_.reset();
|
||||
|
||||
auto self(shared_from_this());
|
||||
stream_.async_read_some(boost::asio::buffer(buffer_), [this, self](boost::system::error_code ec, std::size_t bytes_transferred) {
|
||||
if (!ec) {
|
||||
@ -105,6 +107,7 @@ namespace http::server {
|
||||
doWrite();
|
||||
} else if (result == RequestParser::bad) {
|
||||
stockReply(bad_request, reply_);
|
||||
needClose = true;
|
||||
doWrite();
|
||||
} else {
|
||||
doRead();
|
||||
@ -126,8 +129,10 @@ namespace http::server {
|
||||
|
||||
auto self(shared_from_this());
|
||||
async_write(stream_, reply_.to_buffers(), [this, self](boost::system::error_code ec, std::size_t) {
|
||||
if (!ec) {
|
||||
if (!ec && !needClose) {
|
||||
// keep alive Connection
|
||||
request_parser_.reset();
|
||||
request_.reset();
|
||||
doRead();
|
||||
} else {
|
||||
connection_manager_.stop(shared_from_this());
|
||||
|
@ -72,6 +72,8 @@ namespace http::server {
|
||||
|
||||
/// The reply to be sent back to the client.
|
||||
Reply reply_;
|
||||
|
||||
bool needClose = false;
|
||||
};
|
||||
|
||||
class SslConnection final : public ConnectionBase, public std::enable_shared_from_this<SslConnection> {
|
||||
@ -114,6 +116,8 @@ namespace http::server {
|
||||
|
||||
/// The reply to be sent back to the client.
|
||||
Reply reply_;
|
||||
|
||||
bool needClose = false;
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<ConnectionBase> connection_ptr;
|
||||
|
@ -1,11 +1,31 @@
|
||||
#include "request_parser.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "request.hpp"
|
||||
|
||||
|
||||
namespace http::server {
|
||||
constexpr int HTTP_MAX_HEADERS = 64;
|
||||
|
||||
/**
|
||||
* Функция, позволяющая или запрещающая выделение размера тела для запросов.
|
||||
* @return true, если тело удовлетворяет размерам
|
||||
*/
|
||||
static bool requestBodySizeResolver(Request& req, size_t reqSize) {
|
||||
// разрешаем тело только для POST запросов
|
||||
if (req.method != "POST") {
|
||||
return false;
|
||||
}
|
||||
|
||||
// для обновления прошивки разрешаем большое тело
|
||||
if (req.url->path == "/api/firmwareUpdate") {
|
||||
return reqSize <= HTTP_MAX_PAYLOAD;
|
||||
}
|
||||
|
||||
return reqSize < 0x4000; // 16кб на все POST-запросы к API будет более чем достаточно
|
||||
}
|
||||
|
||||
static void parseParams(Url& u, const std::string& query) {
|
||||
std::istringstream iss(query);
|
||||
std::string param;
|
||||
@ -72,7 +92,7 @@ namespace http::server {
|
||||
switch (state_) {
|
||||
case expecting_payload:
|
||||
req.payload.push_back(input);
|
||||
if (req.payload.size() <= contentLenghtHeader - 1) {
|
||||
if (req.payload.size() < contentLenghtHeader) {
|
||||
return indeterminate;
|
||||
}
|
||||
return good;
|
||||
@ -186,17 +206,23 @@ namespace http::server {
|
||||
if (input == '\r') {
|
||||
state_ = expecting_newline_3;
|
||||
return indeterminate;
|
||||
} else if (!req.headers.empty() && (input == ' ' || input == '\t')) {
|
||||
}
|
||||
if (!req.headers.empty() && (input == ' ' || input == '\t')) {
|
||||
state_ = header_lws;
|
||||
return indeterminate;
|
||||
} else if (!is_char(input) || is_ctl(input) || is_tspecial(input)) {
|
||||
}
|
||||
if (!is_char(input) || is_ctl(input) || is_tspecial(input)) {
|
||||
return bad;
|
||||
} else {
|
||||
}
|
||||
|
||||
if (req.headers.size() > HTTP_MAX_HEADERS) {
|
||||
return bad;
|
||||
}
|
||||
req.headers.emplace_back();
|
||||
req.headers.back().name.push_back(input);
|
||||
state_ = header_name;
|
||||
return indeterminate;
|
||||
}
|
||||
|
||||
case header_lws:
|
||||
if (input == '\r') {
|
||||
state_ = expecting_newline_2;
|
||||
@ -255,12 +281,11 @@ namespace http::server {
|
||||
if (contentLenghtHeader == 0) {
|
||||
return good;
|
||||
}
|
||||
if (requestBodySizeResolver(req, contentLenghtHeader)) {
|
||||
state_ = expecting_payload;
|
||||
if (contentLenghtHeader > HTTP_MAX_PAYLOAD) {
|
||||
return bad;
|
||||
}
|
||||
return indeterminate;
|
||||
}
|
||||
}
|
||||
return bad;
|
||||
|
||||
default:
|
||||
|
@ -25,12 +25,17 @@ static void loadFile(const std::string& path, std::vector<char>& content) {
|
||||
http::resource::BasicResource::BasicResource(std::string path): path(std::move(path)) {}
|
||||
|
||||
http::resource::StaticFileFactory::StaticFileDef::StaticFileDef(std::string path, server::mime_types::Mime type, bool allowCache): path(std::move(path)), type(type), allowCache(allowCache) {
|
||||
#ifdef USE_DEBUG
|
||||
if (allowCache) {
|
||||
BOOST_LOG_TRIVIAL(info) << "Load static file " << this->path;
|
||||
loadFile(this->path, this->content);
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(info) << "Skip loading static file " << this->path;
|
||||
}
|
||||
#else
|
||||
BOOST_LOG_TRIVIAL(info) << "Load static file " << this->path;
|
||||
loadFile(this->path, this->content);
|
||||
#endif
|
||||
}
|
||||
http::resource::StaticFileFactory::StaticFileDef::~StaticFileDef() = default;
|
||||
|
||||
|
@ -505,17 +505,19 @@ std::string api_driver::ApiDriver::loadSettings() const {
|
||||
|
||||
result << ",\n\"buc.refClk10M\":" << boolAsStr(bucLnb.is_ref_10MHz_buc);
|
||||
switch (bucLnb.buc) {
|
||||
case voltage_buc::DISABLE: result << ",\"buc.powering\":0"; break;
|
||||
case voltage_buc::_24V: result << ",\"buc.powering\":24"; break;
|
||||
case voltage_buc::_48V: result << ",\"buc.powering\":48"; break;
|
||||
case voltage_buc::DISABLE:
|
||||
default: result << ",\"buc.powering\":0";
|
||||
}
|
||||
|
||||
result << ",\n\"lnb.refClk10M\":" << boolAsStr(bucLnb.is_ref_10MHz_lnb);
|
||||
switch (bucLnb.lnb) {
|
||||
case voltage_lnb::DISABLE: result << ",\"lnb.powering\":0"; break;
|
||||
case voltage_lnb::_13V: result << ",\"lnb.powering\":13"; break;
|
||||
case voltage_lnb::_18V: result << ",\"lnb.powering\":18"; break;
|
||||
case voltage_lnb::_24V: result << ",\"lnb.powering\":24"; break;
|
||||
case voltage_lnb::DISABLE:
|
||||
default: result << ",\"lnb.powering\":0";
|
||||
}
|
||||
|
||||
result << ",\n\"serviceSettings.refClk10M\":" << boolAsStr(bucLnb.is_ref_10MHz_output);
|
||||
|
@ -118,8 +118,8 @@
|
||||
<label>
|
||||
<span>Режим работы</span>
|
||||
<select v-model="param.general.isCinC">
|
||||
<option value="false">SCPC</option>
|
||||
<option value="true">CinC</option>
|
||||
<option :value="false">SCPC</option>
|
||||
<option :value="true">CinC</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
@ -150,8 +150,8 @@
|
||||
<label>
|
||||
<span>Входные данные</span>
|
||||
<select v-model="param.general.isTestInputData">
|
||||
<option value="false">Ethernet</option>
|
||||
<option value="true">Тест (CW)</option>
|
||||
<option :value="false">Ethernet</option>
|
||||
<option :value="true">Тест (CW)</option>
|
||||
</select>
|
||||
</label>
|
||||
<h3>Параметры передачи</h3>
|
||||
@ -166,11 +166,11 @@
|
||||
<label>
|
||||
<span>Roll-off</span>
|
||||
<select v-model="param.tx.rolloff">
|
||||
<option value="5">0.05</option>
|
||||
<option value="10">0.10</option>
|
||||
<option value="15">0.15</option>
|
||||
<option value="20">0.20</option>
|
||||
<option value="25">0.25</option>
|
||||
<option :value="5">0.05</option>
|
||||
<option :value="10">0.10</option>
|
||||
<option :value="15">0.15</option>
|
||||
<option :value="20">0.20</option>
|
||||
<option :value="25">0.25</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
@ -195,15 +195,15 @@
|
||||
<label>
|
||||
<span>Размер кадра</span>
|
||||
<select v-model="param.dvbs2.frameSizeNormal">
|
||||
<option value="true">normal</option>
|
||||
<option value="false">short</option>
|
||||
<option :value="true">normal</option>
|
||||
<option :value="false">short</option>
|
||||
</select>
|
||||
</label>
|
||||
<!-- <label>-->
|
||||
<!-- <span>Пилот-символы</span>-->
|
||||
<!-- <select v-model="param.dvbs2.isPilots">-->
|
||||
<!-- <option value="true">pilots</option>-->
|
||||
<!-- <option value="false">no pilots</option>-->
|
||||
<!-- <option :value="true">pilots</option>-->
|
||||
<!-- <option :value="false">no pilots</option>-->
|
||||
<!-- </select>-->
|
||||
<!-- </label>-->
|
||||
|
||||
@ -315,19 +315,19 @@
|
||||
<label>
|
||||
<span>Roll-off</span>
|
||||
<select v-model="param.rx.rolloff">
|
||||
<option value="5">0.05</option>
|
||||
<option value="10">0.10</option>
|
||||
<option value="15">0.15</option>
|
||||
<option value="20">0.20</option>
|
||||
<option value="25">0.25</option>
|
||||
<option :value="5">0.05</option>
|
||||
<option :value="10">0.10</option>
|
||||
<option :value="15">0.15</option>
|
||||
<option :value="20">0.20</option>
|
||||
<option :value="25">0.25</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<button class="action-button" @click="settingsSubmitRxTx()">Сохранить <span class="submit-spinner" v-show="submitStatus.rxTx"></span></button>
|
||||
|
||||
<h2 v-show="param.general.isCinC">Настройки режима CinC</h2>
|
||||
<div v-show="param.general.isCinC" class="settings-set-container">
|
||||
<h2 v-show="param.general.isCinC === true">Настройки режима CinC</h2>
|
||||
<div v-show="param.general.isCinC === true" class="settings-set-container">
|
||||
<label>
|
||||
<span>Метод расчета задержки</span>
|
||||
<select v-model="param.cinc.mode">
|
||||
@ -517,7 +517,7 @@
|
||||
</div>
|
||||
<div class="tabs-body-item" v-if="activeTab === 'admin'">
|
||||
<p>
|
||||
Эти настройки пока недоступны, но скоро разработчик это поправит. А пока смотри на крокодила, или купи разработчику банку <strike>пива</strike> колы для ускорения процесса)
|
||||
Эти настройки пока недоступны, но скоро разработчик это поправит. А пока смотри на крокодила, или купи разработчику банку <span style="text-decoration: line-through;">пива</span> колы для ускорения процесса)
|
||||
</p>
|
||||
<img loading="lazy" src="/images/krokodil_vzryvaetsya_hd.gif" alt="krokodil">
|
||||
<video preload="auto" controls style="max-width: 100%">
|
||||
@ -681,7 +681,7 @@
|
||||
const app = new Vue({
|
||||
el: '#app',
|
||||
data: {
|
||||
isCinC: null,
|
||||
isCinC: false,
|
||||
|
||||
// false - означает что статистика не отправляется, true - отправляется
|
||||
submitStatus: {
|
||||
@ -733,17 +733,17 @@
|
||||
|
||||
param: {
|
||||
general: {
|
||||
isCinC: false,
|
||||
txEn: false, // включен/выключен
|
||||
isCinC: Boolean,
|
||||
txEn: Boolean, // включен/выключен
|
||||
modulatorMode: 'normal', // режим работы модулятора
|
||||
autoStartTx: false, // было "режим работы передатчика"
|
||||
isTestInputData: false, // входные данные: eth или test
|
||||
autoStartTx: Boolean, // было "режим работы передатчика"
|
||||
isTestInputData: Boolean, // входные данные: eth или test
|
||||
},
|
||||
tx: {
|
||||
attenuation: null, // ослабление
|
||||
rolloff: null,
|
||||
cymRate: null,
|
||||
centerFreq: null,
|
||||
attenuation: Number, // ослабление
|
||||
rolloff: Number,
|
||||
cymRate: Number,
|
||||
centerFreq: Number,
|
||||
},
|
||||
dvbs2: {
|
||||
mode: null, // ccm/acm
|
||||
@ -948,12 +948,12 @@
|
||||
|
||||
let query = {
|
||||
"cinc.mode": this.param.cinc.mode,
|
||||
"cinc.searchBandwidth": parseInt(this.param.cinc.searchBandwidth),
|
||||
"cinc.position.station.latitude": parseFloat(this.param.cinc.position.station.latitude),
|
||||
"cinc.position.station.longitude": parseFloat(this.param.cinc.position.station.longitude),
|
||||
"cinc.position.satelliteLongitude": parseFloat(this.param.cinc.position.satelliteLongitude),
|
||||
"cinc.delayMin": parseInt(this.param.cinc.delayMin),
|
||||
"cinc.delayMax": parseInt(this.param.cinc.delayMax)
|
||||
"cinc.searchBandwidth": this.param.cinc.searchBandwidth,
|
||||
"cinc.position.station.latitude": this.param.cinc.position.station.latitude,
|
||||
"cinc.position.station.longitude": this.param.cinc.position.station.longitude,
|
||||
"cinc.position.satelliteLongitude": this.param.cinc.position.satelliteLongitude,
|
||||
"cinc.delayMin": this.param.cinc.delayMin,
|
||||
"cinc.delayMax": this.param.cinc.delayMax
|
||||
}
|
||||
this.submitStatus.cinc = true
|
||||
fetch('/api/set/cinc', {
|
||||
|
Loading…
x
Reference in New Issue
Block a user