Spider& RecyclingSpiderFactory::CreateSpider(const sf::Vector2f SpawnPosition,const float speed,const sf::Vector2i InitialDirection, Mushroomfield& FatherMushroomField){
	
	
	Spider* spider;
		
	//if the recyclebin is empty create a Spider
	if ( Instance().recycledItems.empty() )
	{
	
		 
		spider = new Spider(SpawnPosition,speed,InitialDirection, FatherMushroomField);
			
		// Tell Teal to let us manually manage the Spider and send to Recycle method
		spider->SetExternalManagement( RecycleSpider);
	}
	else
	{
		//sets spider to the top of the recycle stack (grab a previously used spider)
		spider = Instance().recycledItems.top();
		Instance().recycledItems.pop();//remove from stack (since it will be used)

		// register flea to scene
		spider->RegisterToCurrentScene();  
	}
	//respawn the flea
	spider->Initialize(SpawnPosition,speed,InitialDirection, FatherMushroomField);
	

	return *spider;
	
}
Example #2
0
int main(int argc, char* argv[])
{
	Spider			spider;
	SpiderInterfaceConfig*	interfaceConfig;

	interfaceConfig	=spider.GetSpiderInterfaceConfig();

	MainUrlRule		mainRule;
	ImageUrlRule	imageRule;
	OnlyPageRule	onlyPageRule;
	ImageSave		imageSave;
	DoPageProcess	pageProcess;
	ErrorNotify		errorNotify;

	interfaceConfig->AddUrlFilter(&mainRule);
	interfaceConfig->AddUrlFilter(&onlyPageRule);
	interfaceConfig->SetErrorNotify(&errorNotify);
//	interfaceConfig.SetFileProcessMethod(&imageSave);
//	interfaceConfig.SetPageProcessMethod(&pageProcess);

	spider.StartSpider("www.920mm.com/DGC");

	printf("输入任意字符退出爬虫。。。\n");
	getchar();
	spider.EndSpider();
}
Example #3
0
Spider* DeathMoth::createBornSpider(int index)
{
    Spider* sp = nullptr;
    if(AttackSequence::ATK_03 == m_atkSeq)
    {
        sp = SpiderSpines::create();
    }
    else
    {
        sp = SpiderFly::create();
    }
    
    sp->setState(SpiderState::kSpiderState_Walk);
    return sp;
}
void TargetDirectoryLoader::targetsLoad(const char* name_src,const char* in_dir
	,Spider& spider,DependencyGraph& graph,Target_FactoryDelegator& factory) const
	{
	Handle<TargetDirectory> target(
		TargetDirectory::create(name_src,in_dir,factory.rootGet(),factory.idGet()));
	graph.targetRegister(target);
	DirectoryLister dirlister(name_src);
	const char* entry=dirlister.read();
	while(entry!=nullptr)
		{
		if(m_ignore.find(Stringkey(entry))==m_ignore.end())
			{
			auto path_tot=dircat(name_src,entry);
			if(m_ignore_fullname.find(Stringkey(path_tot.c_str()))
				==m_ignore_fullname.end())
				{
				auto entry_type=FileInfo(path_tot.c_str()).typeGet();
				if((entry_type==FileInfo::Type::DIRECTORY && m_recursive)
					|| entry_type==FileInfo::Type::FILE)
					{spider.scanFile(path_tot.c_str(),name_src);}
				}
			}

		entry=dirlister.read();
		}
	}
static void depsExtraCollect(const Dependency& dep_in
	,const std::map<Stringkey,const Target_Loader*>& loaders
	,Spider& spider
	,std::map<Stringkey,DependencyBufferDefault>& deps_extra_cache
	,const char* root
	,DependencyBuffer& buffer)
	{
	auto loader=targetLoaderGet(targetLoaderKeyGet(dep_in.nameGet()),loaders);
	if(loader!=nullptr)
		{
		auto in_dir_include=dirname(dep_in.nameGet());
		spider.scanFile(dep_in.nameGet(),in_dir_include.c_str());

		auto key=Stringkey(dep_in.nameGet());
		auto i=deps_extra_cache.find(key);
		if(i==deps_extra_cache.end())
			{
			DependencyBufferDefault buffer_temp;
			loader->dependenciesExtraGet(dep_in.nameGet(),in_dir_include.c_str()
				,root,ResourceObjectJansson::createImpl,buffer_temp);
			buffer.append(buffer_temp);
			deps_extra_cache.insert({std::move(key),std::move(buffer_temp)});
			}
		else
			{buffer.append(i->second);}
		}
	}
