44 Commits

Author SHA1 Message Date
Simon Abed El Sater
3314362faf Merge pull request #48 from Mack29446/master
Decided by vote: Update BeamNG Version and remove Mod Delete warning & Delay
2022-09-25 01:18:58 +03:00
Mackenzie
e483f520db Bump launcher version
2.0.78 -> 2.0.79
2022-09-24 22:49:10 +01:00
Mackenzie
c92e32c0e1 Remove mod wipe warn and delay 2022-09-24 22:48:17 +01:00
Mackenzie
cb872f8a41 Update BeamNG Version 2022-09-24 22:46:38 +01:00
Anonymous275
0aae245054 release 2.0.78 2022-09-24 00:37:29 +03:00
Anonymous275
480a7d038f follow redirects if present 2022-09-24 00:37:04 +03:00
Anonymous275
f62f44d4c0 version 2.0.77 2022-09-20 22:27:26 +03:00
Anonymous275
e316b89fb1 bump 0.26 2022-09-20 22:26:51 +03:00
Anonymous275
3b2dbcac1b release 2.0.76 2022-09-05 03:23:15 +03:00
Anonymous275
d881c9faf6 release 2.0.75 2022-09-05 02:59:05 +03:00
Anonymous275
11d9375f36 fix invalid Key being used 2022-09-05 02:58:22 +03:00
Simon Abed El Sater
4207d7adcf Merge pull request #44 from snepsnepsnep/master
remove key if auth is unsuccessful
2022-09-05 02:40:50 +03:00
snepsnepsnep
832b1d66a0 remove key if auth is unsuccessful 2022-09-04 20:24:27 +02:00
Anonymous275
cd829f9f22 Update Startup.cpp
version 2.0.74
2022-08-12 12:14:31 +03:00
Anonymous275
f7c70eb6df Merge pull request #36 from Mack29446/master
Change serverlist request URL and Protocol
2022-08-12 12:11:22 +03:00
Mackenzie
01960f6470 Change serverlist request URL and Protocol 2022-08-11 20:27:26 +01:00
Anonymous275
f6065a1c00 Merge pull request #21 from Mack29446/master
Update version
2022-06-24 19:46:26 +03:00
Mackenzie
ba3b7f0ed0 Update version 2022-06-23 16:53:06 +01:00
Anonymous275
056eadbef2 Merge pull request #20 from Mack29446/master
Update version
2022-06-21 18:12:49 +03:00
Mackenzie
2bb2dc9040 Update version 2022-06-21 14:28:10 +01:00
Anonymous275
17553fd412 bump launcher version 2022-06-19 02:28:26 +03:00
Anonymous275
08c1c0f682 Merge pull request #19 from Mack29446/master
Update Version Number
2022-06-18 02:02:36 +03:00
Mackenzie
84959ae9c9 Update Version Number 2022-06-17 21:35:00 +01:00
Anonymous275
c90c102097 trying to fix github actions 2022-06-15 21:38:45 +03:00
Anonymous275
5b004426ce vcpkgGitCommitId update 2022-06-15 21:35:12 +03:00
Anonymous275
69c9060dd2 Update release-build.yml 2022-06-15 21:13:02 +03:00
Anonymous275
49870639ff Update cmake-windows.yml 2022-06-15 21:12:41 +03:00
Anonymous275
0843862af9 update for game version 0.25 2022-06-15 21:02:43 +03:00
Anonymous275
71a9a567bc 2.0.63 2021-12-03 18:45:36 +02:00
Anonymous275
a6e3d0fad9 Update cmake-windows.yml 2021-12-03 18:28:03 +02:00
Anonymous275
411d0786a5 0.24.0.1 game version bump 2021-12-03 18:18:57 +02:00
Anonymous-275
acb6b11e24 bump minor version to 62 2021-10-01 00:17:55 +03:00
Anonymous-275
1739393a73 launcher no longer extracts zip file 2021-10-01 00:11:46 +03:00
Anonymous-275
298ef33ab7 V2.0.61 2021-07-03 17:11:56 +03:00
Anonymous-275
d2433cceca V2.0.7 2021-07-03 17:10:55 +03:00
Anonymous-275
705e0ab9c4 Updated version to 0.23.1 2021-07-03 17:09:29 +03:00
Anonymous-275
53c40a2bc3 Removed debug prints 2021-07-01 18:54:36 +03:00
Anonymous-275
96c60ef05a 0.23.0.0 support 2021-07-01 18:54:06 +03:00
Anonymous-275
61759b8531 0.23.0.0 support 2021-07-01 18:53:50 +03:00
Anonymous-275
691be8cd08 Mod validity check 2021-06-02 00:02:50 +03:00
Anonymous-275
082445c295 updated gitignore 2021-05-23 20:04:34 +03:00
Anonymous-275
f4bda81be0 Added 'N' packet flag 2021-05-23 19:22:44 +03:00
Anonymous-275
1ad8e0b8e5 Minor edit 2021-05-11 22:32:46 +03:00
Anonymous-275
6c673e78e5 Fixed invalid string position, Bumped game version 2021-05-11 22:19:42 +03:00
16 changed files with 5786 additions and 58 deletions

