This commit is contained in:
parent
30185e9ff1
commit
abea92c348
@ -4,7 +4,7 @@ ObjCBlockIndentWidth: 4
|
|||||||
IndentWidth: 4
|
IndentWidth: 4
|
||||||
TabWidth: 4
|
TabWidth: 4
|
||||||
AccessModifierOffset: -4
|
AccessModifierOffset: -4
|
||||||
ColumnLimit: 120
|
ColumnLimit: 130
|
||||||
|
|
||||||
#模板声明后换行
|
#模板声明后换行
|
||||||
AlwaysBreakTemplateDeclarations: true
|
AlwaysBreakTemplateDeclarations: true
|
||||||
|
@ -5,6 +5,7 @@ on:
|
|||||||
paths:
|
paths:
|
||||||
- '**.cpp'
|
- '**.cpp'
|
||||||
- '**.h'
|
- '**.h'
|
||||||
|
- '**.conf'
|
||||||
jobs:
|
jobs:
|
||||||
Build:
|
Build:
|
||||||
runs-on: [ubuntu-latest, ubuntu-24.04]
|
runs-on: [ubuntu-latest, ubuntu-24.04]
|
||||||
@ -59,6 +60,24 @@ jobs:
|
|||||||
cp /tmp/HttpServer /root/Server/HttpServer
|
cp /tmp/HttpServer /root/Server/HttpServer
|
||||||
nohup /root/Server/HttpServer > /dev/null 2>&1 &
|
nohup /root/Server/HttpServer > /dev/null 2>&1 &
|
||||||
exit 0
|
exit 0
|
||||||
|
- name: Copy openresty configuration files to server
|
||||||
|
uses: appleboy/scp-action@v0.1.7
|
||||||
|
with:
|
||||||
|
host: ${{ vars.YUYUN_SERVER }}
|
||||||
|
username: ${{ vars.YUYUN_USER }}
|
||||||
|
password: ${{ secrets.SERVER_ROOT_PASSWORD }}
|
||||||
|
overwrite: true
|
||||||
|
strip_components: 1
|
||||||
|
source: Server/conf
|
||||||
|
target: /root/Server
|
||||||
|
- name: Restart openresty
|
||||||
|
uses: appleboy/ssh-action@v1.1.0
|
||||||
|
with:
|
||||||
|
host: ${{ vars.YUYUN_SERVER }}
|
||||||
|
username: ${{ vars.YUYUN_USER }}
|
||||||
|
password: ${{ secrets.SERVER_ROOT_PASSWORD }}
|
||||||
|
script: |
|
||||||
|
systemctl restart openresty.service
|
||||||
- name: Notify-End
|
- name: Notify-End
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
run: |
|
run: |
|
||||||
|
@ -27,6 +27,7 @@ public:
|
|||||||
|
|
||||||
BUILD_SETTING(std::string, Server, "0.0.0.0");
|
BUILD_SETTING(std::string, Server, "0.0.0.0");
|
||||||
BUILD_SETTING(uint16_t, Port, 8081);
|
BUILD_SETTING(uint16_t, Port, 8081);
|
||||||
|
BUILD_SETTING(uint16_t, WtPort, 8082);
|
||||||
BUILD_SETTING(uint32_t, Threads, std::thread::hardware_concurrency());
|
BUILD_SETTING(uint32_t, Threads, std::thread::hardware_concurrency());
|
||||||
BUILD_SETTING(std::string, DocumentRoot, ".");
|
BUILD_SETTING(std::string, DocumentRoot, ".");
|
||||||
BUILD_SETTING(std::string, Sqlte3Path, "database.sqlite");
|
BUILD_SETTING(std::string, Sqlte3Path, "database.sqlite");
|
||||||
|
@ -15,6 +15,7 @@ types {
|
|||||||
text/vnd.wap.wml wml;
|
text/vnd.wap.wml wml;
|
||||||
text/x-component htc;
|
text/x-component htc;
|
||||||
|
|
||||||
|
image/avif avif;
|
||||||
image/png png;
|
image/png png;
|
||||||
image/svg+xml svg svgz;
|
image/svg+xml svg svgz;
|
||||||
image/tiff tif tiff;
|
image/tiff tif tiff;
|
||||||
@ -51,6 +52,7 @@ types {
|
|||||||
application/vnd.openxmlformats-officedocument.wordprocessingml.document
|
application/vnd.openxmlformats-officedocument.wordprocessingml.document
|
||||||
docx;
|
docx;
|
||||||
application/vnd.wap.wmlc wmlc;
|
application/vnd.wap.wmlc wmlc;
|
||||||
|
application/wasm wasm;
|
||||||
application/x-7z-compressed 7z;
|
application/x-7z-compressed 7z;
|
||||||
application/x-cocoa cco;
|
application/x-cocoa cco;
|
||||||
application/x-java-archive-diff jardiff;
|
application/x-java-archive-diff jardiff;
|
||||||
|
@ -15,6 +15,7 @@ types {
|
|||||||
text/vnd.wap.wml wml;
|
text/vnd.wap.wml wml;
|
||||||
text/x-component htc;
|
text/x-component htc;
|
||||||
|
|
||||||
|
image/avif avif;
|
||||||
image/png png;
|
image/png png;
|
||||||
image/svg+xml svg svgz;
|
image/svg+xml svg svgz;
|
||||||
image/tiff tif tiff;
|
image/tiff tif tiff;
|
||||||
@ -51,6 +52,7 @@ types {
|
|||||||
application/vnd.openxmlformats-officedocument.wordprocessingml.document
|
application/vnd.openxmlformats-officedocument.wordprocessingml.document
|
||||||
docx;
|
docx;
|
||||||
application/vnd.wap.wmlc wmlc;
|
application/vnd.wap.wmlc wmlc;
|
||||||
|
application/wasm wasm;
|
||||||
application/x-7z-compressed 7z;
|
application/x-7z-compressed 7z;
|
||||||
application/x-cocoa cco;
|
application/x-cocoa cco;
|
||||||
application/x-java-archive-diff jardiff;
|
application/x-java-archive-diff jardiff;
|
||||||
|
@ -26,7 +26,7 @@ http {
|
|||||||
keepalive_timeout 65;
|
keepalive_timeout 65;
|
||||||
|
|
||||||
gzip on;
|
gzip on;
|
||||||
gzip_types application/octet-stream text/markdown text/plain application/json application/x-javascript text/css application/xml text/javascript application/javascript application/x-httpd-php image/jpeg image/gif image/png;
|
gzip_types application/octet-stream text/markdown text/plain application/json application/x-javascript text/css application/xml text/javascript application/javascript application/x-httpd-php application/text image/jpeg image/gif image/png;
|
||||||
|
|
||||||
# 定义一个限流区域,名称为 one,大小为 10MB,限速为每 5 分钟 5 次请求
|
# 定义一个限流区域,名称为 one,大小为 10MB,限速为每 5 分钟 5 次请求
|
||||||
limit_req_zone $binary_remote_addr zone=one:10m rate=3r/m;
|
limit_req_zone $binary_remote_addr zone=one:10m rate=3r/m;
|
||||||
@ -36,10 +36,14 @@ http {
|
|||||||
server 127.0.0.1:8081;
|
server 127.0.0.1:8081;
|
||||||
}
|
}
|
||||||
|
|
||||||
upstream twikoo {
|
upstream wt {
|
||||||
server 127.0.0.1:8082;
|
server 127.0.0.1:8082;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
upstream twikoo {
|
||||||
|
server 127.0.0.1:8083;
|
||||||
|
}
|
||||||
|
|
||||||
upstream frp_http_proxy {
|
upstream frp_http_proxy {
|
||||||
server 127.0.0.1:8084;
|
server 127.0.0.1:8084;
|
||||||
}
|
}
|
||||||
@ -56,6 +60,10 @@ http {
|
|||||||
server 127.0.0.1:8088;
|
server 127.0.0.1:8088;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
upstream meilisearch {
|
||||||
|
server 127.0.0.1:7700;
|
||||||
|
}
|
||||||
|
|
||||||
upstream typesense {
|
upstream typesense {
|
||||||
server 127.0.0.1:8108;
|
server 127.0.0.1:8108;
|
||||||
}
|
}
|
||||||
|
@ -31,10 +31,18 @@ location ^~ /api/v1/login {
|
|||||||
content_by_lua_file lua/login.lua;
|
content_by_lua_file lua/login.lua;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
location ^~ /api/v1/search/ {
|
||||||
|
proxy_pass http://meilisearch/;
|
||||||
|
}
|
||||||
|
|
||||||
location ~ ^/api/v1/.*$ {
|
location ~ ^/api/v1/.*$ {
|
||||||
proxy_pass http://local;
|
proxy_pass http://local;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
location ~ ^/wt/.+$ {
|
||||||
|
proxy_pass http://wt;
|
||||||
|
}
|
||||||
|
|
||||||
location /freedom {
|
location /freedom {
|
||||||
if ($http_upgrade != "websocket") { # WebSocket协商失败时返回404
|
if ($http_upgrade != "websocket") { # WebSocket协商失败时返回404
|
||||||
return 404;
|
return 404;
|
||||||
@ -62,6 +70,7 @@ location ~ ^/(gitea|v2)($|/) {
|
|||||||
proxy_set_header Upgrade $http_upgrade;
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
# 这里强制修改 Host 为 gitea.amass.fun 只是为了frpc能够做url路由
|
# 这里强制修改 Host 为 gitea.amass.fun 只是为了frpc能够做url路由
|
||||||
proxy_set_header Host gitea.amass.fun;
|
proxy_set_header Host gitea.amass.fun;
|
||||||
|
# proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
@ -101,7 +101,7 @@ int main(int argc, char const *argv[]) {
|
|||||||
|
|
||||||
auto udpServer = std::make_shared<UdpServer>(application->ioContext());
|
auto udpServer = std::make_shared<UdpServer>(application->ioContext());
|
||||||
auto mediaServer = std::make_shared<MediaServer>(554, false);
|
auto mediaServer = std::make_shared<MediaServer>(554, false);
|
||||||
auto webApp = Singleton<WebApplication>::instance<Construct>();
|
auto webApp = Singleton<WebApplication>::instance<Construct>(application->getWtPort());
|
||||||
|
|
||||||
using namespace boost::asio::ip;
|
using namespace boost::asio::ip;
|
||||||
auto proxyAddress = make_address(application->getServer());
|
auto proxyAddress = make_address(application->getServer());
|
||||||
|
@ -12,14 +12,15 @@
|
|||||||
#include <Wt/Dbo/SqlConnectionPool.h>
|
#include <Wt/Dbo/SqlConnectionPool.h>
|
||||||
#include <Wt/Dbo/backend/Sqlite3.h>
|
#include <Wt/Dbo/backend/Sqlite3.h>
|
||||||
#include <Wt/WServer.h>
|
#include <Wt/WServer.h>
|
||||||
|
#include <format>
|
||||||
|
|
||||||
WebApplication::WebApplication() {
|
WebApplication::WebApplication(uint16_t port) {
|
||||||
try {
|
try {
|
||||||
std::vector<std::string> args;
|
std::vector<std::string> args;
|
||||||
args.push_back("--approot=./build");
|
args.push_back("--approot=./build");
|
||||||
args.push_back("--docroot=./build");
|
args.push_back("--docroot=./build");
|
||||||
args.push_back("--config=resources/wt_config.xml");
|
args.push_back("--config=resources/wt_config.xml");
|
||||||
args.push_back("--http-listen=127.0.0.1:8855");
|
args.push_back(std::format("--http-listen=127.0.0.1:{}", port));
|
||||||
// --docroot=. --no-compression --http-listen 127.0.0.1:8855
|
// --docroot=. --no-compression --http-listen 127.0.0.1:8855
|
||||||
initializeAuthenticationService();
|
initializeAuthenticationService();
|
||||||
|
|
||||||
@ -27,11 +28,9 @@ WebApplication::WebApplication() {
|
|||||||
m_sqlConnectionPool = createConnectionPool(m_server->appRoot() + "database.sqlite");
|
m_sqlConnectionPool = createConnectionPool(m_server->appRoot() + "database.sqlite");
|
||||||
|
|
||||||
m_server->addEntryPoint(Wt::EntryPointType::Application,
|
m_server->addEntryPoint(Wt::EntryPointType::Application,
|
||||||
std::bind(&WebApplication::createApplication, this, std::placeholders::_1, false),
|
std::bind(&WebApplication::createApplication, this, std::placeholders::_1, false), "/hello");
|
||||||
"/hello");
|
|
||||||
m_server->addEntryPoint(Wt::EntryPointType::WidgetSet,
|
m_server->addEntryPoint(Wt::EntryPointType::WidgetSet,
|
||||||
std::bind(&WebApplication::createApplication, this, std::placeholders::_1, true),
|
std::bind(&WebApplication::createApplication, this, std::placeholders::_1, true), "/wt/app.js");
|
||||||
"/wt/app.js");
|
|
||||||
m_server->addResource(std::make_shared<AuthenticationResource>(*m_sqlConnectionPool), "/auth");
|
m_server->addResource(std::make_shared<AuthenticationResource>(*m_sqlConnectionPool), "/auth");
|
||||||
m_server->addResource(std::make_shared<PlaintextResource>(), "/plaintext");
|
m_server->addResource(std::make_shared<PlaintextResource>(), "/plaintext");
|
||||||
m_server->addResource(std::make_shared<DbResource>("database.sqlite"), "/db");
|
m_server->addResource(std::make_shared<DbResource>("database.sqlite"), "/db");
|
||||||
@ -45,8 +44,7 @@ WebApplication::WebApplication() {
|
|||||||
std::unique_ptr<Wt::Dbo::SqlConnectionPool> WebApplication::createConnectionPool(const std::string &sqlite3) {
|
std::unique_ptr<Wt::Dbo::SqlConnectionPool> WebApplication::createConnectionPool(const std::string &sqlite3) {
|
||||||
auto connection = std::make_unique<Wt::Dbo::backend::Sqlite3>(sqlite3);
|
auto connection = std::make_unique<Wt::Dbo::backend::Sqlite3>(sqlite3);
|
||||||
connection->setProperty("show-queries", "true");
|
connection->setProperty("show-queries", "true");
|
||||||
connection->setDateTimeStorage(Wt::Dbo::SqlDateTimeType::DateTime,
|
connection->setDateTimeStorage(Wt::Dbo::SqlDateTimeType::DateTime, Wt::Dbo::backend::DateTimeStorage::PseudoISO8601AsText);
|
||||||
Wt::Dbo::backend::DateTimeStorage::PseudoISO8601AsText);
|
|
||||||
return std::make_unique<Wt::Dbo::FixedSqlConnectionPool>(std::move(connection), 10);
|
return std::make_unique<Wt::Dbo::FixedSqlConnectionPool>(std::move(connection), 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ public:
|
|||||||
const Wt::Auth::PasswordService &passwordService();
|
const Wt::Auth::PasswordService &passwordService();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
WebApplication();
|
WebApplication(uint16_t port);
|
||||||
static std::unique_ptr<Wt::Dbo::SqlConnectionPool> createConnectionPool(const std::string &sqlite3);
|
static std::unique_ptr<Wt::Dbo::SqlConnectionPool> createConnectionPool(const std::string &sqlite3);
|
||||||
std::unique_ptr<Wt::WApplication> createApplication(const Wt::WEnvironment &env, bool embedded);
|
std::unique_ptr<Wt::WApplication> createApplication(const Wt::WEnvironment &env, bool embedded);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user