mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2026-04-08 00:36:07 +00:00
cleanup
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
/// Created by Anonymous275 on 7/20/2020
|
||||
///
|
||||
#include "Network/network.h"
|
||||
#include "Security/Init.h"
|
||||
#include "Security/Enc.h"
|
||||
#include "Curl/http.h"
|
||||
#include <WinSock2.h>
|
||||
@@ -9,9 +10,9 @@
|
||||
#include "Startup.h"
|
||||
#include "Memory.h"
|
||||
#include "Logger.h"
|
||||
#include <charconv>
|
||||
#include <thread>
|
||||
#include <set>
|
||||
#include <charconv>
|
||||
|
||||
extern int TraceBack;
|
||||
std::set<std::string>* ConfList = nullptr;
|
||||
@@ -25,6 +26,7 @@ bool ModLoaded;
|
||||
long long ping = -1;
|
||||
|
||||
void StartSync(const std::string &Data){
|
||||
FindDLL(nullptr);
|
||||
std::string IP = GetAddr(Data.substr(1,Data.find(':')-1));
|
||||
if(IP.find('.') == -1){
|
||||
if(IP == "DNS")UlStatus = Sec("UlConnection Failed! (DNS Lookup Failed)");
|
||||
|
||||
@@ -5,18 +5,19 @@
|
||||
#include <string>
|
||||
#include <winsock.h>
|
||||
#include "Logger.h"
|
||||
#include "Security/Enc.h"
|
||||
std::string GetAddr(const std::string&IP){
|
||||
if(IP.find_first_not_of("0123456789.") == -1)return IP;
|
||||
WSADATA wsaData;
|
||||
hostent *host;
|
||||
if(WSAStartup(514, &wsaData) != 0){
|
||||
error("WSA Startup Failed!");
|
||||
error(Sec("WSA Startup Failed!"));
|
||||
WSACleanup();
|
||||
return "";
|
||||
}
|
||||
host = gethostbyname(IP.c_str());
|
||||
if(!host){
|
||||
error("DNS lookup failed! on " + IP);
|
||||
error(Sec("DNS lookup failed! on ") + IP);
|
||||
WSACleanup();
|
||||
return "DNS";
|
||||
}
|
||||
|
||||
@@ -96,17 +96,17 @@ void NetReset(){
|
||||
UlStatus = Sec("Ulstart");
|
||||
MStatus = " ";
|
||||
if(UDPSock != (SOCKET)(-1)){
|
||||
debug("Terminating UDP Socket : " + std::to_string(TCPSock));
|
||||
debug(Sec("Terminating UDP Socket : ") + std::to_string(TCPSock));
|
||||
KillSocket(UDPSock);
|
||||
}
|
||||
UDPSock = -1;
|
||||
if(TCPSock != (SOCKET)(-1)){
|
||||
debug("Terminating TCP Socket : " + std::to_string(TCPSock));
|
||||
debug(Sec("Terminating TCP Socket : ") + std::to_string(TCPSock));
|
||||
KillSocket(TCPSock);
|
||||
}
|
||||
TCPSock = -1;
|
||||
if(GSocket != (SOCKET)(-1)){
|
||||
debug("Terminating GTCP Socket : " + std::to_string(GSocket));
|
||||
debug(Sec("Terminating GTCP Socket : ") + std::to_string(GSocket));
|
||||
KillSocket(GSocket);
|
||||
}
|
||||
GSocket = -1;
|
||||
@@ -202,7 +202,7 @@ void NetMain(const std::string& IP, int Port){
|
||||
void TCPGameServer(const std::string& IP, int Port){
|
||||
GSocket = SetupListener();
|
||||
while (!TCPTerminate && GSocket != -1){
|
||||
debug("MAIN LOOP OF GAME SERVER");
|
||||
debug(Sec("MAIN LOOP OF GAME SERVER"));
|
||||
GConnected = false;
|
||||
if(!CServer){
|
||||
warn(Sec("Connection still alive terminating"));
|
||||
@@ -262,5 +262,5 @@ void TCPGameServer(const std::string& IP, int Port){
|
||||
GConnected = false;
|
||||
Terminate = true;
|
||||
if(CSocket != SOCKET_ERROR)KillSocket(CSocket);
|
||||
debug("END OF GAME SERVER");
|
||||
debug(Sec("END OF GAME SERVER"));
|
||||
}
|
||||
Reference in New Issue
Block a user