View File

@@ -15,12 +15,12 @@ jobs:
submodules: 'true'
- name: Restore artifacts, or run vcpkg, build and cache artifacts
uses: lukka/run-vcpkg@main
uses: lukka/run-vcpkg@v7
id: runvcpkg
with:
vcpkgArguments: 'discord-rpc zlib rapidjson openssl'
vcpkgDirectory: '${{ runner.workspace }}/b/vcpkg'
vcpkgGitCommitId: '75522bb1f2e7d863078bcd06322348f053a9e33f'
vcpkgGitCommitId: '86ff75c6d8232b54d3ebd0e71525b4634dcd9523'
vcpkgTriplet: 'x64-windows-static'
- name: Create Build Environment

View File

@@ -44,7 +44,7 @@ jobs:
with:
vcpkgArguments: 'discord-rpc zlib rapidjson openssl'
vcpkgDirectory: '${{ runner.workspace }}/b/vcpkg'
vcpkgGitCommitId: '75522bb1f2e7d863078bcd06322348f053a9e33f'
vcpkgGitCommitId: '86ff75c6d8232b54d3ebd0e71525b4634dcd9523'
vcpkgTriplet: 'x64-windows-static'
- name: Create Build Environment

3
.gitignore vendored
View File

@@ -2,3 +2,6 @@ cmake-build-debug
cmake-build-release
/.idea/
*.log
/*.sh
/*.obj
/*.exe

View File

@@ -8,7 +8,7 @@
#pragma once
#include <string>
#include "Logger.h"
class HTTP{
class HTTP {
public:
static bool Download(const std::string &IP, const std::string &Path);
static std::string Post(const std::string& IP, const std::string& Fields);

View File

@@ -12,7 +12,8 @@
void NetReset();
extern bool Dev;
extern int ping;
void CoreNetwork();
[[noreturn]] void CoreNetwork();
extern int ClientID;
extern int LastPort;
extern bool ModLoaded;

5710
include/zip_file.h Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -15,7 +15,6 @@ void ParseConfig(const json::Document& d){
if(d["Port"].IsInt()){
DEFAULT_PORT = d["Port"].GetInt();
}
//Default -1
//Release 1
//EA 2

View File

@@ -14,16 +14,8 @@
#include <thread>
std::string getDate() {
typedef std::chrono::duration<int, std::ratio_multiply<std::chrono::hours::period, std::ratio<24>>::type> days;
std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
std::chrono::system_clock::duration tp = now.time_since_epoch();
days d = std::chrono::duration_cast<days>(tp);tp -= d;
auto h = std::chrono::duration_cast<std::chrono::hours>(tp);tp -= h;
auto m = std::chrono::duration_cast<std::chrono::minutes>(tp);tp -= m;
auto s = std::chrono::duration_cast<std::chrono::seconds>(tp);tp -= s;
time_t tt = std::chrono::system_clock::to_time_t(now);
tm local_tm{};
localtime_s(&local_tm,&tt);
time_t tt = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
tm local_tm = *localtime(&tt);
std::stringstream date;
int S = local_tm.tm_sec;
int M = local_tm.tm_min;

View File

@@ -8,7 +8,7 @@
#include "Network/network.h"
#include "Security/Init.h"
#include "http.h"
#include "Http.h"
#include <winsock2.h>
#include <ws2tcpip.h>
#include "Startup.h"
@@ -58,7 +58,7 @@ void Parse(std::string Data,SOCKET CSocket){
NetReset();
Terminate = true;
TCPTerminate = true;
Data = Code + HTTP::Post("https://backend.beammp.com/servers","");
Data = Code + HTTP::Get("https://backend.beammp.com/servers-info");
break;
case 'C':
ListOfMods.clear();
@@ -240,8 +240,8 @@ int Handle(EXCEPTION_POINTERS *ep){
}
void CoreNetwork(){
while(TraceBack >= 4){
[[noreturn]] void CoreNetwork(){
while(true) {
#ifndef __MINGW32__
__try{
#endif

View File

@@ -75,7 +75,7 @@ void ServerSend(std::string Data, bool Rel){
int DLen = int(Data.length());
if(DLen > 3)C = Data.at(0);
if (C == 'O' || C == 'T')Ack = true;
if(C == 'W' || C == 'Y' || C == 'V' || C == 'E' || C == 'C')Rel = true;
if(C == 'N' || C == 'W' || C == 'Y' || C == 'V' || C == 'E' || C == 'C')Rel = true;
if(Ack || Rel){
if(Ack || DLen > 1000)SendLarge(Data);
else TCPSend(Data,TCPSock);

View File

@@ -10,7 +10,7 @@
#include <iostream>
#include <Logger.h>
#include <fstream>
#include "http.h"
#include "Http.h"
#include <mutex>
#include <cmath>
#include <httplib.h>
@@ -31,6 +31,7 @@ std::string HTTP::Get(const std::string &IP) {
httplib::Client cli(IP.substr(0, pos).c_str());
cli.set_connection_timeout(std::chrono::seconds(10));
cli.set_follow_location(true);
auto res = cli.Get(IP.substr(pos).c_str(), ProgressBar);
std::string Ret;

View File

@@ -109,11 +109,10 @@ void UpdateUl(bool D,const std::string&msg){
void AsyncUpdate(uint64_t& Rcv,uint64_t Size,const std::string& Name){
do {
double pr = Rcv / double(Size) * 100;
double pr = double(Rcv) / double(Size) * 100;
std::string Per = std::to_string(trunc(pr * 10) / 10);
UpdateUl(true, Name + " (" + Per.substr(0, Per.find('.') + 2) + "%)");
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}while(!Terminate && Rcv < Size);
}
@@ -176,8 +175,7 @@ std::string MultiDownload(SOCKET MSock,SOCKET DSock, uint64_t Size, const std::s
uint64_t GRcv = 0, MSize = Size/2, DSize = Size - MSize;
std::thread Au(AsyncUpdate,std::ref(GRcv),Size,Name);
Au.detach();
std::thread Au(AsyncUpdate,std::ref(GRcv), Size, Name);
std::packaged_task<char*()> task([&] { return TCPRcvRaw(MSock,GRcv,MSize); });
std::future<char*> f1 = task.get_future();
@@ -198,6 +196,7 @@ std::string MultiDownload(SOCKET MSock,SOCKET DSock, uint64_t Size, const std::s
MultiKill(MSock,DSock);
return "";
}
if(Au.joinable())Au.join();
@@ -212,6 +211,11 @@ std::string MultiDownload(SOCKET MSock,SOCKET DSock, uint64_t Size, const std::s
return Ret;
}
void InvalidResource(const std::string& File){
UUl("Invalid mod \"" + File + "\"");
warn("The server tried to sync \"" + File + "\" that is not a .zip file!");
Terminate = true;
}
void SyncResources(SOCKET Sock){
std::string Ret = Auth(Sock);
@@ -238,6 +242,11 @@ void SyncResources(SOCKET Sock){
t.clear();
for(auto FN = FNames.begin(),FS = FSizes.begin(); FN != FNames.end() && !Terminate; ++FN,++FS) {
auto pos = FN->find_last_of('/');
auto ZIP = FN->find(".zip");
if (ZIP == std::string::npos || FN->length() - ZIP != 4) {
InvalidResource(*FN);
return;
}
if (pos == std::string::npos)continue;
Amount++;
}

View File

@@ -28,7 +28,7 @@ void lowExit(int code){
std::this_thread::sleep_for(std::chrono::seconds(10));
exit(2);
}
void Exit(int code){
/*void Exit(int code){
TraceBack = 0;
std::string msg =
"Sorry. We do not support cracked copies report this if you believe this is a mistake code ";
@@ -43,9 +43,9 @@ void SteamExit(int code){
error(msg+std::to_string(code));
std::this_thread::sleep_for(std::chrono::seconds(10));
exit(4);
}
}*/
std::string GetGameDir(){
if(TraceBack != 4)Exit(0);
//if(TraceBack != 4)Exit(0);
return GameDir.substr(0,GameDir.find_last_of('\\'));
}
LONG OpenKey(HKEY root,const char* path,PHKEY hKey){
@@ -244,25 +244,23 @@ std::string GetManifest(const std::string& Man){
bool IDCheck(std::string Man, std::string steam){
bool a = false,b = true;
int pos = int(Man.rfind("steamapps"));
if(pos == -1)Exit(5);
// if(pos == -1)Exit(5);
Man = Man.substr(0,pos+9) + "\\appmanifest_284160.acf";
steam += "\\config\\loginusers.vdf";
if(fs::exists(Man) && fs::exists(steam)){
for(const std::string&ID : GetID(steam)){
if(ID == GetManifest(Man))b = false;
}
if(b)Exit(6);
//if(b)Exit(6);
}else a = true;
return a;
}
void LegitimacyCheck(){
std::string Result,T;
std::string K1 = R"(Software\Valve\Steam)";
std::string K2 = R"(Software\Valve\Steam\Apps\284160)";
std::string K3 = R"(Software\BeamNG\BeamNG.drive)";
HKEY hKey;
LONG dwRegOPenKey = OpenKey(HKEY_CURRENT_USER, K1.c_str(), &hKey);
//std::string K1 = R"(Software\Valve\Steam)";
//std::string K2 = R"(Software\Valve\Steam\Apps\284160)";
/*LONG dwRegOPenKey = OpenKey(HKEY_CURRENT_USER, K1.c_str(), &hKey);
if(dwRegOPenKey == ERROR_SUCCESS) {
Result = QueryKey(hKey, 1);
@@ -287,19 +285,22 @@ void LegitimacyCheck(){
TraceBack++;
}else lowExit(2);
K2.clear();
RegCloseKey(hKey);
dwRegOPenKey = OpenKey(HKEY_CURRENT_USER, K3.c_str(), &hKey);
RegCloseKey(hKey);*/
std::string Result;
std::string K3 = R"(Software\BeamNG\BeamNG.drive)";
HKEY hKey;
LONG dwRegOPenKey = OpenKey(HKEY_CURRENT_USER, K3.c_str(), &hKey);
if(dwRegOPenKey == ERROR_SUCCESS) {
Result = QueryKey(hKey, 3);
if(Result.empty())lowExit(3);
if(IDCheck(Result,T))lowExit(5);
//if(IDCheck(Result,T))lowExit(5);
GameDir = Result;
TraceBack++;
//TraceBack++;
}else lowExit(4);
K3.clear();
Result.clear();
RegCloseKey(hKey);
if(TraceBack < 3)exit(-1);
//if(TraceBack < 3)exit(-1);
}
std::string CheckVer(const std::string &dir){
std::string temp,Path = dir + "\\integrity.json";

View File

@@ -6,7 +6,7 @@
/// Created by Anonymous275 on 11/26/2020
///
#include "http.h"
#include "Http.h"
#include <filesystem>
#include "Logger.h"
#include <fstream>
@@ -18,7 +18,7 @@ extern bool LoginAuth;
std::string Role;
void UpdateKey(const char* newKey){
if(newKey){
if(newKey && std::isalnum(newKey[0])){
std::ofstream Key("key");
if(Key.is_open()){
Key << newKey;
@@ -88,13 +88,21 @@ void CheckLocalKey(){
Key.read(&Buffer[0], Size);
Key.close();
for (char& c : Buffer) {
if (!std::isalnum(c) && c != '-') {
UpdateKey(nullptr);
return;
}
}
Buffer = HTTP::Post("https://auth.beammp.com/userlogin", R"({"pk":")" + Buffer + "\"}");
json::Document d;
d.Parse(Buffer.c_str());
if (Buffer == "-1" || Buffer.at(0) != '{' || d.HasParseError()) {
error(Buffer);
fatal("Invalid answer from authentication servers, please try again later!");
info("Invalid answer from authentication servers.");
UpdateKey(nullptr);
}
if(d["success"].GetBool()){
LoginAuth = true;

View File

@@ -5,6 +5,7 @@
///
/// Created by Anonymous275 on 7/16/2020
///
#include "zip_file.h"
#include <windows.h>
#include "Discord/discord_info.h"
#include "Network/network.h"
@@ -14,7 +15,7 @@
#include "Logger.h"
#include <fstream>
#include <thread>
#include "http.h"
#include "Http.h"
#include "Json.h"
extern int TraceBack;
@@ -28,7 +29,7 @@ std::string GetVer(){
return "2.0";
}
std::string GetPatch(){
return ".4";
return ".79";
}
std::string GetEP(char*P){
static std::string Ret = [&](){
@@ -194,10 +195,6 @@ size_t DirCount(const std::filesystem::path& path){
void CheckMP(const std::string& Path) {
if (!fs::exists(Path))return;
size_t c = DirCount(fs::path(Path));
if (c > 3) {
warn(std::to_string(c - 1) + " multiplayer mods will be wiped from mods/multiplayer! Close this if you don't want that!");
std::this_thread::sleep_for(std::chrono::seconds(15));
}
try {
for (auto& p : fs::directory_iterator(Path)){
if(p.exists() && !p.is_directory()){
@@ -215,9 +212,10 @@ void CheckMP(const std::string& Path) {
void EnableMP(){
std::string File(GetGamePath() + "mods/db.json");
if(!fs::exists(File))return;
auto Size = fs::file_size(File);
if(Size < 2)return;
std::ifstream db(File);
if(db.is_open()) {
auto Size = fs::file_size(File);
std::string Data(Size, 0);
db.read(&Data[0], Size);
db.close();
@@ -244,7 +242,7 @@ void EnableMP(){
}
void PreGame(const std::string& GamePath){
const std::string CurrVer("0.22.2.0");
const std::string CurrVer("0.26.1.0");
std::string GameVer = CheckVer(GamePath);
info("Game Version : " + GameVer);
if(GameVer < CurrVer){
@@ -264,12 +262,18 @@ void PreGame(const std::string& GamePath){
}catch(std::exception&e){
fatal(e.what());
}
std::string ZipPath(GetGamePath() + R"(mods\multiplayer\BeamMP.zip)");
HTTP::Download("https://backend.beammp.com/builds/client?download=true"
"&pk=" + PublicKey +
"&branch=" + Branch, GetGamePath() + R"(mods\multiplayer\BeamMP.zip)");
HTTP::Download("https://backend.beammp.com/builds/client?download=true"
"&pk=" + PublicKey + "&branch=" + Branch, ZipPath);
std::string Target(GetGamePath() + "mods/unpacked/beammp");
if(fs::is_directory(Target)) {
fs::remove_all(Target);
}
//HTTP::Download("beammp.com/builds/client", GetGamePath() + R"(mods\multiplayer\BeamMP.zip)");
}
}
}

View File

@@ -11,7 +11,7 @@
#include <iostream>
#include "Logger.h"
#include <thread>
#include "http.h"
#include "Http.h"
[[noreturn]] void flush(){
while(true){