Ejemplo n.º 1
0
void Logger::init(string file)
{
	if(!_theLogmutex)
	{
		_theLogmutex = new Mutex();

		PropFileReader pf;
		propMap props = pf.getProperties(file);
		if(props.size()==0)
		{
			level = new string(LEVEL_ERROR);
			mode = new string("CONSOLE");
			datFormat = new DateFormat("dd/mm/yyyy hh:mi:ss");
			return;
		}
		level = new string(props["LEVEL"]);
		mode = new string(props["MODE"]);
		filepath = new string(props["FILEPATH"]);
		datFormat = new DateFormat(props["DATEFMT"]);
		if(*mode=="FILE")
		{
			out = new ofstream();
			out->open(filepath->c_str(),ios::app | ios::binary);
		}
	}
}
Ejemplo n.º 2
0
DLogger::DLogger(string file)
{
    PropFileReader pf;
    propMap props = pf.getProperties(file);
    if(props.size()==0)
    {
        level = "ERROR";
        mode = "CONSOLE";
        datFormat.setFormatspec("dd/mm/yyyy hh:mi:ss");
        return;
    }
    level = props["LEVEL"];
    mode = props["MODE"];
    filepath = props["FILEPATH"];
    if(mode=="FILE")
        out.open(filepath.c_str(),ios::app | ios::binary);
    datFormat.setFormatspec(props["DATEFMT"]);
}
Ejemplo n.º 3
0
SSLClient::SSLClient(const string& secFile) {
	logger = LoggerFactory::getLogger("SSLClient");
	PropFileReader pread;
	propMap sslsec = pread.getProperties(secFile);
	if(sslsec.size()>0)
	{
		cert_file = sslsec["CERTFILE"];
		key_file = sslsec["KEYFILE"];
		dh_file = sslsec["DHFILE"];
		ca_list = sslsec["CA_LIST"];
		rand_file = sslsec["RANDOM"];
		sec_password = sslsec["PASSWORD"];
		string tempcl = sslsec["CLIENT_SEC_LEVEL"];
		if(tempcl!="")
		{
			try
			{
				client_auth = CastUtil::lexical_cast<int>(tempcl);
			}
			catch(...)
			{
				logger << "\nInvalid client auth level defined" << flush;
				client_auth = 0;
			}
		}
		isDHParams = true;
		try
		{
			isDHParams = CastUtil::lexical_cast<bool>(sslsec["ISDH_PARAMS"]);
		}
		catch(...)
		{
			logger << "\nInvalid boolean value for isDHParams defined" << flush;
		}
	}
}
Ejemplo n.º 4
0
pid_t createChildProcess(string serverRootDirectory,int sp[],int sockfd)
{
	pid_t pid;
	if (socketpair(AF_UNIX, SOCK_DGRAM, 0, sp) == -1)
	{
		perror("socketpair");
		exit(1);
	}
	if((pid=fork())==0)
	{
		SSLHandler sSLHandler;
		dlib = dlopen(Constants::INTER_LIB_FILE.c_str(), RTLD_NOW);
		logger << endl <<dlib << endl;
		if(dlib==NULL)
		{
			logger << dlerror() << endl;
			logger.info("Could not load Library");
		}
		else
			logger.info("Library loaded successfully");
		if(isSSLEnabled)
		{
			/*HTTPS related*/
			//client_auth=CLIENT_AUTH_REQUIRE;
			/* Build our SSL context*/
			ctx = sSLHandler.initialize_ctx((char*)configurationData.key_file.c_str(),(char*)configurationData.sec_password.c_str(),
					configurationData.ca_list);
			sSLHandler.load_dh_params(ctx,(char*)configurationData.dh_file.c_str());

			SSL_CTX_set_session_id_context(ctx,
			  (const unsigned char*)&SSLHandler::s_server_session_id_context,
			  sizeof SSLHandler::s_server_session_id_context);

			/* Set our cipher list */
			if(ciphers){
			  SSL_CTX_set_cipher_list(ctx,ciphers);
			}
			if(configurationData.client_auth==2)
				SSL_CTX_set_verify(ctx,SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT,0);
			else
				SSL_CTX_set_verify(ctx,SSL_VERIFY_PEER,0);
		}
		servd = serverRootDirectory;
		string filename;
		stringstream ss;
		ss << serverRootDirectory;
		ss << getpid();
		ss >> filename;
		filename.append(".cntrl");
		logger << "generated file " << filename << flush;
		ofstream cntrlfile;
		cntrlfile.open(filename.c_str());
		cntrlfile << "Process Running" << flush;
		cntrlfile.close();
		struct msghdr msg;
		struct iovec iov;
		char buf[1];
		int rv;
		int connfd = -1;
		char ccmsg[CMSG_SPACE(sizeof(connfd))];
		struct cmsghdr *cmsg;

		iov.iov_base = buf;
		iov.iov_len = 1;

		msg.msg_name = 0;
		msg.msg_namelen = 0;
		msg.msg_iov = &iov;
		msg.msg_iovlen = 1;
		/* old BSD implementations should use msg_accrights instead of
		* msg_control; the interface is different. */
		msg.msg_control = ccmsg;
		msg.msg_controllen = sizeof(ccmsg); /* ? seems to work... */
		close(sockfd);

		fd_set master;    // master file descriptor list
		fd_set read_fds;  // temp file descriptor list for select()
		int fdmax;        // maximum file descriptor number

		FD_ZERO(&master);    // clear the master and temp sets
		FD_ZERO(&read_fds);

		FD_SET(sp[1], &master);

		// keep track of the biggest file descriptor
		fdmax = sp[1]; // so far, it's this on

		ThreadPool pool;
		if(!isThreadprq)
		{
			pool.init(thrdpsiz,30,true);
		}
		PropFileReader pread;
		propMap params = pread.getProperties(serverRootDirectory+"resources/security.prop");

		logger << params.size() <<endl;
		while(1)
		{
			read_fds = master; // copy it
			int nfds = select(fdmax+1, &read_fds, NULL, NULL, NULL);
			if (nfds == -1)
			{
				perror("select_wait child process");
				logger << "\n----------epoll_wait child process----" << flush;
				//break;
			}
			else
			{
				for(int n=0;n<=fdmax;n++)
				{
					if (FD_ISSET(n, &read_fds))
					{
						//int fd = receive_fd(sp[j][1]);
						rv = recvmsg(n, &msg, 0);
						if (rv == -1)
						{
							perror("recvmsg");
							logger << "\n----------error occurred----" << flush;
							exit(1);
						}

						cmsg = CMSG_FIRSTHDR(&msg);
						if (!cmsg->cmsg_type == SCM_RIGHTS)
						{
							fprintf(stderr, "got control message of unknown type %d\n",cmsg->cmsg_type);
							exit(1);
						}
						int fd = *(int*)CMSG_DATA(cmsg);
						fcntl(fd, F_SETFL,O_SYNC);

						char buf[10];
						int err;
						if((err=recv(fd,buf,10,MSG_PEEK))==0)
						{
							close(fd);
							logger << "\nsocket conn closed before being serviced" << flush;
							continue;
						}

						if(isThreadprq)
						{
							ServiceTask *task = new ServiceTask(n,serverRootDirectory,&params,
										isSSLEnabled, ctx, sSLHandler, configurationData, dlib);
							Thread pthread(&service, task);
							pthread.execute();
							delete task;
						}
						else
						{
							ServiceTask *task = new ServiceTask(n,serverRootDirectory,&params,
									isSSLEnabled, ctx, sSLHandler, configurationData, dlib);
							pool.execute(*task);
						}
					}
				}
			}
		}
	}
Ejemplo n.º 5
0
void one_time_init(ffead_ccp_module_config *s_cf)
{
	PropFileReader pread;
	serverRootDirectory.append(s_cf->path);
	if(serverRootDirectory=="") {
		serverRootDirectory = s_cf->defpath;
	}
	string incpath = serverRootDirectory + "include/";
	string rtdcfpath = serverRootDirectory + "rtdcf/";
	string pubpath = serverRootDirectory + "public/";
	string respath = serverRootDirectory + "resources/";
	string webpath = serverRootDirectory + "web/";
	resourcePath = respath;

	ConfigurationData::getInstance();

	string logf = serverRootDirectory+"/server.log";
	string logp = respath+"/log.prop";
	LoggerFactory::init(logp, serverRootDirectory);
	logger = LoggerFactory::getLogger("FfeadCppApacheModule");

	propMap srprps = pread.getProperties(respath+"server.prop");

	strVec webdirs,webdirs1,pubfiles;
	ConfigurationHandler::listi(webpath,"/",true,webdirs,false);
	ConfigurationHandler::listi(webpath,"/",false,webdirs1,false);
	ConfigurationHandler::listi(pubpath,".js",false,pubfiles,false);

	strVec cmpnames;
	try
	{
		ConfigurationHandler::handle(webdirs, webdirs1, incpath, rtdcfpath, serverRootDirectory, respath);
	}
	catch(const XmlParseException &p)
	{
		logger << p.getMessage() << endl;
	}
	catch(const char* msg)
	{
		logger << msg << endl;
	}

	ip_address = srprps["IP_ADDR"];
	if(ip_address=="")
		ip_address = "localhost";

	if(srprps["SESS_STATE"]=="server")
		sessatserv = true;
	if(srprps["SESS_TIME_OUT"]!="")
	{
		try {
			sessionTimeout = CastUtil::lexical_cast<long>(srprps["SESS_TIME_OUT"]);
		} catch (...) {
			sessionTimeout = 3600;
			logger << "\nInvalid session timeout value defined, defaulting to 1hour/3600sec";
		}
	}
	ConfigurationData::getInstance()->sessionTimeout = sessionTimeout;
	ConfigurationData::getInstance()->sessatserv = sessatserv;
	for(unsigned int var=0;var<pubfiles.size();var++)
	{
		ConfigurationData::getInstance()->pubMap[pubfiles.at(var)] = "true";
	}
	bool libpresent = true;
	void *dlibtemp = dlopen(INTER_LIB_FILE, RTLD_NOW);
	logger << endl <<dlibtemp << endl;
	if(dlibtemp==NULL)
	{
		libpresent = false;
		logger << dlerror() << endl;
		logger.info("Could not load Library");
	}
	else
		dlclose(dlibtemp);

	//Generate library if dev mode = true or the library is not found in prod mode
	if(isCompileEnabled || !libpresent)
		libpresent = false;

	ConfigurationData::getInstance()->props = pread.getProperties(respath+"mime-types.prop");
	ConfigurationData::getInstance()->lprops = pread.getProperties(respath+"locale.prop");

	string compres;
#if BUILT_WITH_CONFGURE == 1
	compres = respath+"rundyn-automake.sh "+serverRootDirectory;
#else
	compres = respath+"rundyn.sh "+serverRootDirectory;
#endif
	if(!libpresent)
	{
		string output = ScriptHandler::execute(compres, true);
		logger << "Intermediate code generation task\n\n" << endl;
		logger << output << endl;
	}
	void* checkdlib = dlopen(INTER_LIB_FILE, RTLD_NOW);
#if BUILT_WITH_CONFGURE == 1
	if(checkdlib==NULL)
	{
		compres = respath+"rundyn-configure.sh reconf "+serverRootDirectory;
		string output = ScriptHandler::execute(compres, true);
		logger << output << endl;

		compres = respath+"rundyn-automake.sh "+serverRootDirectory;
		if(!libpresent)
		{
			string output = ScriptHandler::execute(compres, true);
			logger << "Rerunning Intermediate code generation task\n\n" << endl;
			logger << output << endl;
		}
		checkdlib = dlopen(INTER_LIB_FILE, RTLD_NOW);
	}
#endif
	if(checkdlib==NULL)
	{
		logger << dlerror() << endl;
		logger.info("Could not load Library");
		exit(0);
	}
	else
	{
		dlclose(checkdlib);
		logger.info("Library generated successfully");
	}

#ifdef INC_COMP
	for (unsigned int var1 = 0;var1<ConfigurationData::getInstance()->cmpnames.size();var1++)
	{
		string name = ConfigurationData::getInstance()->cmpnames.at(var1);
		StringUtil::replaceFirst(name,"Component_","");
		ComponentHandler::registerComponent(name);
		AppContext::registerComponent(name);
	}
#endif

	bool distocache = false;
#ifdef INC_DSTC
	int distocachepoolsize = 20;
	try {
		if(srprps["DISTOCACHE_POOL_SIZE"]!="")
		{
			distocachepoolsize = CastUtil::lexical_cast<int>(srprps["DISTOCACHE_POOL_SIZE"]);
		}
	} catch(...) {
		logger << ("Invalid poolsize specified for distocache") << endl;
	}

	try {
		if(srprps["DISTOCACHE_PORT_NO"]!="")
		{
			CastUtil::lexical_cast<int>(srprps["DISTOCACHE_PORT_NO"]);
			DistoCacheHandler::trigger(srprps["DISTOCACHE_PORT_NO"], distocachepoolsize);
			logger << ("Session store is set to distocache store") << endl;
			distocache = true;
		}
	} catch(...) {
		logger << ("Invalid port specified for distocache") << endl;
	}

	if(!distocache) {
		logger << ("Session store is set to file store") << endl;
	}
#endif

	ConfigurationData::getInstance()->sessservdistocache = distocache;

#ifdef INC_COMP
	try {
		if(srprps["CMP_PORT"]!="")
		{
			int port = CastUtil::lexical_cast<int>(srprps["CMP_PORT"]);
			if(port>0)
			{
				ComponentHandler::trigger(srprps["CMP_PORT"]);
			}
		}
	} catch(...) {
		logger << ("Component Handler Services are disabled") << endl;
	}
#endif

#ifdef INC_MSGH
	try {
		if(srprps["MESS_PORT"]!="")
		{
			int port = CastUtil::lexical_cast<int>(srprps["MESS_PORT"]);
			if(port>0)
			{
				MessageHandler::trigger(srprps["MESS_PORT"],resourcePath);
			}
		}
	} catch(...) {
		logger << ("Messaging Handler Services are disabled") << endl;
	}
#endif

#ifdef INC_MI
	try {
		if(srprps["MI_PORT"]!="")
		{
			int port = CastUtil::lexical_cast<int>(srprps["MI_PORT"]);
			if(port>0)
			{
				MethodInvoc::trigger(srprps["MI_PORT"]);
			}
		}
	} catch(...) {
		logger << ("Method Invoker Services are disabled") << endl;
	}
#endif

#ifdef INC_JOBS
	JobScheduler::start();
#endif

	//Load all the FFEADContext beans so that the same copy is shared by all process
	//We need singleton beans so only initialize singletons(controllers,authhandlers,formhandlers..)
	ConfigurationData::getInstance()->ffeadContext.initializeAllSingletonBeans();
}
static ngx_int_t init_module(ngx_cycle_t *cycle)
{
	string serverRootDirectory;
	serverRootDirectory.append(ffeadcpp_path.data, ffeadcpp_path.len);
	
	cerr << "FFEAD in init_module " << serverRootDirectory << endl;
	//if(serverRootDirectory=="") {
	//	serverRootDirectory = fconfig.defpath;
	//}

    serverRootDirectory += "/";
	if(serverRootDirectory.find("//")==0)
	{
		RegexUtil::replace(serverRootDirectory,"[/]+","/");
	}

	string incpath = serverRootDirectory + "include/";
	string rtdcfpath = serverRootDirectory + "rtdcf/";
	string pubpath = serverRootDirectory + "public/";
	string respath = serverRootDirectory + "resources/";
	string webpath = serverRootDirectory + "web/";
	string logpath = serverRootDirectory + "logs/";
	string resourcePath = respath;

	PropFileReader pread;
	propMap srprps = pread.getProperties(respath+"server.prop");

	string servd = serverRootDirectory;
	string logp = respath+"/logging.xml";
	LoggerFactory::init(logp, serverRootDirectory, "", StringUtil::toLowerCopy(srprps["LOGGING_ENABLED"])=="true");

	logger = LoggerFactory::getLogger("MOD_FFEADCPP");

	bool isCompileEnabled = false;
   	string compileEnabled = srprps["DEV_MODE"];
	if(compileEnabled=="true" || compileEnabled=="TRUE")
		isCompileEnabled = true;

	/*if(srprps["SCRIPT_ERRS"]=="true" || srprps["SCRIPT_ERRS"]=="TRUE")
	{
		SCRIPT_EXEC_SHOW_ERRS = true;
	}*/
	bool sessatserv = true;
   	if(srprps["SESS_STATE"]=="server")
   		sessatserv = true;
   	long sessionTimeout = 3600;
   	if(srprps["SESS_TIME_OUT"]!="")
   	{
   		try {
   			sessionTimeout = CastUtil::lexical_cast<long>(srprps["SESS_TIME_OUT"]);
		} catch(const std::exception& e) {
			logger << "Invalid session timeout value defined, defaulting to 1hour/3600sec" << endl;
		}
   	}

	ConfigurationData::getInstance();
	SSLHandler::setIsSSL(false);

	strVec webdirs,webdirs1,pubfiles;
	//ConfigurationHandler::listi(webpath,"/",true,webdirs,false);
	CommonUtils::listFiles(webdirs, webpath, "/");
    //ConfigurationHandler::listi(webpath,"/",false,webdirs1,false);
	CommonUtils::listFiles(webdirs1, webpath, "/", false);

    CommonUtils::loadMimeTypes(respath+"mime-types.prop");
	CommonUtils::loadLocales(respath+"locale.prop");

	RegexUtil::replace(serverRootDirectory,"[/]+","/");
	RegexUtil::replace(webpath,"[/]+","/");

	CoreServerProperties csp(serverRootDirectory, respath, webpath, srprps, sessionTimeout, sessatserv);
	ConfigurationData::getInstance()->setCoreServerProperties(csp);

    strVec cmpnames;
    try
    {
    	ConfigurationHandler::handle(webdirs, webdirs1, incpath, rtdcfpath, serverRootDirectory, respath);
    }
    catch(const XmlParseException& p)
    {
    	logger << p.getMessage() << endl;
    }
    catch(const std::exception& msg)
	{
		logger << msg << endl;
	}

    logger << INTER_LIB_FILE << endl;

    bool libpresent = true;
    void *dlibtemp = dlopen(INTER_LIB_FILE, RTLD_NOW);
	//logger << endl <<dlibtemp << endl;
	if(dlibtemp==NULL)
	{
		libpresent = false;
		logger << dlerror() << endl;
		logger.info("Could not load Library");
	}
	else
		dlclose(dlibtemp);

	//Generate library if dev mode = true or the library is not found in prod mode
	if(isCompileEnabled || !libpresent)
		libpresent = false;

	if(!libpresent)
	{
		string configureFilePath = rtdcfpath+"/autotools/configure";
		if (access( configureFilePath.c_str(), F_OK ) == -1 )
		{
			string compres = rtdcfpath+"/autotools/autogen.sh "+serverRootDirectory;
			string output = ScriptHandler::execute(compres, true);
			logger << "Set up configure for intermediate libraries\n\n" << endl;
		}

		if (access( configureFilePath.c_str(), F_OK ) != -1 )
		{
			string compres = respath+"rundyn-configure.sh "+serverRootDirectory;
		#ifdef DEBUG
			compres += " --enable-debug=yes";
		#endif
			string output = ScriptHandler::execute(compres, true);
			logger << "Set up makefiles for intermediate libraries\n\n" << endl;
			logger << output << endl;

			compres = respath+"rundyn-automake.sh "+serverRootDirectory;
			output = ScriptHandler::execute(compres, true);
			logger << "Intermediate code generation task\n\n" << endl;
			logger << output << endl;
		}
	}

	void* checkdlib = dlopen(INTER_LIB_FILE, RTLD_NOW);
	if(checkdlib==NULL)
	{
		string compres = rtdcfpath+"/autotools/autogen-noreconf.sh "+serverRootDirectory;
		string output = ScriptHandler::execute(compres, true);
		logger << "Set up configure for intermediate libraries\n\n" << endl;

		compres = respath+"rundyn-configure.sh "+serverRootDirectory;
		#ifdef DEBUG
			compres += " --enable-debug=yes";
		#endif
		output = ScriptHandler::execute(compres, true);
		logger << "Set up makefiles for intermediate libraries\n\n" << endl;
		logger << output << endl;

		compres = respath+"rundyn-automake.sh "+serverRootDirectory;
		if(!libpresent)
		{
			string output = ScriptHandler::execute(compres, true);
			logger << "Rerunning Intermediate code generation task\n\n" << endl;
			logger << output << endl;
		}
		checkdlib = dlopen(INTER_LIB_FILE, RTLD_NOW);
	}

	if(checkdlib==NULL)
	{
		logger << dlerror() << endl;
		logger.info("Could not load Library");
		exit(0);
	}
	else
	{
		dlclose(checkdlib);
		logger.info("Library generated successfully");
	}

#ifdef INC_COMP
	for (unsigned int var1 = 0;var1<ConfigurationData::getInstance()->componentNames.size();var1++)
	{
		string name = ConfigurationData::getInstance()->componentNames.at(var1);
		StringUtil::replaceFirst(name,"Component_","");
		ComponentHandler::registerComponent(name);
		AppContext::registerComponent(name);
	}
#endif

	bool distocache = false;
/*#ifdef INC_DSTC
	int distocachepoolsize = 20;
	try {
		if(srprps["DISTOCACHE_POOL_SIZE"]!="")
		{
			distocachepoolsize = CastUtil::lexical_cast<int>(srprps["DISTOCACHE_POOL_SIZE"]);
		}
	} catch(const std::exception& e) {
		logger << ("Invalid poolsize specified for distocache") << endl;
	}

	try {
		if(srprps["DISTOCACHE_PORT_NO"]!="")
		{
			CastUtil::lexical_cast<int>(srprps["DISTOCACHE_PORT_NO"]);
			DistoCacheHandler::trigger(srprps["DISTOCACHE_PORT_NO"], distocachepoolsize);
			logger << ("Session store is set to distocache store") << endl;
			distocache = true;
		}
	} catch(const std::exception& e) {
		logger << ("Invalid port specified for distocache") << endl;
	}

	if(!distocache) {
		logger << ("Session store is set to file store") << endl;
	}
#endif*/


#ifdef INC_JOBS
	JobScheduler::start();
#endif

	logger << ("Initializing WSDL files....") << endl;
	ConfigurationHandler::initializeWsdls();
	logger << ("Initializing WSDL files done....") << endl;

	for(char **current = environ; *current; current++) {
        cerr << *current << endl;
    }

	void* dlib = dlopen(INTER_LIB_FILE, RTLD_NOW);
	//logger << endl <<dlib << endl;
	if(dlib==NULL)
	{
		logger << dlerror() << endl;
		logger.info("Could not load Library");
		exit(0);
	}
	else
	{
		logger.info("Library loaded successfully");
		dlclose(dlib);
	}

	void* ddlib = dlopen(DINTER_LIB_FILE, RTLD_NOW);
	//logger << endl <<dlib << endl;
	if(ddlib==NULL)
	{
		logger << dlerror() << endl;
		logger.info("Could not load dynamic Library");
		exit(0);
	}
	else
	{
		logger.info("Dynamic Library loaded successfully");
		dlclose(ddlib);
	}

	ddlib = dlopen(DINTER_LIB_FILE, RTLD_NOW);
        //logger << endl <<dlib << endl;
        if(ddlib==NULL)
        {
                logger << dlerror() << endl;
                logger.info("Could not load dynamic Library");
                exit(0);
        }
        else
        {
                logger.info("Second Dynamic Library loaded successfully");
                dlclose(ddlib);
        }	
	cerr << getpid() << endl;
	return NGX_OK;
}
Ejemplo n.º 7
0
int main()
{
	#ifdef OS_MINGW
		// startup WinSock in Windows
		WSADATA wsa_data;
		WSAStartup(MAKEWORD(1,1), &wsa_data);
	#endif
	
	PropFileReader propFileReader;
	propMap props = propFileReader.getProperties("testValues.prop");

	CsvFileReader csvFileReader;
	strVecVec testCases = csvFileReader.getRows("test.csv");

	Timer timer, timerc;
	std::string cookies, result;
	int total, skipped = 0, passed = 0, failed = 0, header = 0, counter = 0;

	total = (int)testCases.size();

	std::string ip = props["SERVER_IP_ADDRESS"];
	if(ip=="")
		ip = "localhost";
	int port = 8080;
	if(props["SERVER_PORT"]!="")
	{
		try{
			port = CastUtil::lexical_cast<int>(props["SERVER_PORT"]);
		} catch(...) {
		}

	}
	bool sslEnabled = false;
	if(props["SERVER_SSL_ENABLED"]!="")
	{
		try{
			sslEnabled = CastUtil::lexical_cast<bool>(props["SERVER_SSL_ENABLED"]);
		} catch(...) {
		}
	}

	std::string sslFile = props["SERVER_SSL_FILE"];

	bool isDebug = false;
	if(StringUtil::toLowerCopy(props["DEBUG"])=="true") {
		isDebug = true;
	}

	std::cout << "Server IP - " << ip <<std::endl;
	std::cout << "Server Port - " << port <<std::endl;
	std::cout << "Debug Mode - " << isDebug <<std::endl;
	std::cout << "Server SSL Enabled - " << CastUtil::lexical_cast<std::string>(sslEnabled) <<std::endl;
	if(sslEnabled)
	{
		std::cout << "Server SSL File - " << sslFile <<std::endl;
	}

	timerc.start();
	for (int var = 0; var < total; ++var)
	{
		ClientInterface* client;
		if(sslEnabled)
		{
			if(sslFile!="")
				client = new SSLClient(sslFile);
			else
				client = new SSLClient;
		}
		else
			client = new Client;
		if(testCases[var].size()>=4)
		{
			if(testCases[var][0]=="ENABLED")
			{
				header++;
				continue;
			}
			counter = var;
			std::string request = testCases[var][2];
			if(testCases[var][0]=="N" || testCases[var][0]=="n")
			{
				std::cout << "Request " << counter << " " << request << " was Skipped" << std::endl;
				skipped++;
				continue;
			}

			bool debugCont = false;
			std::string debugContStr = testCases[var][1];
			if(debugContStr=="Y" || debugContStr=="y")
				debugCont = true;

			std::string responseCode = testCases[var][3];
			std::string file;
			if(testCases[var].size()>4)
				file = testCases[var][4];
			std::string fileCntlen;
			if(testCases[var].size()>5)
				fileCntlen = testCases[var][5];
			std::string reqContTyp, content, headers, respCntType;
			if(testCases[var].size()>6)
			{
				reqContTyp = testCases[var][6];
			}
			if(testCases[var].size()>7)
			{
				content = testCases[var][7];
			}
			if(testCases[var].size()>8)
			{
				headers = testCases[var][8];
				if(headers!="" && headers.find("HEADERVALS_")!=std::string::npos)
				{
					headers = props[headers];
				}
				else
				{
					std::vector<std::string> headerVec;
					StringUtil::split(headerVec, headers, ";");
					headers = "";
					for (int var = 0; var < (int)headerVec.size(); ++var) {
						std::vector<std::string> param;
						StringUtil::split(param, headerVec.at(var), "=");
						if(param.size()==2)
						{
							headers += param.at(0) + ": " + param.at(1) + "\r\n";
						}
					}
				}
			}
			if(testCases[var].size()>9)
			{
				respCntType = testCases[var][9];
			}

			std::string data = request;
			data += " HTTP/1.1\r\nHost: "+ip+":"+CastUtil::lexical_cast<std::string>(port)+"\r\nUser-Agent: Program\r\n";

			if(content!="" && content.find("TSTVALUES_")!=std::string::npos)
				content = props[content];

			if(reqContTyp!="")
			{
				data += "Content-Type: " + reqContTyp + "\r\n";
			}
			if(content.length()>0)
			{
				data += "Content-Length: " + CastUtil::lexical_cast<std::string>((int)content.length()) + "\r\n";
			}
			if(cookies!="")
			{
				data += "Cookie: " + cookies + "\r\n";
			}
			if(headers!="")
			{
				data += headers;
			}
			data += "\r\n";

			if(content!="")
			{
				data += content;
			}

			timer.start();

			if(isDebug) {
				std::cout << "HTTP Request Is=>\n" << data << "\n\n" << std::endl;
			}

			client->connectionUnresolv(ip,port);
			int bytes = client->sendData(data);
			std::string tot = client->getTextData("\r\n","content-length");
			long long millis = timer.elapsedMilliSeconds();

			if(isDebug) {
				std::cout << "HTTP Response Is=>\n" << tot << "\n\n" << std::endl;
			}

			HttpResponse res;
			HttpResponseParser parser(tot, res);

			if(res.getHeader("Set-Cookie")!="")
			{
				cookies = res.getHeader("Set-Cookie");
				cookies = cookies.substr(0, cookies.find(";"));
			}

			std::string debugContentValue;
			if(debugCont)
			{
				debugContentValue = ", Content => " + parser.getContent();
			}

			std::string ss;
			bool passedFlag = false, done = false;
			if(res.getStatusCode()==responseCode)
			{
				if(respCntType!="")
				{
					if(res.getHeader("Content-Type")==respCntType)
					{
						ss.clear();
						ss = "Test " + CastUtil::lexical_cast<std::string>(counter) + " " + request + " was Successfull, Response Time = " + CastUtil::lexical_cast<std::string>(millis) + "ms" + debugContentValue;
						passedFlag = true;
					}
					else
					{
						ss.clear();
						ss = "Test " + CastUtil::lexical_cast<std::string>(counter) + " " + request + " Failed, Response Time = " + CastUtil::lexical_cast<std::string>(millis) + "ms"
								+ ", Expected ContentType = " + respCntType + ", Actual ContentType = "  + res.getHeader("Content-Type");
						passedFlag = false;
					}
					done = true;
				}
				if(!done)
				{
					std::string cntlen = res.getHeader("Content-Length");
					if(file!="")
					{
						std::ifstream myfile (&file[0], std::ios::binary | std::ios::ate);
						if (myfile.is_open() && cntlen!="" && myfile.tellg()==CastUtil::lexical_cast<int>(cntlen))
						{
							ss.clear();
							ss = "Test " + CastUtil::lexical_cast<std::string>(counter) + " " + request + " was Successfull, Response Time = " + CastUtil::lexical_cast<std::string>(millis) + "ms" + debugContentValue;
							passedFlag = true;
						}
						else
						{
							ss.clear();
							ss = "Test " + CastUtil::lexical_cast<std::string>(counter) + " " + request + ", Invalid Content Length, Response Time = " + CastUtil::lexical_cast<std::string>(millis) + "ms" + debugContentValue;
							passedFlag = false;
						}
					}
					else if((file=="" && fileCntlen=="") || (fileCntlen!="" && fileCntlen==cntlen))
					{
						ss.clear();
						ss = "Test " + CastUtil::lexical_cast<std::string>(counter) + " " + request + " was Successfull, Response Time = " + CastUtil::lexical_cast<std::string>(millis) + "ms" + debugContentValue;
						passedFlag = true;
					}
					else
					{
						ss.clear();
						ss = "Test " + CastUtil::lexical_cast<std::string>(counter) + " " + request + ", Invalid Content Length, Response Time = " + CastUtil::lexical_cast<std::string>(millis) + "ms" + debugContentValue;
						passedFlag = false;
					}
				}
			}
			else
			{
				ss.clear();
				ss = "Test " + CastUtil::lexical_cast<std::string>(counter) + " " + request + " Failed, Response Time = " + CastUtil::lexical_cast<std::string>(millis) + "ms" + ", Expected Status = " +
						responseCode + ", Actual Status = "  + res.getStatusCode();
				passedFlag = false;
			}
			std::cout << ss << std::endl;
			if(passedFlag)
				passed++;
			else
				failed++;
		}
		else
		{
			skipped++;
		}
		if(client!=NULL)
		{
			client->closeConnection();
			delete client;
		}
	}

	std::cout << "Total Tests = " << total-1 << ", Passed = " << passed << ", Failed = " << failed
			<< ", Skipped = " << skipped << ", Time taken = " << timerc.elapsedMilliSeconds() << "ms" << std::endl;
	
	#ifdef OS_MINGW
		WSACleanup();
	#endif

	return 0;
}