void http_connect_handler(http_connection& c)
{
	++connect_handler_called;
	TEST_CHECK(c.socket().is_open());
	std::cerr << "connected to: " << c.socket().remote_endpoint() << std::endl;
	TEST_CHECK(c.socket().remote_endpoint().address() == address::from_string("127.0.0.1"));
}
void http_connect_handler(http_connection& c)
{
	++connect_handler_called;
	TEST_CHECK(c.socket().is_open());
	error_code ec;
	std::cerr << time_now_string() << " connected to: " << print_endpoint(c.socket().remote_endpoint(ec))
		<< std::endl;
// this is not necessarily true when using a proxy and proxying hostnames
//	TEST_CHECK(c.socket().remote_endpoint(ec).address() == address::from_string("127.0.0.1", ec));
}
void http_tracker_connection::on_connect(http_connection& c)
{
    error_code ec;
    tcp::endpoint ep = c.socket().remote_endpoint(ec);
    m_tracker_ip = ep.address();
    boost::shared_ptr<request_callback> cb = requester();
}
Example #4
0
void upnp::create_port_mapping(http_connection& c, rootdevice& d, int i)
{
	mutex_t::scoped_lock l(m_mutex);

	TORRENT_ASSERT(d.magic == 1337);

	if (!d.upnp_connection)
	{
		TORRENT_ASSERT(d.disabled);
		char msg[200];
		snprintf(msg, sizeof(msg), "mapping %u aborted", i);
		log(msg);
		return;
	}
	
	char const* soap_action = "AddPortMapping";

	char soap[2048];
	error_code ec;
	snprintf(soap, sizeof(soap), "<?xml version=\"1.0\"?>\n"
		"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" "
		"s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
		"<s:Body><u:%s xmlns:u=\"%s\">"
		"<NewRemoteHost></NewRemoteHost>"
		"<NewExternalPort>%u</NewExternalPort>"
		"<NewProtocol>%s</NewProtocol>"
		"<NewInternalPort>%u</NewInternalPort>"
		"<NewInternalClient>%s</NewInternalClient>"
		"<NewEnabled>1</NewEnabled>"
		"<NewPortMappingDescription>%s</NewPortMappingDescription>"
		"<NewLeaseDuration>%u</NewLeaseDuration>"
		"</u:%s></s:Body></s:Envelope>"
		, soap_action, d.service_namespace, d.mapping[i].external_port
		, (d.mapping[i].protocol == udp ? "UDP" : "TCP")
		, d.mapping[i].local_port
		, print_address(c.socket().local_endpoint(ec).address()).c_str()
		, m_user_agent.c_str(), d.lease_duration, soap_action);

	post(d, soap, soap_action);
}