diff --git a/server/cardnet.cpp b/server/cardnet.cpp index 2c9d6ae..757dc32 100644 --- a/server/cardnet.cpp +++ b/server/cardnet.cpp @@ -1,11 +1,11 @@ /* Compiler: g++ -Flags: -static-libgcc -static-libstdc++ -lws2_32 +Flags: -std=c++11 -static-libgcc -static-libstdc++ -lws2_32 TODO: -Do not send auto reply +Fix regex validation, should be 16 character hexadecimal starting with e004 +Fix validation for file checker file Change card0.txt file based on information given by client - */ #include @@ -13,6 +13,7 @@ Change card0.txt file based on information given by client #include "argh.h" #include #include +#include #pragma comment(lib,"ws2_32.lib") //Winsock Library @@ -229,6 +230,31 @@ int main (int argc, char* argv[]) //add null character, if you want to use with printf/puts or other string handling functions buffer[valread] = '\0'; printf("%s:%d - %s \n" , inet_ntoa(address.sin_addr) , ntohs(address.sin_port), buffer); + + // the 'buffer' is the string to use to edit our card0.txt file + + // check if the check file exists + //if(std::ifstream(check)) + //{ + // check file exists, rewrite + // regex to validate buffer is a e004 hex number + std::regex cardRegex("[eE]004[0-9a-fA-F]{12}"); + if(std::regex_match(buffer, cardRegex)) + { + std::cout << "Data recieved is a valid game card" << std::endl; + } + else + { + std::cout << "Data recieved is not a valid game card" << std::endl; + } + //} + //else + //{ + // no check file + // std::cout << "No check file! Will not re-write: " << file << std::endl; + //} + + send( s , buffer , valread , 0 ); } } diff --git a/server/cardnet.exe b/server/cardnet.exe index 1ed6032..bfa9c69 100755 Binary files a/server/cardnet.exe and b/server/cardnet.exe differ