mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-06-17 22:23:03 +00:00
add even more debugging prints
This commit is contained in:
+15
-1
@@ -116,12 +116,14 @@ void Identification(SOCKET TCPSock,Hold*S,RSA*Skey){
|
|||||||
Timeout.detach();
|
Timeout.detach();
|
||||||
std::string Name,DID,Role;
|
std::string Name,DID,Role;
|
||||||
if(!Send(TCPSock,GenerateM(Skey))){
|
if(!Send(TCPSock,GenerateM(Skey))){
|
||||||
|
error("died on " + std::string(__func__) + ":" + std::to_string(__LINE__));
|
||||||
closesocket(TCPSock);
|
closesocket(TCPSock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::string msg = Rcv(TCPSock);
|
std::string msg = Rcv(TCPSock);
|
||||||
auto Keys = Parse(msg);
|
auto Keys = Parse(msg);
|
||||||
if(!Send(TCPSock,RSA_E("HC",Keys.second,Keys.first))){
|
if(!Send(TCPSock,RSA_E("HC",Keys.second,Keys.first))){
|
||||||
|
error("died on " + std::string(__func__) + ":" + std::to_string(__LINE__));
|
||||||
closesocket(TCPSock);
|
closesocket(TCPSock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -133,19 +135,23 @@ void Identification(SOCKET TCPSock,Hold*S,RSA*Skey){
|
|||||||
if(Ver.size() > 3 && Ver.substr(0,2) == Sec("VC")){
|
if(Ver.size() > 3 && Ver.substr(0,2) == Sec("VC")){
|
||||||
Ver = Ver.substr(2);
|
Ver = Ver.substr(2);
|
||||||
if(Ver.length() > 4 || Ver != GetCVer()){
|
if(Ver.length() > 4 || Ver != GetCVer()){
|
||||||
|
error("died on " + std::string(__func__) + ":" + std::to_string(__LINE__));
|
||||||
closesocket(TCPSock);
|
closesocket(TCPSock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
error("died on " + std::string(__func__) + ":" + std::to_string(__LINE__));
|
||||||
closesocket(TCPSock);
|
closesocket(TCPSock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Res = RSA_D(Res,Skey);
|
Res = RSA_D(Res,Skey);
|
||||||
if(Res.size() < 3 || Res.substr(0,2) != Sec("NR")) {
|
if(Res.size() < 3 || Res.substr(0,2) != Sec("NR")) {
|
||||||
|
error("died on " + std::string(__func__) + ":" + std::to_string(__LINE__));
|
||||||
closesocket(TCPSock);
|
closesocket(TCPSock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(Res.find(':') == std::string::npos){
|
if(Res.find(':') == std::string::npos){
|
||||||
|
error("died on " + std::string(__func__) + ":" + std::to_string(__LINE__));
|
||||||
closesocket(TCPSock);
|
closesocket(TCPSock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -153,6 +159,7 @@ void Identification(SOCKET TCPSock,Hold*S,RSA*Skey){
|
|||||||
DID = Res.substr(Res.find(':')+1);
|
DID = Res.substr(Res.find(':')+1);
|
||||||
Role = GetRole(DID);
|
Role = GetRole(DID);
|
||||||
if(Role.empty() || Role.find(Sec("Error")) != std::string::npos){
|
if(Role.empty() || Role.find(Sec("Error")) != std::string::npos){
|
||||||
|
error("died on " + std::string(__func__) + ":" + std::to_string(__LINE__));
|
||||||
closesocket(TCPSock);
|
closesocket(TCPSock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -160,6 +167,7 @@ void Identification(SOCKET TCPSock,Hold*S,RSA*Skey){
|
|||||||
for(Client*c: CI->Clients){
|
for(Client*c: CI->Clients){
|
||||||
if(c != nullptr){
|
if(c != nullptr){
|
||||||
if(c->GetDID() == DID){
|
if(c->GetDID() == DID){
|
||||||
|
error("died on " + std::string(__func__) + ":" + std::to_string(__LINE__));
|
||||||
closesocket(c->GetTCPSock());
|
closesocket(c->GetTCPSock());
|
||||||
c->SetStatus(-2);
|
c->SetStatus(-2);
|
||||||
break;
|
break;
|
||||||
@@ -168,7 +176,11 @@ void Identification(SOCKET TCPSock,Hold*S,RSA*Skey){
|
|||||||
}
|
}
|
||||||
if(Role == Sec("MDEV") || CI->Size() < Max()){
|
if(Role == Sec("MDEV") || CI->Size() < Max()){
|
||||||
CreateClient(TCPSock,Name,DID,Role);
|
CreateClient(TCPSock,Name,DID,Role);
|
||||||
}else closesocket(TCPSock);
|
} else {
|
||||||
|
error("died on " + std::string(__func__) + ":" + std::to_string(__LINE__));
|
||||||
|
closesocket(TCPSock);
|
||||||
|
}
|
||||||
|
debug("Identification success");
|
||||||
}
|
}
|
||||||
void Identify(SOCKET TCPSock){
|
void Identify(SOCKET TCPSock){
|
||||||
auto* S = new Hold;
|
auto* S = new Hold;
|
||||||
@@ -186,6 +198,7 @@ void Identify(SOCKET TCPSock){
|
|||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
|
|
||||||
if(TCPSock != -1){
|
if(TCPSock != -1){
|
||||||
|
error("died on " + std::string(__func__) + ":" + std::to_string(__LINE__));
|
||||||
closesocket(TCPSock);
|
closesocket(TCPSock);
|
||||||
}
|
}
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
@@ -267,6 +280,7 @@ void TCPServerMain(){
|
|||||||
ID.detach();
|
ID.detach();
|
||||||
}while(client);
|
}while(client);
|
||||||
|
|
||||||
|
debug("all ok, arrived at " + std::string(__func__) + ":" + std::to_string(__LINE__));
|
||||||
closesocket(client);
|
closesocket(client);
|
||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user