当前位置: 首页>>代码示例>>C++>>正文


C++ LLHost类代码示例

本文整理汇总了C++中LLHost的典型用法代码示例。如果您正苦于以下问题:C++ LLHost类的具体用法?C++ LLHost怎么用?C++ LLHost使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了LLHost类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

	void host_object::test<10>()
	{
		std::string hostStr = "64.233.167.99";		
		LLHost host;
		host.setHostByName(hostStr);	
		ensure("SetHostByName for dotted IP Address failed", host.getAddress() == ip_string_to_u32(hostStr.c_str()));
	}
开发者ID:Xara,项目名称:Opensource-V2-SL-Viewer,代码行数:7,代码来源:llhost_test.cpp

示例2: switch

// static
bool LLFloaterMessageLog::onConfirmCloseCircuit(const LLSD& notification, const LLSD& response )
{
	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
	LLCircuitData* cdp = gMessageSystem->mCircuitInfo.findCircuit(LLHost(notification["payload"]["circuittoclose"].asString()));
	if(!cdp) return false;
	LLViewerRegion* regionp = LLWorld::getInstance()->getRegion(cdp->getHost());
	switch(option)
	{
	case 0: // yes
		gMessageSystem->newMessageFast(_PREHASH_CloseCircuit);
		gMessageSystem->sendReliable(cdp->getHost());
		break;
	case 2: // cancel
		return false;
		break;
	case 1: // no
	default:
		break;
	}
	if(gMessageSystem->findCircuitCode(cdp->getHost()))
		gMessageSystem->disableCircuit(cdp->getHost());
	else
		gMessageSystem->mCircuitInfo.removeCircuitData(cdp->getHost());
	if(regionp)
	{
		LLHost myhost = regionp->getHost();
		LLSD args;
		args["MESSAGE"] = "That host had a region associated with it.\nDo you want to clean that up?";
		LLSD payload;
		payload["regionhost"] = myhost.getString();
		LLNotificationsUtil::add("GenericAlertYesCancel", args, payload, onConfirmRemoveRegion);
	}
	return false;
}
开发者ID:Apelsin,项目名称:EffervescenceViewer,代码行数:35,代码来源:llfloatermessagelog.cpp

示例3: extractDomain

bool LLViewerParcelMedia::allowedMedia(std::string media_url)
{
	LLStringUtil::trim(media_url);
	std::string domain = extractDomain(media_url);
	LLHost host;
	host.setHostByName(domain);
	std::string ip = host.getIPString();
	if (sAllowedMedia.count(domain) || sAllowedMedia.count(ip))
	{
		return true;
	}
	std::string server;
	for (S32 i = 0; i < (S32)sMediaFilterList.size(); i++)
	{
		server = sMediaFilterList[i]["domain"].asString();
		if (server == domain || server == ip)
		{
			if (sMediaFilterList[i]["action"].asString() == "allow")
			{
				return true;
			}
			else
			{
				return false;
			}
		}
	}
	return false;
}
开发者ID:Nekrofage,项目名称:SingularityViewer,代码行数:29,代码来源:llviewerparcelmedia.cpp

示例4: sendPacketImpl

BOOL LLPacketRing::sendPacketImpl(int h_socket, const char * send_buffer, S32 buf_size, LLHost host)
{
	
	if (!LLProxy::isSOCKSProxyEnabled())
	{
		return send_packet(h_socket, send_buffer, buf_size, host.getAddress(), host.getPort());
	}

	char headered_send_buffer[NET_BUFFER_SIZE + SOCKS_HEADER_SIZE];

	proxywrap_t *socks_header = static_cast<proxywrap_t*>(static_cast<void*>(&headered_send_buffer));
	socks_header->rsv   = 0;
	socks_header->addr  = host.getAddress();
	socks_header->port  = htons(host.getPort());
	socks_header->atype = ADDRESS_IPV4;
	socks_header->frag  = 0;

	memcpy(headered_send_buffer + SOCKS_HEADER_SIZE, send_buffer, buf_size);

	return send_packet(	h_socket,
						headered_send_buffer,
						buf_size + SOCKS_HEADER_SIZE,
						LLProxy::getInstance()->getUDPProxy().getAddress(),
						LLProxy::getInstance()->getUDPProxy().getPort());
}
开发者ID:HizWylder,项目名称:GIS,代码行数:25,代码来源:llpacketring.cpp

