Fully remove BPTF
This commit is contained in:
parent
fe1304ab1e
commit
74b299ca59
@ -1,6 +1,5 @@
|
||||
# Current dependencies:
|
||||
# Git
|
||||
# OpenSSL (maybe should be removed, only used by backpack.tf esp)
|
||||
# SDL2
|
||||
# GLEW
|
||||
|
||||
@ -40,7 +39,6 @@ if(NOT EnableVisuals)
|
||||
endif()
|
||||
|
||||
find_package(Git REQUIRED)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
|
||||
# cat packages
|
||||
|
||||
@ -87,7 +85,6 @@ endif()
|
||||
configure_file(include/config.h.in ${CMAKE_SOURCE_DIR}/include/config.h @ONLY)
|
||||
configure_file(include/version.h.in ${CMAKE_SOURCE_DIR}/include/version.h @ONLY)
|
||||
|
||||
set_target_properties(cathook PROPERTIES COMPILE_FLAGS "-m32 -msse -msse2 -msse3 -fexceptions" LINK_FLAGS "-m32 -fno-gnu-unique -fexceptions -DNDEBUG")
|
||||
|
||||
target_compile_definitions(cathook PRIVATE
|
||||
_GLIBCXX_USE_CXX11_ABI=0
|
||||
|
@ -18,7 +18,6 @@ target_sources(cathook PRIVATE
|
||||
"${CMAKE_CURRENT_LIST_DIR}/hitrate.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/hooks.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/hoovy.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/https_request.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/init.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/ipc.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/itemtypes.hpp"
|
||||
@ -38,7 +37,7 @@ target_sources(cathook PRIVATE
|
||||
"${CMAKE_CURRENT_LIST_DIR}/velocity.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/votelogger.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/MiscTemporary.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/navparser.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/navparser.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Options.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/PlayerTools.hpp")
|
||||
|
||||
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* https_request.hpp
|
||||
*
|
||||
* Created on: Jul 23, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <openssl/ssl.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace https
|
||||
{
|
||||
|
||||
extern SSL_CTX *ssl_context;
|
||||
|
||||
class RAII_HTTPS_Socket
|
||||
{
|
||||
public:
|
||||
RAII_HTTPS_Socket(const std::string &host);
|
||||
~RAII_HTTPS_Socket();
|
||||
|
||||
bool ssl_connect();
|
||||
void ssl_die();
|
||||
|
||||
std::string get(const std::string &path);
|
||||
|
||||
const std::string hostname_;
|
||||
|
||||
hostent *host_{ nullptr };
|
||||
sockaddr_in addr_{};
|
||||
int sock_{ -1 };
|
||||
SSL *connection_{ nullptr };
|
||||
};
|
||||
|
||||
void initialize();
|
||||
} // namespace https
|
@ -11,11 +11,11 @@ rm ../install-all # remove install file
|
||||
# Install base Dependencies
|
||||
#
|
||||
if [ -f "/etc/arch-release" ]; then
|
||||
sudo pacman -S --needed --noconfirm boost cmake make lib32-openssl lib32-libpng gcc gdb lib32-sdl2 lib32-glew freetype2 rsync
|
||||
sudo pacman -S --needed --noconfirm boost cmake make lib32-libpng gcc gdb lib32-sdl2 lib32-glew freetype2 rsync
|
||||
else
|
||||
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
|
||||
sudo apt update
|
||||
sudo apt install build-essential git gcc-multilib g++-multilib software-properties-common gcc-snapshot g++-7-multilib gcc-7 g++-7 libssl-dev:i386 libboost-all-dev libc6-dev:i386 gdb libsdl2-dev libglew-dev:i386 libglew-dev libfreetype6-dev libfreetype6-dev:i386 cmake libpng-dev libssl-dev cmake gcc-multilib g++-multilib -y
|
||||
sudo apt install build-essential git gcc-multilib g++-multilib software-properties-common gcc-snapshot g++-7-multilib gcc-7 g++-7 libboost-all-dev libc6-dev:i386 gdb libsdl2-dev libglew-dev:i386 libglew-dev libfreetype6-dev libfreetype6-dev:i386 cmake libpng-dev cmake gcc-multilib g++-multilib -y
|
||||
fi
|
||||
#
|
||||
# Update cathook
|
||||
|
@ -13,7 +13,6 @@ target_sources(cathook PRIVATE
|
||||
"${CMAKE_CURRENT_LIST_DIR}/hitrate.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/hooks.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/hoovy.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/https_request.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/ipc.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/itemtypes.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/localplayer.cpp"
|
||||
|
@ -1,144 +0,0 @@
|
||||
/*
|
||||
* https_request.cpp
|
||||
*
|
||||
* Created on: Jul 23, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#include <core/logging.hpp>
|
||||
#include "https_request.hpp"
|
||||
|
||||
#include <string.h>
|
||||
#include <netdb.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <openssl/err.h>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <memory>
|
||||
|
||||
namespace https
|
||||
{
|
||||
|
||||
SSL_CTX *ssl_context;
|
||||
|
||||
bool initialized = false;
|
||||
|
||||
RAII_HTTPS_Socket::RAII_HTTPS_Socket(const std::string &host) : hostname_(host)
|
||||
{
|
||||
if (!initialized)
|
||||
{
|
||||
logging::Info("Initializing SSL");
|
||||
initialize();
|
||||
}
|
||||
sock_ = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (sock_ < 0)
|
||||
{
|
||||
throw std::runtime_error("Socket creation error");
|
||||
}
|
||||
host_ = gethostbyname(hostname_.c_str());
|
||||
if (not host_)
|
||||
{
|
||||
throw std::runtime_error("Could not resolve hostname: " + host);
|
||||
}
|
||||
memset(&addr_, 0, sizeof(addr_));
|
||||
addr_.sin_family = AF_INET;
|
||||
addr_.sin_port = htons(443);
|
||||
memcpy(&addr_.sin_addr.s_addr, host_->h_addr, host_->h_length);
|
||||
if (connect(sock_, (sockaddr *) &addr_, sizeof(addr_)) < 0)
|
||||
{
|
||||
close(sock_);
|
||||
sock_ = -1;
|
||||
throw std::runtime_error("Couldn't connect to host");
|
||||
}
|
||||
ssl_connect();
|
||||
}
|
||||
|
||||
RAII_HTTPS_Socket::~RAII_HTTPS_Socket()
|
||||
{
|
||||
ssl_die();
|
||||
if (sock_ >= 0)
|
||||
close(sock_);
|
||||
}
|
||||
|
||||
bool RAII_HTTPS_Socket::ssl_connect()
|
||||
{
|
||||
connection_ = SSL_new(ssl_context);
|
||||
SSL_set_fd(connection_, sock_);
|
||||
int ret = SSL_connect(connection_);
|
||||
if (ret != 1)
|
||||
{
|
||||
logging::Info("SSL connection error: %d, %d, %x\n", ret,
|
||||
SSL_get_error(connection_, ret), ERR_get_error());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void RAII_HTTPS_Socket::ssl_die()
|
||||
{
|
||||
if (connection_)
|
||||
{
|
||||
SSL_free(connection_);
|
||||
connection_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
std::string RAII_HTTPS_Socket::get(const std::string &path)
|
||||
{
|
||||
constexpr size_t rq_size = 1024 * 8;
|
||||
constexpr size_t rs_size = 1024 * 1024;
|
||||
|
||||
std::unique_ptr<char> buffer_rq(new char[rq_size]),
|
||||
buffer_rs(new char[rs_size]);
|
||||
|
||||
memset(buffer_rq.get(), 0, rq_size);
|
||||
int rq_length = snprintf(buffer_rq.get(), rq_size,
|
||||
"GET %s HTTP/1.0\r\nHost: %s\r\n\r\n",
|
||||
path.c_str(), hostname_.c_str());
|
||||
int sent = 0;
|
||||
int chunk = 0;
|
||||
do
|
||||
{
|
||||
chunk =
|
||||
SSL_write(connection_, buffer_rq.get() + sent, rq_length - sent);
|
||||
if (chunk < 0)
|
||||
{
|
||||
throw std::runtime_error("Error writing to Secure Socket: " +
|
||||
std::to_string(ERR_get_error()));
|
||||
}
|
||||
else if (chunk == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
sent += chunk;
|
||||
} while (sent < rq_length);
|
||||
|
||||
memset(buffer_rs.get(), 0, rs_size);
|
||||
int total = rs_size - 1;
|
||||
int received = 0;
|
||||
do
|
||||
{
|
||||
chunk =
|
||||
SSL_read(connection_, buffer_rs.get() + received, total - received);
|
||||
if (chunk < 0)
|
||||
throw std::runtime_error("Error reading from socket");
|
||||
if (chunk == 0)
|
||||
break;
|
||||
received += chunk;
|
||||
} while (received < total);
|
||||
|
||||
if (received == total)
|
||||
throw std::runtime_error("Response too large");
|
||||
|
||||
return std::string(buffer_rs.get());
|
||||
}
|
||||
|
||||
void initialize()
|
||||
{
|
||||
SSL_load_error_strings();
|
||||
SSL_library_init();
|
||||
ssl_context = SSL_CTX_new(SSLv23_client_method());
|
||||
initialized = true;
|
||||
}
|
||||
} // namespace https
|
Reference in New Issue
Block a user