本文整理汇总了C++中LLHost::getIPString方法的典型用法代码示例。如果您正苦于以下问题:C++ LLHost::getIPString方法的具体用法?C++ LLHost::getIPString怎么用?C++ LLHost::getIPString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLHost
的用法示例。
在下文中一共展示了LLHost::getIPString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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"));
}
示例3: 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();
}
}
示例4: 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;
}
示例5: 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();
}
示例6: 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)
{
//.........这里部分代码省略.........
示例7: 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");
//.........这里部分代码省略.........
示例8: 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();
}