示例5: tcp_open_channel

S32 tcp_open_channel(LLHost host)
{
    // Open a TCP channel
    // Jump through some hoops to ensure that if the request hosts is down
    // or not reachable connect() does not block

    S32 handle;
    handle = socket(AF_INET, SOCK_STREAM, 0);
    if (!handle)
    {
        llwarns << "Error opening TCP control socket, socket() returned " << handle << llendl;
        return -1;
    }

    struct sockaddr_in address;
    address.sin_port        = htons(host.getPort());
    address.sin_family      = AF_INET;
    address.sin_addr.s_addr = host.getAddress();

    // Non blocking
    WSAEVENT hEvent=WSACreateEvent();
    WSAEventSelect(handle, hEvent, FD_CONNECT) ;
    connect(handle, (struct sockaddr*)&address, sizeof(address)) ;
    // Wait fot 5 seconds, if we can't get a TCP channel open in this
    // time frame then there is something badly wrong.
    WaitForSingleObject(hEvent, 1000*5); // 5 seconds time out

    WSANETWORKEVENTS netevents;
    WSAEnumNetworkEvents(handle,hEvent,&netevents);

    // Check the async event status to see if we connected
    if ((netevents.lNetworkEvents & FD_CONNECT) == FD_CONNECT)
    {
        if (netevents.iErrorCode[FD_CONNECT_BIT] != 0)
        {
            llwarns << "Unable to open TCP channel, WSA returned an error code of " << netevents.iErrorCode[FD_CONNECT_BIT] << llendl;
            WSACloseEvent(hEvent);
            return -1;
        }

        // Now we are connected disable non blocking
        // we don't need support an async interface as
        // currently our only consumer (socks5) will make one round
        // of packets then just hold the connection open
        WSAEventSelect(handle, hEvent, NULL) ;
        unsigned long NonBlock = 0;
        ioctlsocket(handle, FIONBIO, &NonBlock);

        return handle;
    }

    llwarns << "Unable to open TCP channel, Timeout is the host up?" << netevents.iErrorCode[FD_CONNECT_BIT] << llendl;
    return -1;
}
开发者ID:VirtualReality,项目名称:Viewer,代码行数:54,代码来源:net.cpp

示例6: ensure

void host_object::test<9>()
{
    std::string hostStr = "google.com";
    LLHost host;
    host.setHostByName(hostStr);

    // reverse DNS will likely result in appending of some
    // sub-domain to the main hostname. so look for
    // the main domain name and not do the exact compare

    std::string hostname = host.getHostName();
    ensure("getHostName failed", hostname.find(hostStr) != std::string::npos);
}
开发者ID:Tjarko-Holtjer,项目名称:rainbow,代码行数:13,代码来源:llhost_tut.cpp

示例7: str

	void host_object::test<8>()
	{
		const std::string str("192.168.1.1");
		U32 port = 8080;
		LLHost host;
		host.set(str,port);

		std::string ip_string = host.getIPString();
		ensure("Function Failed", (ip_string == str));

		std::string ip_string_port = host.getIPandPort();
		ensure("Function Failed", (ip_string_port == "192.168.1.1:8080"));
	}
开发者ID:Xara,项目名称:Opensource-V2-SL-Viewer,代码行数:13,代码来源:llhost_test.cpp

示例8: onClickCloseCircuit

