11 Commits
v2.1.0 ... v3

Author SHA1 Message Date
Anonymous275
d545bd7078 - version change 3.0
- protocol version 2.0
2023-12-02 21:21:02 +00:00
Anonymous275
84111d36c1 - remove debug line 2023-12-02 16:10:42 +00:00
Anonymous275
b09c9f4c7a - add backend proxy
- fix crash bug
2023-12-02 16:09:42 +00:00
Anonymous275
dd3d1494c6 edits 2023-12-02 14:53:54 +00:00
Anonymous275
56574bb483 remove submodule 2023-12-02 14:52:39 +00:00
Anonymous275
2f2127121f remove submodule 2023-12-02 14:49:47 +00:00
Anonymous275
5847375447 add vcpkg entry 2023-12-01 16:19:28 +00:00
Anonymous275
da9e32f15f remove submodule 2023-12-01 16:17:08 +00:00
KK-Simon
5027bd9fa6 remove submodule 2023-12-01 16:10:46 +00:00
Anonymous-275
409a2501e9 v2.1.1 2023-10-02 20:33:04 +01:00
Anonymous-275
ce4e651af9 - MP.Core -> mp_core
- MP.Game -> mp_game
- MP.try_pop -> mp_try_pop
- MP.open_url -> mp_open_url
2023-10-02 20:32:32 +01:00
16 changed files with 107 additions and 149 deletions

View File

@@ -18,9 +18,9 @@ jobs:
uses: lukka/run-vcpkg@v7
id: runvcpkg
with:
vcpkgArguments: 'zlib discord-rpc nlohmann-json openssl minhook'
vcpkgArguments: 'zlib discord-rpc nlohmann-json openssl minhook cpp-httplib tomlplusplus easyloggingpp[no-defaultfile]'
vcpkgDirectory: '${{ runner.workspace }}/b/vcpkg'
vcpkgGitCommitId: '06b5f4a769d848d1a20fa0acd556019728b56273'
vcpkgGitCommitId: '16ee2ecb31788c336ace8bb14c21801efb6836e4'
vcpkgTriplet: 'x64-windows-static'
- name: Create Build Environment

View File

@@ -1,72 +0,0 @@
name: Release Create & Build
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
env:
BUILD_TYPE: Release
jobs:
create-release:
runs-on: ubuntu-latest
name: Create Release
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
body: |
Files included in this release:
- `BeamMP-Launcher.exe` windows build
upload-release-files-windows:
name: Upload Windows Release Files
runs-on: windows-latest
needs: create-release
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Restore artifacts, or run vcpkg, build and cache artifacts
uses: lukka/run-vcpkg@main
id: runvcpkg
with:
vcpkgArguments: 'zlib discord-rpc nlohmann-json openssl minhook'
vcpkgDirectory: '${{ runner.workspace }}/b/vcpkg'
vcpkgGitCommitId: '06b5f4a769d848d1a20fa0acd556019728b56273'
vcpkgTriplet: 'x64-windows-static'
- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/build-windows
- name: Configure CMake
shell: bash
working-directory: ${{github.workspace}}/build-windows
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_TOOLCHAIN_FILE='${{ runner.workspace }}/b/vcpkg/scripts/buildsystems/vcpkg.cmake' -DVCPKG_TARGET_TRIPLET=x64-windows-static
- name: Build
working-directory: ${{github.workspace}}/build-windows
shell: bash
run: cmake --build . --config $BUILD_TYPE --target BeamMP-Launcher
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ${{github.workspace}}/build-windows/Release/BeamMP-Launcher.exe
asset_name: BeamMP-Launcher.exe
asset_content_type: application/vnd.microsoft.portable-executable

12
.gitmodules vendored
View File

@@ -1,12 +0,0 @@
[submodule "wxWidgets"]
path = include/wxWidgets
url = https://github.com/wxWidgets/wxWidgets.git
[submodule "include/cpp-httplib"]
path = include/cpp-httplib
url = https://github.com/yhirose/cpp-httplib.git
[submodule "include/tomlplusplus"]
path = include/tomlplusplus
url = https://github.com/marzer/tomlplusplus.git
[submodule "include/easyloggingpp"]
path = include/easyloggingpp
url = https://github.com/amrayn/easyloggingpp.git

View File

