本文整理汇总了C++中LLHost::setHostByName方法的典型用法代码示例。如果您正苦于以下问题:C++ LLHost::setHostByName方法的具体用法?C++ LLHost::setHostByName怎么用?C++ LLHost::setHostByName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLHost
的用法示例。
在下文中一共展示了LLHost::setHostByName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()));
}
示例2: allowedMedia
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;
}
示例3: 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);
}
示例4: 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();
}
}
示例5:
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;
}
}
示例6: callback_media_alert
void callback_media_alert(const LLSD ¬ification, const LLSD &response, LLParcel* parcel, U32 type, std::string domain)
{
S32 option = LLNotification::getSelectedOption(notification, response);
LLHost host;
host.setHostByName(domain);
std::string ip = host.getIPString();
LLSD args;
if (ip != domain && domain.find('/') == std::string::npos)
{
args["DOMAIN"] = domain + " (" + ip + ")";
}
else
{
args["DOMAIN"] = domain;
}
if (option == 0 || option == 3) // Allow or Whitelist
{
LLViewerParcelMedia::sAllowedMedia.insert(domain);
if (option == 3) // Whitelist
{
LLSD newmedia;
newmedia["domain"] = domain;
newmedia["action"] = "allow";
LLViewerParcelMedia::sMediaFilterList.append(newmedia);
if (ip != domain && domain.find('/') == std::string::npos)
{
newmedia["domain"] = ip;
LLViewerParcelMedia::sMediaFilterList.append(newmedia);
}
LLViewerParcelMedia::saveDomainFilterList();
args["LISTED"] = "whitelisted";
LLNotificationsUtil::add("MediaListed", args);
}
if (type == 0)
{
LLViewerParcelMedia::play(parcel, false);
}
else
{
LLViewerParcelMedia::playStreamingMusic(parcel, false);
}
}
else if (option == 1 || option == 2) // Deny or Blacklist
{
LLViewerParcelMedia::sDeniedMedia.insert(domain);
if (ip != domain && domain.find('/') == std::string::npos)
{
LLViewerParcelMedia::sDeniedMedia.insert(ip);
}
if (type == 1)
{
LLViewerParcelMedia::stopStreamingMusic();
}
if (option == 1) // Deny
{
LLNotificationsUtil::add("MediaBlocked", args);
}
else // Blacklist
{
LLSD newmedia;
newmedia["domain"] = domain;
newmedia["action"] = "deny";
LLViewerParcelMedia::sMediaFilterList.append(newmedia);
if (ip != domain && domain.find('/') == std::string::npos)
{
newmedia["domain"] = ip;
LLViewerParcelMedia::sMediaFilterList.append(newmedia);
}
LLViewerParcelMedia::saveDomainFilterList();
args["LISTED"] = "blacklisted";
LLNotificationsUtil::add("MediaListed", args);
}
}
LLViewerParcelMedia::sMediaQueries.erase(domain);
SLFloaterMediaFilter::setDirty();
}
示例7: filterMedia
void LLViewerParcelMedia::filterMedia(LLParcel* parcel, U32 type)
{
std::string media_action;
std::string media_url;
std::string domain;
std::string ip;
if (parcel != LLViewerParcelMgr::getInstance()->getAgentParcel())
{
// The parcel just changed (may occur right out after a TP)
sIsUserAction = false;
return;
}
if (type == 0)
{
media_url = parcel->getMediaURL();
}
else
{
media_url = parcel->getMusicURL();
}
LLStringUtil::trim(media_url);
domain = extractDomain(media_url);
if (sMediaQueries.count(domain) > 0)
{
sIsUserAction = false;
return;
}
LLHost host;
host.setHostByName(domain);
ip = host.getIPString();
if (sIsUserAction)
{
// This was a user manual request to play this media, so give
// it another chance...
sIsUserAction = false;
bool dirty = false;
if (sDeniedMedia.count(domain))
{
sDeniedMedia.erase(domain);
dirty = true;
}
if (sDeniedMedia.count(ip))
{
sDeniedMedia.erase(ip);
dirty = true;
}
if (dirty)
{
SLFloaterMediaFilter::setDirty();
}
}
if (media_url.empty())
{
media_action = "allow";
}
else if (!sMediaFilterListLoaded || sDeniedMedia.count(domain) || sDeniedMedia.count(ip))
{
media_action = "ignore";
}
else if (sAllowedMedia.count(domain) || sAllowedMedia.count(ip))
{
media_action = "allow";
}
else
{
std::string server;
for (S32 i = 0; i < (S32)sMediaFilterList.size(); i++)
{
server = sMediaFilterList[i]["domain"].asString();
if (server == domain || server == ip)
{
media_action = sMediaFilterList[i]["action"].asString();
break;
}
}
}
if (media_action == "allow")
{
if (type == 0)
{
play(parcel, false);
}
else
{
playStreamingMusic(parcel, false);
}
return;
}
if (media_action == "ignore")
{
if (type == 1)
{
//.........这里部分代码省略.........
示例8: 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");
//.........这里部分代码省略.........
示例9: onCommitDomain
void SLFloaterMediaFilter::onCommitDomain()
{
std::string domain = childGetText("input_domain");
domain = LLViewerParcelMedia::extractDomain(domain);
LLHost host;
host.setHostByName(domain);
std::string ip = host.getIPString();
bool match_ip = (childGetValue("match_ip") && ip != domain && domain.find('/') == std::string::npos);
if (!domain.empty())
{
LLViewerParcelMedia::sDeniedMedia.erase(domain);
LLViewerParcelMedia::sAllowedMedia.erase(domain);
for (S32 i = 0; i < (S32)LLViewerParcelMedia::sMediaFilterList.size(); i++)
{
if (LLViewerParcelMedia::sMediaFilterList[i]["domain"].asString() == domain)
{
LLViewerParcelMedia::sMediaFilterList.erase(i);
}
}
if (match_ip)
{
LLViewerParcelMedia::sDeniedMedia.erase(ip);
LLViewerParcelMedia::sAllowedMedia.erase(ip);
for (S32 i = 0; i < (S32)LLViewerParcelMedia::sMediaFilterList.size(); i++)
{
if (LLViewerParcelMedia::sMediaFilterList[i]["domain"].asString() == ip)
{
LLViewerParcelMedia::sMediaFilterList.erase(i);
}
}
}
LLSD newmedia;
newmedia["domain"] = domain;
if (mIsWhitelist)
{
newmedia["action"] = "allow";
}
else
{
newmedia["action"] = "deny";
}
LLViewerParcelMedia::sMediaFilterList.append(newmedia);
if (match_ip)
{
newmedia["domain"] = ip;
LLViewerParcelMedia::sMediaFilterList.append(newmedia);
}
LLViewerParcelMedia::saveDomainFilterList();
}
childEnable("clear_lists");
childEnable("show_ips");
childEnable("blacklist_list");
childEnable("whitelist_list");
childEnable("remove_whitelist");
childEnable("add_whitelist");
childEnable("remove_blacklist");
childEnable("add_blacklist");
childDisable("input_domain");
childDisable("commit_domain");
childSetText("add_text", std::string("New domain:"));
childSetText("input_domain", std::string(""));
setDirty();
}