// static
BOOL LLFloaterMessageLog::onClickCloseCircuit(void* user_data)
{
	LLNetListItem* itemp = (LLNetListItem*)user_data;
	LLCircuitData* cdp = (LLCircuitData*)itemp->mCircuitData;
	if(!cdp) return FALSE;
	LLHost myhost = cdp->getHost();
	LLSD args;
	args["MESSAGE"] = "This will delete local circuit data.\nDo you want to tell the remote host to close the circuit too?";
	LLSD payload;
	payload["circuittoclose"] = myhost.getString(); 
	LLNotificationsUtil::add("GenericAlertYesCancel", args, payload, onConfirmCloseCircuit);
	return TRUE;
}
开发者ID:Apelsin,项目名称:EffervescenceViewer,代码行数:14,代码来源:llfloatermessagelog.cpp

示例9: onBlacklistRemove

void SLFloaterMediaFilter::onBlacklistRemove()
{	
	LLScrollListItem* selected = mBlacklistSLC->getFirstSelected();

	if (selected)
	{
		std::string domain = mBlacklistSLC->getSelectedItemLabel();
		size_t pos = domain.find(' ');
		if (pos != std::string::npos)
		{
			domain = domain.substr(0, pos);
		}

		LLViewerParcelMedia::sDeniedMedia.erase(domain);

		for (S32 i = 0; i < (S32)LLViewerParcelMedia::sMediaFilterList.size(); i++)
		{
			if (LLViewerParcelMedia::sMediaFilterList[i]["domain"].asString() == domain)
			{
				LLViewerParcelMedia::sMediaFilterList.erase(i);
				break;
			}
		}

		if (childGetValue("match_ip") && domain.find('/') == std::string::npos)
		{
			LLHost host;
			host.setHostByName(domain);
			std::string ip = host.getIPString();

			if (ip != domain)
			{
				LLViewerParcelMedia::sDeniedMedia.erase(ip);

				for (S32 i = 0; i < (S32)LLViewerParcelMedia::sMediaFilterList.size(); i++)
				{
					if (LLViewerParcelMedia::sMediaFilterList[i]["domain"].asString() == ip)
					{
						LLViewerParcelMedia::sMediaFilterList.erase(i);
						break;
					}
				}
			}
		}

		LLViewerParcelMedia::saveDomainFilterList();
		setDirty();
	}
}	
开发者ID:ArxNet,项目名称:SingularityViewer,代码行数:49,代码来源:slfloatermediafilter.cpp

示例10: startSOCKSProxy

/**
 * @brief Initiates a SOCKS 5 proxy session.
 *
 * Performs basic checks on host to verify that it is a valid address. Opens the control channel
 * and then negotiates the proxy connection with the server. Closes any existing SOCKS
 * connection before proceeding. Also disables an HTTP proxy if it is using SOCKS as the proxy.
 *
 *
 * @param host Socks server to connect to.
 * @return SOCKS_OK if successful, otherwise a SOCKS error code defined in llproxy.h.
 */
S32 LLProxy::startSOCKSProxy(LLHost host)
{
	if (host.isOk())
	{
		mTCPProxy = host;
	}
	else
	{
		return SOCKS_INVALID_HOST;
	}

	// Close any running SOCKS connection.
	stopSOCKSProxy();

	mProxyControlChannel = tcp_open_channel(mTCPProxy);
	if (!mProxyControlChannel)
	{
		return SOCKS_HOST_CONNECT_FAILED;
	}

	S32 status = proxyHandshake(mTCPProxy);

	if (status != SOCKS_OK)
	{
		// Shut down the proxy if any of the above steps failed.
		stopSOCKSProxy();
	}
	else
	{
		// Connection was successful.
		sUDPProxyEnabled = true;
	}

	return status;
}
开发者ID:AlchemyDev,项目名称:Carbon,代码行数:46,代码来源:llproxy.cpp

示例11: doSendPacket