@@ -1,16 +1,14 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.5)
project(BeamMP-Launcher)
set(CMAKE_CXX_STANDARD 20)
if (WIN32)
message(STATUS "MSVC -> forcing use of statically-linked runtime.")
STRING(REPLACE "/MD" "/MT /MP" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
STRING(REPLACE "/MD" "/MT /MP" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
STRING(REPLACE "/MDd" "/MTd /MP" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
STRING(REPLACE "/MDd" "/MTd /MP" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
find_package(ZLIB REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(minhook CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
#-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static
set(VcpkgRoot ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET})
include_directories(${VcpkgRoot}/include)
@@ -18,15 +16,17 @@ if (WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUNICODE")
endif(WIN32)
add_subdirectory(include/cpp-httplib)
add_subdirectory(include/tomlplusplus)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
find_package(ZLIB REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(minhook CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
find_package(httplib CONFIG REQUIRED)
add_executable(${PROJECT_NAME}
src/main.cpp include/easyloggingpp/src/easylogging++.cc
src/main.cpp
src/Launcher.cpp include/Launcher.h include/Memory/Hook.h
src/Memory/Definitions.cpp include/Memory/Definitions.h
src/Memory/Memory.cpp include/Memory/Memory.h include/Memory/Patterns.h
@@ -46,17 +46,18 @@ add_executable(${PROJECT_NAME}
if (WIN32)
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
target_link_libraries(${PROJECT_NAME} PRIVATE discord-rpc)
target_link_libraries(${PROJECT_NAME} PRIVATE discord-rpc easyloggingpp)
else ()
target_link_libraries(${PROJECT_NAME} PRIVATE ${VcpkgRoot}/debug/lib/easyloggingpp.lib)
endif()
target_link_libraries(${PROJECT_NAME} PRIVATE
ZLIB::ZLIB OpenSSL::SSL OpenSSL::Crypto ws2_32
Dbghelp comsuppw minhook::minhook nlohmann_json nlohmann_json::nlohmann_json)
Dbghelp comsuppw minhook::minhook nlohmann_json httplib::httplib)
else(WIN32) #MINGW
add_definitions("-D_WIN32_WINNT=0x0600")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os -s --static")
target_link_libraries(${PROJECT_NAME} discord-rpc ssl crypto ws2_32 ssp crypt32 z
Dbghelp comsuppw minhook::minhook nlohmann_json nlohmann_json::nlohmann_json)
endif(WIN32)
add_definitions(-DELPP_NO_DEFAULT_LOG_FILE)
target_include_directories(${PROJECT_NAME} PRIVATE "include")
target_include_directories(${PROJECT_NAME} PRIVATE "include/atomic_queue/include")

View File

@@ -4,6 +4,8 @@
///
#pragma once
#define CPPHTTPLIB_OPENSSL_SUPPORT
#include <httplib.h>
#include <filesystem>
#include <thread>
#include "Memory/IPC.h"
@@ -37,6 +39,7 @@ class Launcher {
void UpdateCheck();
void WaitForGame();
void LaunchGame();
void StartProxy();
void CheckKey();
void SetupMOD();
@@ -52,6 +55,7 @@ class Launcher {
const std::string& getPublicKey();
const std::string& getUserRole();
const std::string& getVersion();
const std::string& getProtocolVersion();
static bool getExit() noexcept;
private: // functions
@@ -69,8 +73,9 @@ class Launcher {
public: // variables
static inline std::thread EntryThread{};
static inline std::string Version{"2.1"};
static inline std::string Version{"3.0"};
static inline std::string FullVersion{Version + ".0"};
static inline std::string ProtocolVersion{"2.0"};
private: // variables
uint32_t GamePID{0};
@@ -86,12 +91,15 @@ class Launcher {
std::string UserRole{};
std::string PublicKey{};
std::thread IPCSystem{};
std::thread BackendProxy{};
std::thread DiscordRPC{};
std::string ConnectURI{};
std::string BeamVersion{};
std::string DiscordMessage{};
Server ServerHandler{this};
std::string TargetBuild{"default"};
httplib::Server HTTPProxy;
int ProxyPort{0};
static inline std::atomic<bool> Shutdown{false}, Exit{false};
std::unique_ptr<IPC> IPCToGame{};

View File

@@ -4,7 +4,7 @@
///
#pragma once
#include <easyloggingpp/src/easylogging++.h>
#include <easylogging++.h>
#undef min
#undef max
class Log {

View File

@@ -40,8 +40,8 @@ namespace GELuaTable {
}
inline void InsertFunction(lua_State* L, const char* name,
lua_CFunction func) {
BeginEntry(L, name);
//BeginEntry(L, name);
GELua::lua_pushcclosure(L, func, 0);
EndEntry(L);
End(L, name);
}
}

View File

@@ -4,7 +4,7 @@
///
#include <tomlplusplus/toml.hpp>
#include <toml++/toml.hpp>
#include "Launcher.h"
#include "Logger.h"
#include <shlguid.h>

View File

@@ -24,40 +24,46 @@ LONG WINAPI CrashHandler(EXCEPTION_POINTERS* p) {
Launcher::Launcher(int argc, char* argv[]) :
CurrentPath(fs::current_path()),
DiscordMessage("Just launched") {
Log::Init();
Shutdown.store(false);
Exit.store(false);
Launcher::StaticAbort(this);
DiscordTime = std::time(nullptr);
WindowsInit();
SetUnhandledExceptionFilter(CrashHandler);
LOG(INFO) << "Starting Launcher v" << FullVersion;
try {
Log::Init();
Shutdown.store(false);
Exit.store(false);
Launcher::StaticAbort(this);
DiscordTime = std::time(nullptr);
WindowsInit();
SetUnhandledExceptionFilter(CrashHandler);
LOG(INFO) << "Starting Launcher v" << FullVersion;
BackendProxy = std::thread(&Launcher::StartProxy, this);
fs::path config_path(CurrentPath / "Launcher.toml");
fs::path config_path(CurrentPath / "Launcher.toml");
std::string arg, arg2;
if(argc > 2) {
arg = argv[1];
arg2 = argv[2];
} else if (argc > 1) {
arg = argv[1];
}
if (arg.starts_with('0')) {
LOG(INFO) << "Debug param in effect";
DebugMode = true;
Memory::DebugMode = true;
} else if (arg2.starts_with("beammp://")) {
CurrentPath = arg;
config_path = CurrentPath / "Launcher.toml";
if (arg2.starts_with("beammp://connect/")) {
std::string arg, arg2;
if(argc > 2) {
arg = argv[1];
arg2 = argv[2];
} else if (argc > 1) {
arg = argv[1];
}
if (arg.starts_with('0')) {
LOG(INFO) << "Debug param in effect";
DebugMode = true;
Memory::DebugMode = true;
} else if (arg2.starts_with("beammp://")) {
CurrentPath = arg;
config_path = CurrentPath / "Launcher.toml";
if (arg2.starts_with("beammp://connect/")) {
ConnectURI = arg2.substr(17);
}
} else if (!arg.empty()) {
config_path = CurrentPath / arg;
}
}
} else if (!arg.empty()) {
config_path = CurrentPath / arg;
}
LoadConfig(config_path);
LauncherCache = CurrentPath/"Resources";
LoadConfig(config_path);
LauncherCache = CurrentPath/"Resources";
} catch (const ShutdownException& e) {
Abort();
throw ShutdownException(e.what());
}
}
void Launcher::Abort() {
@@ -69,6 +75,10 @@ void Launcher::Abort() {
if (IPCSystem.joinable()) {
IPCSystem.join();
}
HTTPProxy.stop();
if (BackendProxy.joinable()) {
BackendProxy.join();
}
if (!MPUserPath.empty()) {
ResetMods();
}
@@ -203,6 +213,30 @@ void Launcher::WaitForGame() {
GamePID = 0;
}
void Launcher::StartProxy() {
HTTPProxy.Get("/:any", [](const httplib::Request& req, httplib::Response& res) {
httplib::Client cli("https://backend.beammp.com");
if (auto cli_res = cli.Get(req.path); cli_res) {
res.set_content(cli_res->body,cli_res->get_header_value("Content-Type"));
} else {
res.set_content(to_string(cli_res.error()), "text/plain");
}
});
HTTPProxy.Post("/:any", [](const httplib::Request& req, httplib::Response& res) {
httplib::Client cli("https://backend.beammp.com");
if (auto cli_res = cli.Post(req.path, req.body, req.get_header_value("Content-Type")); cli_res) {
res.set_content(cli_res->body,cli_res->get_header_value("Content-Type"));
} else {
res.set_content(to_string(cli_res.error()), "text/plain");
}
});
ProxyPort = HTTPProxy.bind_to_any_port("0.0.0.0");
LOG(INFO) << "HTTP Proxy running on port " << ProxyPort;
HTTPProxy.listen_after_bind();
}
void Launcher::ListenIPC() {
while (!Shutdown.load()) {
IPCFromGame->receive();
@@ -242,6 +276,10 @@ const std::string& Launcher::getFullVersion() {
return FullVersion;
}
const std::string& Launcher::getProtocolVersion() {
return ProtocolVersion;
}
const std::string& Launcher::getVersion() {
return Version;
}

View File

@@ -109,12 +109,12 @@ int LuaOpenURL(lua_State* L) {
void BeamNG::RegisterGEFunctions() {
Memory::Print("Registering GE Functions");
GELuaTable::Begin(GELua::State);
GELuaTable::InsertFunction(GELua::State, "Core", Core);
GELuaTable::InsertFunction(GELua::State, "Game", Game);
GELuaTable::InsertFunction(GELua::State, "try_pop", LuaPop);
GELuaTable::InsertFunction(GELua::State, "open_url", LuaOpenURL);
GELuaTable::End(GELua::State, "MP");
//GELuaTable::Begin(GELua::State);
GELuaTable::InsertFunction(GELua::State, "mp_core", Core);
GELuaTable::InsertFunction(GELua::State, "mp_game", Game);
GELuaTable::InsertFunction(GELua::State, "mp_try_pop", LuaPop);
GELuaTable::InsertFunction(GELua::State, "mp_open_url", LuaOpenURL);
//GELuaTable::End(GELua::State, "MP");
Memory::Print("Registered!");
}

View File

@@ -2,9 +2,8 @@
/// Created by Anonymous275 on 1/17/22
/// Copyright (c) 2021-present Anonymous275 read the LICENSE file for more info.
///
#define CPPHTTPLIB_OPENSSL_SUPPORT
#include "HttpAPI.h"
#include <cpp-httplib/httplib.h>
#include <cmath>
#include <fstream>
#include <iostream>

View File

@@ -45,7 +45,7 @@ void Server::Abort() {
}
std::string Server::Auth() {
TCPSend("VC" + LauncherInstance->getVersion());
TCPSend("VC" + LauncherInstance->getProtocolVersion());
auto Res = TCPRcv();