library/src/network/tor/BP-Tor.cc
// attempt to start the tor service if it's unstarted
attempt to start the tor service if it's unstarted
attempt to start the tor service if it ' s unstarted
BP_ERROR_T BP_TorStart
(
		P_BP_TOR           tor
)
{
	if(!tor)
		return ERR_FAILURE;
	if(!tor->evm)
		return ERR_FAILURE;
	if(!tor->torrc_buff)
		return ERR_FAILURE;
	if(!tor->torrc_size)
		return ERR_FAILURE;
	if(!BP_StringIsReasonablePrintableString(tor->torrc_buff, tor->torrc_size, BP_TRUE, BP_FALSE))
		return ERR_FAILURE;
	P_BP_EVENT_PROCESSOR tor_processor = BP_EventMgrLookupProcessorByName(tor->evm, TOR_EVENT_PROCESSOR_NAME);
	printf("\n [+] tor_processor lookup %p", tor_processor);
	tor->run_status = BP_TOR_EVENT_STATUS_STARTING_UP;
	if(!tor_processor)
		return ERR_FAILURE;
	P_BP_TOR_EVENT_DATA tor_event = (P_BP_TOR_EVENT_DATA) ht_calloc(tor->system_hreg, sizeof(BP_TOR_EVENT_DATA), 1);
	if(!tor_event)
	{
		return ERR_FAILURE;
	}
	tor_event->event_type = BP_TOR_EVENT_START_TOR;
	tor_event->tor = tor;
	char *tmp_uuid = BP_GenRandomUUID();
	BP_ERROR_T event_create_ret = BP_EventMgrCreateEvent
	(
			tor->evm,
			(P_BP_EVENT_PROCESSOR) tor_processor,
			(P_BP_EVENT_PROCESSOR) NULL,
			BP_EVENT_MESSAGES_IN,
			BP_EVENT_TYPE_MARKER_SYSTEM_CORE_EVENT,
				tmp_uuid,
			"Starting Tor Process",
			(void *) tor_event,
			sizeof(tor_event),
			BP_EVENT_PRIORITY_HIGH
	);
	if(!event_create_ret)
	{
		printf("\n [!!] Tor start event dispatch failed.");
	}
	printf("\n [+] Tor startup dispatch succeeded!");
	tor->start_event_uuid = ht_strdup(tor->system_hreg, (char *) tmp_uuid);
	bpfree(tmp_uuid);
	tmp_uuid = NULL;
	return event_create_ret;
}
BP_ERROR_T BP_TorStart ( P_BP_TOR tor ) { if ( ! tor ) return ERR_FAILURE ; if ( ! tor -> evm ) return ERR_FAILURE ; if ( ! tor -> torrc_buff ) return ERR_FAILURE ; if ( ! tor -> torrc_size ) return ERR_FAILURE ; if ( ! BP_StringIsReasonablePrintableString ( tor -> torrc_buff , tor -> torrc_size , BP_TRUE , BP_FALSE ) ) return ERR_FAILURE ; P_BP_EVENT_PROCESSOR tor_processor = BP_EventMgrLookupProcessorByName ( tor -> evm , TOR_EVENT_PROCESSOR_NAME ) ; printf ( " \n " , tor_processor ) ; tor -> run_status = BP_TOR_EVENT_STATUS_STARTING_UP ; if ( ! tor_processor ) return ERR_FAILURE ; P_BP_TOR_EVENT_DATA tor_event = ( P_BP_TOR_EVENT_DATA ) ht_calloc ( tor -> system_hreg , sizeof ( BP_TOR_EVENT_DATA ) , 1 ) ; if ( ! tor_event ) { return ERR_FAILURE ; } tor_event -> event_type = BP_TOR_EVENT_START_TOR ; tor_event -> tor = tor ; char * tmp_uuid = BP_GenRandomUUID ( ) ; BP_ERROR_T event_create_ret = BP_EventMgrCreateEvent ( tor -> evm , ( P_BP_EVENT_PROCESSOR ) tor_processor , ( P_BP_EVENT_PROCESSOR ) NULL , BP_EVENT_MESSAGES_IN , BP_EVENT_TYPE_MARKER_SYSTEM_CORE_EVENT , tmp_uuid , " " , ( void * ) tor_event , sizeof ( tor_event ) , BP_EVENT_PRIORITY_HIGH ) ; if ( ! event_create_ret ) { printf ( " \n " ) ; } printf ( " \n " ) ; tor -> start_event_uuid = ht_strdup ( tor -> system_hreg , ( char * ) tmp_uuid ) ; bpfree ( tmp_uuid ) ; tmp_uuid = NULL ; return event_create_ret ; }
attempt to start the tor service if it's unstarted
attempt to start the tor service if it ' s unstarted
// ensure //attempt to lookup the tor processor // display processor lookup // set the run status as starting up // if we don't have an event manager entry, add it now // create new tor event // return indicating failure if we can't alloc // set event as a start event // set tor reference // create temporary uuid for the event // add start tor /*"GR4_Start_Tor_API_Server"*/ // dispatch event check // attempt to duplicate event uuid // destroy temporary uuid before returning // return the creation return value