BOOL LLPacketRing::doSendPacket(int h_socket, const char * send_buffer, S32 buf_size, LLHost host)
{
	
	if (!LLSocks::isEnabled())
	{
		return send_packet(h_socket, send_buffer, buf_size, host.getAddress(), host.getPort());
	}

	proxywrap_t *socks_header = (proxywrap_t *)&mProxyWrappedSendBuffer;
	socks_header->rsv   = 0;
	socks_header->addr  = host.getAddress();
	socks_header->port  = htons(host.getPort());
	socks_header->atype = ADDRESS_IPV4;
	socks_header->frag  = 0;

	memcpy(mProxyWrappedSendBuffer+10, send_buffer, buf_size);

	return send_packet(h_socket,(const char*) mProxyWrappedSendBuffer, buf_size+10, LLSocks::getInstance()->getUDPPproxy().getAddress(), LLSocks::getInstance()->getUDPPproxy().getPort());
}
开发者ID:9skunks,项目名称:imprudence,代码行数:19,代码来源:llpacketring.cpp

示例12: skip

	void host_object::test<9>()
	{
		skip("this test is irreparably flaky");
//		skip("setHostByName(\"google.com\"); getHostName() -> (e.g.) \"yx-in-f100.1e100.net\"");
		// nat: is it reasonable to expect LLHost::getHostName() to echo
		// back something resembling the string passed to setHostByName()?
		//
		// If that's not even reasonable, would a round trip in the /other/
		// direction make more sense? (Call getHostName() for something with
		// known IP address; call setHostByName(); verify IP address)
		//
		// Failing that... is there a plausible way to test getHostName() and
		// setHostByName()? Hopefully without putting up a dummy local DNS
		// server?

		// monty: If you don't control the DNS server or the DNS configuration
		// for the test point then, no, none of these will necessarily be
		// reliable and may start to fail at any time. Forward translation
		// is subject to CNAME records and round-robin address assignment.
		// Reverse lookup is 1-to-many and is more and more likely to have
		// nothing to do with the forward translation.
		// 
		// So the test is increasingly meaningless on a real network.

		std::string hostStr = "lindenlab.com";
		LLHost host;
		host.setHostByName(hostStr);

		// reverse DNS will likely result in appending of some
		// sub-domain to the main hostname. so look for
		// the main domain name and not do the exact compare
		
		std::string hostname = host.getHostName();
		try
		{
			ensure("getHostName failed", hostname.find(hostStr) != std::string::npos);
		}
		catch (const std::exception&)
		{
			std::cerr << "set '" << hostStr << "'; reported '" << hostname << "'" << std::endl;
			throw;
		}
	}
开发者ID:Belxjander,项目名称:Kirito,代码行数:43,代码来源:llhost_test.cpp

示例13: blockingConnect

bool LLSocket::blockingConnect(const LLHost& host)
{
	if(!mSocket) return false;
	apr_sockaddr_t* sa = NULL;
	std::string ip_address;
	ip_address = host.getIPString();
	if(ll_apr_warn_status(apr_sockaddr_info_get(
		&sa,
		ip_address.c_str(),
		APR_UNSPEC,
		host.getPort(),
		0,
		mPool())))
	{
		return false;
	}
	setBlocking(1000);
	ll_debug_socket("Blocking connect", mSocket);
	if(ll_apr_warn_status(apr_socket_connect(mSocket, sa))) return false;
	setNonBlocking();
	return true;
}
开发者ID:DamianZhaoying,项目名称:SingularityViewer,代码行数:22,代码来源:lliosocket.cpp

示例14: enableHTTPProxy

/**
 * @brief Enable the HTTP proxy for either SOCKS or HTTP.
 *
 * Check the supplied host to see if it is a valid IP and port.
 *
 * @param httpHost Proxy server to connect to.
 * @param type Is the host a SOCKS or HTTP proxy.
 * @return Return true if applying the setting was successful. No changes are made if false.
 */
bool LLProxy::enableHTTPProxy(LLHost httpHost, LLHttpProxyType type)
{
	if (!httpHost.isOk())
	{
		LL_WARNS("Proxy") << "Invalid SOCKS 5 Server" << LL_ENDL;
		return false;
	}

	LLMutexLock lock(&mProxyMutex);

	mHTTPProxy        = httpHost;
	mProxyType        = type;

	mHTTPProxyEnabled = true;

	return true;
}
开发者ID:AlchemyDev,项目名称:Carbon,代码行数:26,代码来源:llproxy.cpp

示例15: draw