Example #6
0
void dController::getTemplatesFromServer(QString &saveTo)
{
    QDir dir;
    if (dir.mkpath(saveTo))
    {
	QFileInfoList list = dir.entryInfoList();
	//Очистил каталог назначения
	for (int i = 0; i < list.size(); ++i) {
	    QFileInfo fileInfo = list.at(i);
	    dir.remove(fileInfo.fileName());
	}
	Spider spider;
	spider.getDirectory(QUrl(this->ftpTemplatesDir),this->globalTemplates);
	QObject::connect(&spider, SIGNAL(done()), this, SLOT(done_ftp_transfer()));

    }

}
Example #7
0
Spider* SpiderFactory::CreateSpider(std::string texture, MushroomField* theField, sf::Vector2f pos, int frameWidth, int frameHeight, int moveDirection)
{
	Spider* e;

	if ( recycledItems.empty() )
	{
		e = new Spider(texture, theField, frameWidth, frameHeight);


		e->SetExternalManagement( RecycleSpider );
	}
	else
	{
		e = recycledItems.top();
		recycledItems.pop();	


		e->RegisterToCurrentScene();  
	}
	e->Initialize(pos, moveDirection);

	return e;
}
Example #8
0
int main(int argc, char *argv[]) {
	bool ret = 0;
	int iret = 0;

	unique_ptr<MathildaDNS> mdns(new MathildaDNS(true));

	std::vector<std::string> out;
	iret = mdns->name_to_addr("www.yahoo.com", out, false);

	for(auto j : out) {
		fprintf(stdout, "name_to_addr(www.yahoo.com) = %d %s\n", iret, j.c_str());
	}
	for(auto i : mdns->dns_cache) {
		fprintf(stdout, "[DNS Cache] %s -> %s\n", i.first.c_str(), i.second.c_str());
	}

	out.clear();

	iret = mdns->name_to_addr("aaaaaaa.test.com", out, true);
	fprintf(stdout, "name_to_addr(aaaaaaa.test.com) = %d\n", iret);

	std::vector<std::string> hostnames;
	hostnames.push_back("www.yahoo.com");
	hostnames.push_back("answers.yahoo.com");
	hostnames.push_back("finance.yahoo.com");
	hostnames.push_back("mail.yahoo.com");
	hostnames.push_back("messenger.yahoo.com");
	hostnames.push_back("github.com");
	hostnames.push_back("facebook.com");
	hostnames.push_back("google.com");
	hostnames.push_back("facebook.com");
	hostnames.push_back("twitter.com");
	hostnames.push_back("abc.com");
	hostnames.push_back("cbs.com");
	hostnames.push_back("nbc.com");
	hostnames.push_back("slack.com");
	hostnames.push_back("microsoft.com");
	hostnames.push_back("nfl.com");
	hostnames.push_back("mail.microsoft.com");
	hostnames.push_back("mail.google.com");
	hostnames.push_back("gmail.com");
	hostnames.push_back("lastpass.com");
	hostnames.push_back("github.io");
	hostnames.push_back("mongodb.com");
	mdns->name_to_addr_a(hostnames, out);

	fprintf(stdout, "%zu/%zu results for async reverse DNS lookup:\n", out.size(), hostnames.size());

	for(auto o : out) {
		cout << o << endl;
	}

	for(auto i : mdns->dns_cache) {
		fprintf(stdout, "[DNS Cache] %s -> %s\n", i.first.c_str(), i.second.c_str());
	}

	std::string ip = "8.8.8.8";
	std::string out_r;

	iret = mdns->addr_to_name(ip, out_r);
	fprintf(stdout, "addr_to_name(8.8.8.8) = %s %d\n", out_r.c_str(), iret);

	std::vector<std::string> ips_v;
	ips_v.push_back("8.8.8.8");
	ips_v.push_back("4.4.4.4");
	ips_v.push_back("6.6.6.6");
	ips_v.push_back("127.0.0.1");

	std::vector<std::string> ips_v_out;
	mdns->addr_to_name_a(ips_v, ips_v_out);

	fprintf(stdout, "%zu/%zu results for async DNS lookup:\n", ips_v_out.size(), ips_v.size());

	for(auto v : ips_v_out) {
		fprintf(stdout, "%s\n", v.c_str());
	}

	const char *HTTP = "200 OK\r\nX-Test: 1abc\r\nX-Hdr: abc2\r\nX-Server: 3xyz\r\n\r\ndatas";
	std::map<std::string, std::string> hdrs;
	MathildaUtils::get_http_headers(HTTP, hdrs);

	fprintf(stdout, "HTTP Headers from:\n%s\n", HTTP);

	for(auto const &h : hdrs) {
		fprintf(stdout, "[%s] -> [%s]\n", h.first.c_str(), h.second.c_str());
	}

	auto url = MathildaUtils::normalize_uri("http://www.yahoo.com/test//dir//a");
	fprintf(stdout, "normalize_uri(http://www.yahoo.com/test//dir//a) = %s\n", url.c_str());

	auto host = MathildaUtils::extract_host_from_uri("http://example.test.example.com/something/");
	fprintf(stdout, "extract_host_from_uri(http://example.test.example.com/something) = %s\n", host.c_str());

	auto page = MathildaUtils::extract_path_from_uri("http://example.test.example.com/something/test.php");
	fprintf(stdout, "extract_path_from_uri(http://example.test.example.com/something/test.php) = %s\n", page.c_str());

	ret = MathildaUtils::is_domain_host(".example.com", "/example");
	fprintf(stdout, "is_domain_host(example.com, /example) | ret = %d\n", ret);

	ret = MathildaUtils::is_domain_host(".example.com", "http://www.example.com");
	fprintf(stdout, "is_domain_host(http://www.example.com, http://www.example.com) | ret = %d\n", ret);

	ret = MathildaUtils::is_domain_host(".example.com", "http://sports.exampleaaa.com");
	fprintf(stdout, "is_domain_host(.example.com, http://sports.exampleaaa.com) | ret = %d\n", ret);

	ret = MathildaUtils::is_domain_host(".example.com", "http://example.test.something.com/index.html");
	fprintf(stdout, "is_domain_host(.example.com, http://example.test.something.com/index.html) | ret = %d\n", ret);

	ret = MathildaUtils::is_subdomain("a.b.example.com");
	fprintf(stdout, "is_subdomain(a.b.example.com) | ret = %d\n", ret);

	ret = MathildaUtils::is_subdomain("www.example.com");
	fprintf(stdout, "is_subdomain(www.example.com) | ret = %d\n", ret);

	ret = MathildaUtils::is_http_uri("http://sports.example.com");
	fprintf(stdout, "is_http_uri('http://sports.example.com') | ret = %d\n", ret);

	ret = MathildaUtils::is_http_uri("https://www.example.com");
	fprintf(stdout, "is_http_uri('https://www.example.com') | ret = %d\n", ret);

	ret = MathildaUtils::is_https_uri("https://www.example.com");
	fprintf(stdout, "is_http_uri('https://www.example.com') | ret = %d\n", ret);

	ret = MathildaUtils::is_https_uri("http://www.example.com");
	fprintf(stdout, "is_http_uri('http://www.example.com') | ret = %d\n", ret);

	ret = MathildaUtils::link_blacklist("http://www.example.com");
	fprintf(stdout, "link_blacklist('http://www.example.com') | ret = %d\n", ret);

	ret = MathildaUtils::link_blacklist("http://mail.example2.com");
	fprintf(stdout, "link_blacklist('http://mail.example2.com') | ret = %d\n", ret);

#ifdef SPIDER
	cout << "Spidering..." << endl;
	std::vector<std::string> paths;
	paths.push_back("/index.php");
	auto hh = "your-example-host.com";
	auto d = "your-example-host.com";
	auto cookie_file = "";
	Spider *s = new Spider(paths, hh, d, cookie_file, 80);
    s->run(3);

    for(auto x : s->links) {
        cout << "Discovered Link: " << x.c_str() << endl;
    }

    delete s;
#endif

#ifdef DIRBUSTER
    cout << "Dirbuster..." << endl;

	std::vector <std::string> pages;
	std::vector <std::string> dirs;
	const char *p = "pages.txt";
	const char *d = "dirs.txt";

	MathildaUtils::read_file((char *) p, pages);
	MathildaUtils::read_file((char *) d, dirs);

	std::vector<std::string> hh;
	hh.push_back("your-example-host.com");
	auto cookie_file = "";

    Dirbuster *dirb = new Dirbuster(hh, pages, dirs, cookie_file, 80);
    dirb->run();

	fprintf(stdout, "Dirbuster results:\n");

	for(auto pt : dirb->paths) {
		fprintf(stdout, "%s\n", pt.c_str());
	}

    delete dirb;
#endif

#ifdef LOAD_TEST
	unique_ptr<Mathilda> m(new Mathilda());
	m->finish = my_finish;

	for(int j = 0; j < 20000; j++) {
		Instruction *i = new Instruction((char *) "example.test.example.com", (char *) "/test.html");
		i->before = my_before;
		i->after = my_after;
		m->add_instruction(i);
	}

	m->safe_to_fork = true;
	m->use_shm = false;
	m->execute_instructions();
	m->clear_instructions();
#endif

	return OK;
}