library/src/network/searchengines/BP-DisconnectMeScraper.cc
// Attempt to pregenerate a stack of queries
Attempt to pregenerate a stack of queries
Attempt to pregenerate a stack of queries
BP_ERROR_T BP_DisconnectMePreGenQueries
(
		P_BP_DISCONNECTME_SCRAPE_SESSION dmss,
		char *search_query,
		BP_DISCONNECT_ME_SEARCH_TARGET search_target
)
{
	if(!dmss)
		return ERR_FAILURE;
	if(!search_query)
		return ERR_FAILURE;
	if(!search_target)
		return ERR_FAILURE;
	if(!BP_StringIsReasonablePrintableString(search_query, bpstrlen(search_query), BP_FALSE, BP_FALSE))
		return ERR_FAILURE;
	BP_HASH_TABLE_ENTER_CRITICAL_SECTION(dmss->system_hreg);
	char * lookup_table[10];
	BP_ZERO_STACK(lookup_table);
	lookup_table[0] = "search_queries";
	lookup_table[1] = NULL;
	P_BP_HASH_TABLE_KEYED_ENTRY queries_table = BP_HashRegLookupTableByPath(dmss->system_hreg, (char **) &lookup_table);
	size_t n = 0;
	for(; n < 5000; n+=10)
	{
		P_BP_LINKL ddg_tq = BP_CreateLinkL(".", BP_TRUE);
		char ddg_front_part_initial[256];
		BP_ZERO_STACK(ddg_front_part_initial);
		char * index_as_string = BP_SizeTToBuffer(n);
		sprintf((char *) &ddg_front_part_initial, "/search?q=&hl=en&start=%u&sa=N", n);
		char * ddg_front_part = BP_UTF8StringEncode((char *) &ddg_front_part_initial, bpstrlen(ddg_front_part_initial));
		P_BP_LINKL tmp_tq = BP_CreateLinkL(".", BP_TRUE);
		tq_strdup(tmp_tq, "http://search.disconnect.me/searchTerms/search?", BPLN);
		tq_strdup(tmp_tq, "start=nav", BPLN);
		tq_strdup(tmp_tq, "&option=Web", BPLN);
		tq_strdup(tmp_tq, "&option=Web", BPLN);
		tq_strdup(tmp_tq, "&query=", BPLN);
		tq_strdup(tmp_tq, search_query, BPLN);
		tq_strdup(tmp_tq, "&sess=Google", BPLN);
		tq_strdup(tmp_tq, "&location_option=US", BPLN);
		tq_strdup(tmp_tq, "&nextDDG=", BPLN);10%26sa%3DN");
		tq_strdup(tmp_tq, ddg_front_part, BPLN);
		tq_strdup(tmp_tq, "&showIcons=false", BPLN);
		tq_strdup(tmp_tq, "&filterIcons=none", BPLN);
		tq_strdup(tmp_tq, "&js_enabled=0", BPLN);
		tq_strdup(tmp_tq, "&source=tor", BPLN);
		BP_LinkLFlattenJoinStringElements(tmp_tq);
		BP_HashRegAddDataToTable
		(
				dmss->system_hreg,
				queries_table,
				index_as_string,
				BP_HASH_TABLE_KEYED_ENTRY_TYPE_BINARY_BLOB,
				(void *) tmp_tq->flat_buff,
				bpstrlen((char *) tmp_tq->flat_buff)
		);
		BP_DestroyLinkL(tmp_tq, BP_TRUE);
		bpfree(index_as_string);
	}
	BP_HASH_TABLE_LEAVE_CRITICAL_SECTION(dmss->system_hreg);
	return ERR_SUCCESS;
}
BP_ERROR_T BP_DisconnectMePreGenQueries ( P_BP_DISCONNECTME_SCRAPE_SESSION dmss , char * search_query , BP_DISCONNECT_ME_SEARCH_TARGET search_target ) { if ( ! dmss ) return ERR_FAILURE ; if ( ! search_query ) return ERR_FAILURE ; if ( ! search_target ) return ERR_FAILURE ; if ( ! BP_StringIsReasonablePrintableString ( search_query , bpstrlen ( search_query ) , BP_FALSE , BP_FALSE ) ) return ERR_FAILURE ; BP_HASH_TABLE_ENTER_CRITICAL_SECTION ( dmss -> system_hreg ) ; char * lookup_table [ 10 ] ; BP_ZERO_STACK ( lookup_table ) ; lookup_table [ 0 ] = " " ; lookup_table [ 1 ] = NULL ; P_BP_HASH_TABLE_KEYED_ENTRY queries_table = BP_HashRegLookupTableByPath ( dmss -> system_hreg , ( char * * ) & lookup_table ) ; size_t n = 0 ; for ( ; n < 5000 ; n += 10 ) { P_BP_LINKL ddg_tq = BP_CreateLinkL ( " " , BP_TRUE ) ; char ddg_front_part_initial [ 256 ] ; BP_ZERO_STACK ( ddg_front_part_initial ) ; char * index_as_string = BP_SizeTToBuffer ( n ) ; sprintf ( ( char * ) & ddg_front_part_initial , " " , n ) ; char * ddg_front_part = BP_UTF8StringEncode ( ( char * ) & ddg_front_part_initial , bpstrlen ( ddg_front_part_initial ) ) ; P_BP_LINKL tmp_tq = BP_CreateLinkL ( " " , BP_TRUE ) ; tq_strdup ( tmp_tq , " " , BPLN ) ; tq_strdup ( tmp_tq , " " , BPLN ) ; tq_strdup ( tmp_tq , " " , BPLN ) ; tq_strdup ( tmp_tq , " " , BPLN ) ; tq_strdup ( tmp_tq , " " , BPLN ) ; tq_strdup ( tmp_tq , search_query , BPLN ) ; tq_strdup ( tmp_tq , " " , BPLN ) ; tq_strdup ( tmp_tq , " " , BPLN ) ; tq_strdup ( tmp_tq , " " , BPLN ) ; tq_strdup ( tmp_tq , ddg_front_part , BPLN ) ; tq_strdup ( tmp_tq , " " , BPLN ) ; tq_strdup ( tmp_tq , " " , BPLN ) ; tq_strdup ( tmp_tq , " " , BPLN ) ; tq_strdup ( tmp_tq , " " , BPLN ) ; BP_LinkLFlattenJoinStringElements ( tmp_tq ) ; BP_HashRegAddDataToTable ( dmss -> system_hreg , queries_table , index_as_string , BP_HASH_TABLE_KEYED_ENTRY_TYPE_BINARY_BLOB , ( void * ) tmp_tq -> flat_buff , bpstrlen ( ( char * ) tmp_tq -> flat_buff ) ) ; BP_DestroyLinkL ( tmp_tq , BP_TRUE ) ; bpfree ( index_as_string ) ; } BP_HASH_TABLE_LEAVE_CRITICAL_SECTION ( dmss -> system_hreg ) ; return ERR_SUCCESS ; }
Attempt to pregenerate a stack of queries
Attempt to pregenerate a stack of queries
// ensure we have a reasonable printable string // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Enter Critical Section and Generate Queries %%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // enter critical section // set lookup table // set query table // lookup search queries // generate query stacks // create linkl for adding google parameters // create stack buffer for initial front part // convert index to a buffer // create the initial front part // generate ddg front part // create new tailqueue allocator // https://search.disconnect.me/searchTerms/search?start=nav&option=Web&query=inurl%3Ablah&ses=Google&location_option=US&nextDDG=%2Fsearch%3Fq%3D%26hl%3Den%26start%3D100%26sa%3DN&showIcons=false&filterIcons=none&js_enabled=1&source=tor // https://search.disconnect.me/searchTerms/serp?search=c2c65f31-c43c-46d8-a50b-32413a859579 // %2Fsearch%3Fq%3D%26hl%3Den%26start%3D //100 // %26sa%3DN // %2Fsearch%3Fq%3D%26hl%3Den%26start%3D10%26sa%3DN"); // flatten string elements // add data to table // printf("\n Got flat string?: %s", tmp_tq->flat_buff); // destroy linkl // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Leave Critical Section and Return %%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // exit critical section // return indicating success