void SLFloaterMediaFilter::draw()
{
	if (mIsDirty && mWhitelistSLC && mBlacklistSLC)
	{
		S32 whitescrollpos = mWhitelistSLC->getScrollPos();
		S32 blackscrollpos = mBlacklistSLC->getScrollPos();
		mWhitelistSLC->deleteAllItems();
		mBlacklistSLC->deleteAllItems();
		std::set<std::string> listed;
		LLHost host;
		std::string ip;
		std::string domain;
		std::string action;
		LLSD element;
		element["columns"][0]["font"] = "SANSSERIF";
		element["columns"][0]["font-style"] = "BOLD";
		for (S32 i = 0; i < (S32)LLViewerParcelMedia::sMediaFilterList.size(); i++)
		{
			domain = LLViewerParcelMedia::sMediaFilterList[i]["domain"].asString();
			if (mShowIPs)
			{
				host.setHostByName(domain);
				ip = host.getIPString();
				if (ip != domain && domain.find('/') == std::string::npos)
				{
					domain += " (" + ip + ")";
				}
			}

			action = LLViewerParcelMedia::sMediaFilterList[i]["action"].asString();
			if (!domain.empty() && action == "allow")
			{	
				element["columns"][0]["column"] = "whitelist_col";
				element["columns"][0]["value"] = domain;
				//element["columns"][0]["color"] = LLColor4::green3.getValue();
				mWhitelistSLC->addElement(element, ADD_BOTTOM);
				listed.insert(domain);
			}
			else if (!domain.empty() && action == "deny")
			{
				element["columns"][0]["column"] = "blacklist_col";
				element["columns"][0]["value"] = domain;
				//element["columns"][0]["color"] = LLColor4::red2.getValue();
				mBlacklistSLC->addElement(element, ADD_BOTTOM);
				listed.insert(domain);
			}
			else
			{
				LL_WARNS("MediaFilter") << "Bad media filter list: removing corrupted entry for \"" << domain << "\"" << LL_ENDL;
				LLViewerParcelMedia::sMediaFilterList.erase(i--);
			}
		}
		std::set<std::string>::iterator it;
		element["columns"][0]["font"] = "SANSSERIF";
		element["columns"][0]["font-style"] = "ITALIC";
		//element["columns"][0]["color"] = LLColor4::green3.getValue();
		element["columns"][0]["column"] = "whitelist_col";
		for (it = LLViewerParcelMedia::sAllowedMedia.begin(); it != LLViewerParcelMedia::sAllowedMedia.end(); it++)
		{
			domain = *it;
			if (mShowIPs)
			{
				host.setHostByName(domain);
				ip = host.getIPString();
				if (ip != domain && domain.find('/') == std::string::npos)
				{
					domain += " (" + ip + ")";
				}
			}
			if (listed.count(domain) == 0)
			{
				element["columns"][0]["value"] = domain;
				mWhitelistSLC->addElement(element, ADD_BOTTOM);
			}
		}
		element["columns"][0]["column"] = "blacklist_col";
		for (it = LLViewerParcelMedia::sDeniedMedia.begin(); it != LLViewerParcelMedia::sDeniedMedia.end(); it++)
		{
			domain = *it;
			if (mShowIPs)
			{
				host.setHostByName(domain);
				ip = host.getIPString();
				if (ip != domain && domain.find('/') == std::string::npos)
				{
					domain += " (" + ip + ")";
				}
			}
			if (listed.count(domain) == 0)
			{
				element["columns"][0]["value"] = domain;
				mBlacklistSLC->addElement(element, ADD_BOTTOM);
			}
		}
		mWhitelistSLC->setScrollPos(whitescrollpos);
		mBlacklistSLC->setScrollPos(blackscrollpos);

		if (!gSavedSettings.getBOOL("MediaEnableFilter"))
		{
			childDisable("clear_lists");
//.........这里部分代码省略.........
开发者ID:ArxNet,项目名称:SingularityViewer,代码行数:101,代码来源:slfloatermediafilter.cpp


注:本文中的LLHost类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。