mirror of
https://github.com/SantaSpeen/BeamMP-Server.git
synced 2025-08-18 13:05:37 +00:00
wesocket base
This commit is contained in:
parent
757c63bddb
commit
5b92cbc0be
@ -18,21 +18,21 @@ elseif (WIN32)
|
||||
STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
|
||||
endif ()
|
||||
|
||||
find_package(Boost 1.67.0 REQUIRED COMPONENTS system thread)
|
||||
find_package(Boost 1.70.0 REQUIRED COMPONENTS system thread)
|
||||
file(GLOB source_files "src/*.cpp" "src/*/*.cpp" "include/*.h" "include/*/*.h" "include/*.hpp" "include/*/*.hpp")
|
||||
add_executable(BeamMP-Server ${source_files})
|
||||
|
||||
target_include_directories(BeamMP-Server PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> ${Boost_INCLUDE_DIRS})
|
||||
target_include_directories(BeamMP-Server SYSTEM PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
|
||||
target_include_directories(BeamMP-Server SYSTEM PRIVATE ${LUA_INCLUDE_DIR} ${Boost_INCLUDE_DIRS})
|
||||
|
||||
if (UNIX)
|
||||
find_package(Lua 5.3 REQUIRED)
|
||||
target_include_directories(BeamMP-Server PRIVATE ${LUA_INCLUDE_DIR})
|
||||
target_include_directories(BeamMP-Server PRIVATE )
|
||||
target_link_libraries(BeamMP-Server curl krb5 z pthread stdc++fs ${Boost_LINK_DIRS} ${LUA_LIBRARIES})
|
||||
elseif (WIN32)
|
||||
include(FindLua)
|
||||
find_package(CURL CONFIG REQUIRED)
|
||||
find_package(ZLIB REQUIRED)
|
||||
find_package(Lua REQUIRED)
|
||||
target_include_directories(BeamMP-Server PRIVATE ${LUA_INCLUDE_DIR})
|
||||
target_link_libraries(BeamMP-Server PRIVATE urlmon ws2_32 CURL::libcurl ZLIB::ZLIB ${Boost_LINK_DIRS} ${LUA_LIBRARIES})
|
||||
endif ()
|
||||
|
@ -38,6 +38,7 @@ void Heartbeat(){
|
||||
if(!CustomIP.empty())R+="&ip="+CustomIP;
|
||||
std::string link = Sec("https://beammp.com/heartbeatv2");
|
||||
T = PostHTTP(link,R);
|
||||
|
||||
if(T.find_first_not_of(Sec("20")) != std::string::npos){
|
||||
//Backend system refused server startup!
|
||||
std::this_thread::sleep_for(std::chrono::seconds(10));
|
||||
|
@ -35,6 +35,8 @@ std::string PostHTTP(const std::string& IP,const std::string& Fields){
|
||||
Assert(curl);
|
||||
if(curl) {
|
||||
curl_easy_setopt(curl, CURLOPT_URL, IP.c_str());
|
||||
/*curl_easy_setopt(curl, CURLOPT_URL, "95.216.35.232/heartbeatv2");
|
||||
curl_easy_setopt(curl, CURLOPT_PORT, 3600);*/
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, Fields.size());
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, Fields.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
|
||||
|
@ -1,43 +1,58 @@
|
||||
///
|
||||
/// Created by Anonymous275 on 11/6/2020
|
||||
///
|
||||
#include <boost/beast/core.hpp>
|
||||
/*#include <boost/beast/core.hpp>
|
||||
#include <boost/beast/websocket.hpp>
|
||||
#include <boost/asio/connect.hpp>
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
#include <boost/asio/ip/tcp.hpp>*/
|
||||
#include "Security/Enc.h"
|
||||
#include <iostream>
|
||||
#include "Logger.h"
|
||||
#include <thread>
|
||||
#include <string>
|
||||
|
||||
namespace beast = boost::beast;
|
||||
/*namespace beast = boost::beast;
|
||||
namespace http = beast::http;
|
||||
namespace websocket = beast::websocket;
|
||||
namespace net = boost::asio;
|
||||
using tcp = boost::asio::ip::tcp;
|
||||
//ws.write(asio::buffer("Hello, world!"));
|
||||
// asio::connect(sock,r.resolve(asio::ip::tcp::resolver::query{host, "80"}));
|
||||
// beast::websocket::stream<asio::ip::tcp::socket&> ws(sock);
|
||||
// ws.handshake(host,"/");
|
||||
|
||||
std::string GetRes(const beast::flat_buffer& buff) {
|
||||
return (char*)buff.data().data();
|
||||
}*/
|
||||
|
||||
void SyncData(){
|
||||
DebugPrintTID();
|
||||
using namespace boost;
|
||||
std::string const host = "95.216.35.232";
|
||||
net::io_context ioc;
|
||||
/*DebugPrintTID();
|
||||
try {
|
||||
std::string const host = Sec("95.216.35.232");
|
||||
|
||||
tcp::resolver r(ioc);
|
||||
net::io_context ioc;
|
||||
tcp::resolver r(ioc);
|
||||
|
||||
websocket::stream<tcp::socket> ws{ioc};
|
||||
auto const results = r.resolve(host, "3600");
|
||||
net::connect(ws.next_layer(), results.begin(), results.end());
|
||||
websocket::stream<tcp::socket> ws(ioc);
|
||||
auto const results = r.resolve(host, Sec("3600"));
|
||||
net::connect(ws.next_layer(), results.begin(), results.end());
|
||||
|
||||
|
||||
ws.handshake(host, "/");
|
||||
beast::flat_buffer buffer;
|
||||
ws.write(boost::asio::buffer("Hello, world!"));
|
||||
ws.read(buffer);
|
||||
|
||||
std::cout << GetRes(buffer) << std::endl;
|
||||
|
||||
ws.close(websocket::close_code::normal);
|
||||
|
||||
}catch(std::exception const& e){
|
||||
error(e.what());
|
||||
std::this_thread::sleep_for(std::chrono::seconds(3));
|
||||
exit(0);
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
void WebsocketInit(){
|
||||
std::thread t1(SyncData);
|
||||
t1.detach();
|
||||
/*std::thread t1(SyncData);
|
||||
t1.detach();*/
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user