aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra
diff options
context:
space:
mode:
authorthickbrick2011-03-28 20:11:12 +0200
committerthickbrick2011-03-28 20:11:12 +0200
commitf6347b941b08a620d82ba5a11254362f392a439e (patch)
treefecfdfd1c0e3e110e0df132898192201565e8270 /linden/indra
parentFix #811: Map tiles are deformed when NOT on Aurora. (diff)
downloadmeta-impy-f6347b941b08a620d82ba5a11254362f392a439e.zip
meta-impy-f6347b941b08a620d82ba5a11254362f392a439e.tar.gz
meta-impy-f6347b941b08a620d82ba5a11254362f392a439e.tar.bz2
meta-impy-f6347b941b08a620d82ba5a11254362f392a439e.tar.xz
Sync media filter patch to Henri Beauchamp's MediaFilter_v4
Compared to v3, this adds resolving domains to IPs in order to list them and match them against listed IPs. Also shows both the full stream url and the munged domain that will be added to the lists.
Diffstat (limited to 'linden/indra')
-rw-r--r--linden/indra/newview/llviewerparcelmedia.cpp108
-rw-r--r--linden/indra/newview/skins/default/xui/en-us/floater_media_filter.xml39
-rw-r--r--linden/indra/newview/skins/default/xui/en-us/notifications.xml8
-rw-r--r--linden/indra/newview/slfloatermediafilter.cpp124
-rw-r--r--linden/indra/newview/slfloatermediafilter.h2
5 files changed, 239 insertions, 42 deletions
diff --git a/linden/indra/newview/llviewerparcelmedia.cpp b/linden/indra/newview/llviewerparcelmedia.cpp
index a5d97f2..b816ab4 100644
--- a/linden/indra/newview/llviewerparcelmedia.cpp
+++ b/linden/indra/newview/llviewerparcelmedia.cpp
@@ -649,13 +649,18 @@ bool LLViewerParcelMedia::allowedMedia(std::string media_url)
649{ 649{
650 LLStringUtil::trim(media_url); 650 LLStringUtil::trim(media_url);
651 std::string domain = extractDomain(media_url); 651 std::string domain = extractDomain(media_url);
652 LLHost host;
653 host.setHostByName(domain);
654 std::string ip = host.getIPString();
652 if (sAllowedMedia.count(domain)) 655 if (sAllowedMedia.count(domain))
653 { 656 {
654 return true; 657 return true;
655 } 658 }
659 std::string server;
656 for (S32 i = 0; i < (S32)sMediaFilterList.size(); i++) 660 for (S32 i = 0; i < (S32)sMediaFilterList.size(); i++)
657 { 661 {
658 if (sMediaFilterList[i]["domain"].asString() == domain) 662 server = sMediaFilterList[i]["domain"].asString();
663 if (server == domain || server == ip)
659 { 664 {
660 if (sMediaFilterList[i]["action"].asString() == "allow") 665 if (sMediaFilterList[i]["action"].asString() == "allow")
661 { 666 {
@@ -675,6 +680,7 @@ void LLViewerParcelMedia::filterMedia(LLParcel* parcel, U32 type)
675 std::string media_action; 680 std::string media_action;
676 std::string media_url; 681 std::string media_url;
677 std::string domain; 682 std::string domain;
683 std::string ip;
678 684
679 if (parcel != LLViewerParcelMgr::getInstance()->getAgentParcel()) 685 if (parcel != LLViewerParcelMgr::getInstance()->getAgentParcel())
680 { 686 {
@@ -703,31 +709,51 @@ void LLViewerParcelMedia::filterMedia(LLParcel* parcel, U32 type)
703 return; 709 return;
704 } 710 }
705 711
712 LLHost host;
713 host.setHostByName(domain);
714 ip = host.getIPString();
715
706 if (sIsUserAction) 716 if (sIsUserAction)
707 { 717 {
708 // This was a user manual request to play this media, so give 718 // This was a user manual request to play this media, so give
709 // it another chance... 719 // it another chance...
710 sIsUserAction = false; 720 sIsUserAction = false;
721 bool dirty = false;
711 if (sDeniedMedia.count(domain)) 722 if (sDeniedMedia.count(domain))
712 { 723 {
713 sDeniedMedia.erase(domain); 724 sDeniedMedia.erase(domain);
725 dirty = true;
726 }
727 if (sDeniedMedia.count(ip))
728 {
729 sDeniedMedia.erase(ip);
730 dirty = true;
731 }
732 if (dirty)
733 {
714 SLFloaterMediaFilter::setDirty(); 734 SLFloaterMediaFilter::setDirty();
715 } 735 }
716 } 736 }
717 737
718 if (!sMediaFilterListLoaded || sDeniedMedia.count(domain)) 738 if (media_url.empty())
739 {
740 media_action == "allow";
741 }
742 else if (!sMediaFilterListLoaded || sDeniedMedia.count(domain) || sDeniedMedia.count(ip))
719 { 743 {
720 media_action = "ignore"; 744 media_action = "ignore";
721 } 745 }
722 else if (sAllowedMedia.count(domain)) 746 else if (sAllowedMedia.count(domain) || sAllowedMedia.count(ip))
723 { 747 {
724 media_action = "allow"; 748 media_action = "allow";
725 } 749 }
726 else 750 else
727 { 751 {
752 std::string server;
728 for (S32 i = 0; i < (S32)sMediaFilterList.size(); i++) 753 for (S32 i = 0; i < (S32)sMediaFilterList.size(); i++)
729 { 754 {
730 if (sMediaFilterList[i]["domain"].asString() == domain) 755 server = sMediaFilterList[i]["domain"].asString();
756 if (server == domain || server == ip)
731 { 757 {
732 media_action = sMediaFilterList[i]["action"].asString(); 758 media_action = sMediaFilterList[i]["action"].asString();
733 break; 759 break;
@@ -735,7 +761,7 @@ void LLViewerParcelMedia::filterMedia(LLParcel* parcel, U32 type)
735 } 761 }
736 } 762 }
737 763
738 if (media_action == "allow" || media_url.empty()) 764 if (media_action == "allow")
739 { 765 {
740 if (type == 0) 766 if (type == 0)
741 { 767 {
@@ -745,47 +771,51 @@ void LLViewerParcelMedia::filterMedia(LLParcel* parcel, U32 type)
745 { 771 {
746 playStreamingMusic(parcel, false); 772 playStreamingMusic(parcel, false);
747 } 773 }
774 return;
748 } 775 }
749 else if (media_action == "deny") 776 if (media_action == "ignore")
750 { 777 {
751 LLSD args;
752 args["DOMAIN"] = domain;
753 LLNotifications::instance().add("MediaBlocked", args);
754 if (type == 1) 778 if (type == 1)
755 { 779 {
756 LLViewerParcelMedia::stopStreamingMusic(); 780 LLViewerParcelMedia::stopStreamingMusic();
757 } 781 }
758 // So to avoid other "blocked" messages later in the session 782 return;
759 // for this url should it be requested again by a script. 783 }
760 sDeniedMedia.insert(domain); 784
785 LLSD args;
786 if (ip != domain && domain.find('/') == std::string::npos)
787 {
788 args["DOMAIN"] = domain + " (" + ip + ")";
761 } 789 }
762 else if (media_action == "ignore") 790 else
791 {
792 args["DOMAIN"] = domain;
793 }
794
795 if (media_action == "deny")
763 { 796 {
797 LLNotifications::instance().add("MediaBlocked", args);
764 if (type == 1) 798 if (type == 1)
765 { 799 {
766 LLViewerParcelMedia::stopStreamingMusic(); 800 LLViewerParcelMedia::stopStreamingMusic();
767 } 801 }
802 // So to avoid other "blocked" messages later in the session
803 // for this url should it be requested again by a script.
804 // We don't add the IP, on purpose (want to show different
805 // blocks for different domains pointing to the same IP).
806 sDeniedMedia.insert(domain);
768 } 807 }
769 else 808 else
770 { 809 {
771 sMediaQueries.insert(domain); 810 sMediaQueries.insert(domain);
772 LLSD args; 811 args["URL"] = media_url;
773 args["DOMAIN"] = domain;
774 if (media_url.find('?') != std::string::npos)
775 {
776 args["WARNING"] = " (WARNING: this URL also contains parameter(s) that could potentially be used to correlate your avatar name with your IP)";
777 }
778 else
779 {
780 args["WARNING"] = "";
781 }
782 if (type == 0) 812 if (type == 0)
783 { 813 {
784 args["TYPE"] = "a media"; 814 args["TYPE"] = "media";
785 } 815 }
786 else 816 else
787 { 817 {
788 args["TYPE"] = "an audio"; 818 args["TYPE"] = "audio";
789 } 819 }
790 LLNotifications::instance().add("MediaAlert", args, LLSD(), boost::bind(callback_media_alert, _1, _2, parcel, type, domain)); 820 LLNotifications::instance().add("MediaAlert", args, LLSD(), boost::bind(callback_media_alert, _1, _2, parcel, type, domain));
791 } 821 }
@@ -795,8 +825,19 @@ void callback_media_alert(const LLSD &notification, const LLSD &response, LLParc
795{ 825{
796 S32 option = LLNotification::getSelectedOption(notification, response); 826 S32 option = LLNotification::getSelectedOption(notification, response);
797 827
828 LLHost host;
829 host.setHostByName(domain);
830 std::string ip = host.getIPString();
831
798 LLSD args; 832 LLSD args;
799 args["DOMAIN"] = domain; 833 if (ip != domain && domain.find('/') == std::string::npos)
834 {
835 args["DOMAIN"] = domain + " (" + ip + ")";
836 }
837 else
838 {
839 args["DOMAIN"] = domain;
840 }
800 841
801 if (option == 0 || option == 3) // Allow or Whitelist 842 if (option == 0 || option == 3) // Allow or Whitelist
802 { 843 {
@@ -807,6 +848,11 @@ void callback_media_alert(const LLSD &notification, const LLSD &response, LLParc
807 newmedia["domain"] = domain; 848 newmedia["domain"] = domain;
808 newmedia["action"] = "allow"; 849 newmedia["action"] = "allow";
809 LLViewerParcelMedia::sMediaFilterList.append(newmedia); 850 LLViewerParcelMedia::sMediaFilterList.append(newmedia);
851 if (ip != domain && domain.find('/') == std::string::npos)
852 {
853 newmedia["domain"] = ip;
854 LLViewerParcelMedia::sMediaFilterList.append(newmedia);
855 }
810 LLViewerParcelMedia::saveDomainFilterList(); 856 LLViewerParcelMedia::saveDomainFilterList();
811 args["LISTED"] = "whitelisted"; 857 args["LISTED"] = "whitelisted";
812 LLNotifications::instance().add("MediaListed", args); 858 LLNotifications::instance().add("MediaListed", args);
@@ -823,6 +869,10 @@ void callback_media_alert(const LLSD &notification, const LLSD &response, LLParc
823 else if (option == 1 || option == 2) // Deny or Blacklist 869 else if (option == 1 || option == 2) // Deny or Blacklist
824 { 870 {
825 LLViewerParcelMedia::sDeniedMedia.insert(domain); 871 LLViewerParcelMedia::sDeniedMedia.insert(domain);
872 if (ip != domain && domain.find('/') == std::string::npos)
873 {
874 LLViewerParcelMedia::sDeniedMedia.insert(ip);
875 }
826 if (type == 1) 876 if (type == 1)
827 { 877 {
828 LLViewerParcelMedia::stopStreamingMusic(); 878 LLViewerParcelMedia::stopStreamingMusic();
@@ -837,6 +887,11 @@ void callback_media_alert(const LLSD &notification, const LLSD &response, LLParc
837 newmedia["domain"] = domain; 887 newmedia["domain"] = domain;
838 newmedia["action"] = "deny"; 888 newmedia["action"] = "deny";
839 LLViewerParcelMedia::sMediaFilterList.append(newmedia); 889 LLViewerParcelMedia::sMediaFilterList.append(newmedia);
890 if (ip != domain && domain.find('/') == std::string::npos)
891 {
892 newmedia["domain"] = ip;
893 LLViewerParcelMedia::sMediaFilterList.append(newmedia);
894 }
840 LLViewerParcelMedia::saveDomainFilterList(); 895 LLViewerParcelMedia::saveDomainFilterList();
841 args["LISTED"] = "blacklisted"; 896 args["LISTED"] = "blacklisted";
842 LLNotifications::instance().add("MediaListed", args); 897 LLNotifications::instance().add("MediaListed", args);
@@ -975,3 +1030,4 @@ std::string LLViewerParcelMedia::extractDomain(std::string url)
975 1030
976 return url; 1031 return url;
977} 1032}
1033
diff --git a/linden/indra/newview/skins/default/xui/en-us/floater_media_filter.xml b/linden/indra/newview/skins/default/xui/en-us/floater_media_filter.xml
index 9b7355c..5faaf1a 100644
--- a/linden/indra/newview/skins/default/xui/en-us/floater_media_filter.xml
+++ b/linden/indra/newview/skins/default/xui/en-us/floater_media_filter.xml
@@ -15,47 +15,64 @@
15 background_visible="true" mouse_opaque="true" 15 background_visible="true" mouse_opaque="true"
16 multi_select="false" column_padding="5" draw_border="true" draw_heading="true" 16 multi_select="false" column_padding="5" draw_border="true" draw_heading="true"
17 bottom_delta="-205" left="15" height="200" width="280"> 17 bottom_delta="-205" left="15" height="200" width="280">
18 <column name="whitelist_col" label="Allowed domains/objects" dynamicwidth="true" /> 18 <column name="whitelist_col" label="Allowed domains or server objects" dynamicwidth="true" />
19 </scroll_list> 19 </scroll_list>
20 20
21 <scroll_list name="blacklist_list" follows="top|bottom|right" 21 <scroll_list name="blacklist_list" follows="top|bottom|right"
22 background_visible="true" mouse_opaque="true" 22 background_visible="true" mouse_opaque="true"
23 multi_select="false" column_padding="5" draw_border="true" draw_heading="true" 23 multi_select="false" column_padding="5" draw_border="true" draw_heading="true"
24 bottom_delta="0" right="-15" height="200" width="280"> 24 bottom_delta="0" right="-15" height="200" width="280">
25 <column name="blacklist_col" label="Blocked domains/objects" dynamicwidth="true" /> 25 <column name="blacklist_col" label="Blocked domains or server objects" dynamicwidth="true" />
26 </scroll_list> 26 </scroll_list>
27 27
28 <button name="add_whitelist" font="SansSerif" label="Add..." halign="center" 28 <button name="add_whitelist" font="SansSerif" label="Add..." halign="center"
29 tool_tip="Add a server to the whitelist"
29 enabled="true" mouse_opaque="true" follows="bottom|left" 30 enabled="true" mouse_opaque="true" follows="bottom|left"
30 bottom_delta="-25" left="30" height="20" width="80" /> 31 bottom_delta="-25" left="15" height="20" width="80" />
31 32
32 <button name="remove_whitelist" font="SansSerif" label="Remove" halign="center" 33 <button name="remove_whitelist" font="SansSerif" label="Remove" halign="center"
34 tool_tip="Remove the selected server from the whitelist"
33 enabled="true" mouse_opaque="true" follows="bottom|left" 35 enabled="true" mouse_opaque="true" follows="bottom|left"
34 bottom_delta="0" left_delta="100" height="20" width="80" /> 36 bottom_delta="0" left="100" height="20" width="80" />
35 37
36 <button name="clear_lists" font="SansSerif" label="Clear lists" halign="center" 38 <button name="clear_lists" font="SansSerif" label="Clear lists" halign="center"
37 enabled="true" mouse_opaque="true" follows="bottom|left|right" 39 tool_tip="Clear all lists"
38 bottom_delta="0" left_delta="110" height="20" width="120" /> 40 enabled="true" mouse_opaque="true" follows="bottom|left"
41 bottom_delta="0" left="205" height="20" width="90" />
42
43 <button name="show_ips" font="SansSerif" label="Show IPs" halign="center"
44 tool_tip="Show the IP associated with each domain name (makes the viewer pause while the list is refreshed, because of DNS lookups)"
45 enabled="true" mouse_opaque="true" follows="bottom|right"
46 bottom_delta="0" right="-205" height="20" width="90" />
39 47
40 <button name="add_blacklist" font="SansSerif" label="Add..." halign="center" 48 <button name="add_blacklist" font="SansSerif" label="Add..." halign="center"
49 tool_tip="Add a server to the blacklist"
41 enabled="true" mouse_opaque="true" follows="bottom|right" 50 enabled="true" mouse_opaque="true" follows="bottom|right"
42 bottom_delta="0" right="-130" height="20" width="80" /> 51 bottom_delta="0" right="-100" height="20" width="80" />
43 52
44 <button name="remove_blacklist" font="SansSerif" label="Remove" halign="center" 53 <button name="remove_blacklist" font="SansSerif" label="Remove" halign="center"
54 tool_tip="Remove the selected server from the blacklist"
45 enabled="true" mouse_opaque="true" follows="bottom|right" 55 enabled="true" mouse_opaque="true" follows="bottom|right"
46 bottom_delta="0" right="-30" height="20" width="80" /> 56 bottom_delta="0" right="-15" height="20" width="80" />
47 57
48 <text name="add_text" font="SansSerif" mouse_opaque="true" enabled="true" 58 <text name="add_text" font="SansSerif" mouse_opaque="true"
49 bottom_delta="-25" left="20" height="20" width="500" follows="left|right|bottom"> 59 bottom_delta="-25" left="20" height="20" width="450" follows="left|right|bottom">
50 New domain: 60 New domain:
51 </text> 61 </text>
52 62
63 <check_box name="match_ip" label="Add/remove matching IP" initial_value="true"
64 tool_tip="Add or remove any IP associated with the added or removed domain name"
65 font="SansSerifSmall" mouse_opaque="true" radio_style="false"
66 bottom_delta="2" right="-95" height="16" width="70" follows="right|bottom" />
67
53 <line_editor name="input_domain" max_length="255" font="SansSerif" enabled="false" 68 <line_editor name="input_domain" max_length="255" font="SansSerif" enabled="false"
69 tool_tip="Enter the new URL, domain name, IP or scripted object HTTP server path here"
54 select_all_on_focus_received="true" select_on_focus="true" 70 select_all_on_focus_received="true" select_on_focus="true"
55 bevel_style="in" border_style="line" border_thickness="1" 71 bevel_style="in" border_style="line" border_thickness="1"
56 bottom_delta="-20" right="-100" height="20" left="15" follows="left|bottom|right"/> 72 bottom_delta="-22" right="-100" height="20" left="15" follows="left|bottom|right"/>
57 73
58 <button name="commit_domain" font="SansSerif" label="Add" halign="center" enabled="false" 74 <button name="commit_domain" font="SansSerif" label="Add" halign="center" enabled="false"
75 tool_tip="Add to the list"
59 mouse_opaque="true" follows="bottom|right" 76 mouse_opaque="true" follows="bottom|right"
60 bottom_delta="0" right="-15" height="20" width="80"/> 77 bottom_delta="0" right="-15" height="20" width="80"/>
61</floater> 78</floater>
diff --git a/linden/indra/newview/skins/default/xui/en-us/notifications.xml b/linden/indra/newview/skins/default/xui/en-us/notifications.xml
index 27f5529..aa4a1b5 100644
--- a/linden/indra/newview/skins/default/xui/en-us/notifications.xml
+++ b/linden/indra/newview/skins/default/xui/en-us/notifications.xml
@@ -7324,11 +7324,15 @@ The Second Life Terms of Service do not allow you to opt out. By logging in to S
7324 icon="alert.tga" 7324 icon="alert.tga"
7325 name="MediaAlert" 7325 name="MediaAlert"
7326 type="alert"> 7326 type="alert">
7327The owner of this parcel has requested [TYPE] URL pertaining to the following domain or scripted object to be loaded by your viewer[WARNING]: 7327The owner of this parcel has requested the following [TYPE] URL to be loaded by your viewer:
7328
7329[URL]
7330
7331You may choose to allow or deny the corresponding domain or in-world scripted object server:
7328 7332
7329[DOMAIN] 7333[DOMAIN]
7330 7334
7331"Allow" and "Deny" apply only for this session, while "Blacklist" and "Whitelist" apply forever to the above domain or scripted object. 7335"Allow" and "Deny" apply only for this session, while "Blacklist" and "Whitelist" apply forever.
7332 <form name="form"> 7336 <form name="form">
7333 <button 7337 <button
7334 index="0" 7338 index="0"
diff --git a/linden/indra/newview/slfloatermediafilter.cpp b/linden/indra/newview/slfloatermediafilter.cpp
index c47ed26..7b287e0 100644
--- a/linden/indra/newview/slfloatermediafilter.cpp
+++ b/linden/indra/newview/slfloatermediafilter.cpp
@@ -43,6 +43,7 @@
43 43
44SLFloaterMediaFilter* SLFloaterMediaFilter::sInstance = NULL; 44SLFloaterMediaFilter* SLFloaterMediaFilter::sInstance = NULL;
45bool SLFloaterMediaFilter::sIsWhitelist = false; 45bool SLFloaterMediaFilter::sIsWhitelist = false;
46bool SLFloaterMediaFilter::sShowIPs = false;
46 47
47SLFloaterMediaFilter::SLFloaterMediaFilter() : LLFloater(std::string("media filter")), mIsDirty(false) 48SLFloaterMediaFilter::SLFloaterMediaFilter() : LLFloater(std::string("media filter")), mIsDirty(false)
48{ 49{
@@ -62,6 +63,7 @@ BOOL SLFloaterMediaFilter::postBuild()
62 if (mWhitelistSLC && mBlacklistSLC) 63 if (mWhitelistSLC && mBlacklistSLC)
63 { 64 {
64 childSetAction("clear_lists", onClearLists, this); 65 childSetAction("clear_lists", onClearLists, this);
66 childSetAction("show_ips", onShowIPs, this);
65 childSetAction("add_whitelist", onWhitelistAdd, this); 67 childSetAction("add_whitelist", onWhitelistAdd, this);
66 childSetAction("remove_whitelist", onWhitelistRemove, this); 68 childSetAction("remove_whitelist", onWhitelistRemove, this);
67 childSetAction("add_blacklist", onBlacklistAdd, this); 69 childSetAction("add_blacklist", onBlacklistAdd, this);
@@ -84,6 +86,8 @@ void SLFloaterMediaFilter::draw()
84 mWhitelistSLC->deleteAllItems(); 86 mWhitelistSLC->deleteAllItems();
85 mBlacklistSLC->deleteAllItems(); 87 mBlacklistSLC->deleteAllItems();
86 std::set<std::string> listed; 88 std::set<std::string> listed;
89 LLHost host;
90 std::string ip;
87 std::string domain; 91 std::string domain;
88 std::string action; 92 std::string action;
89 LLSD element; 93 LLSD element;
@@ -92,6 +96,16 @@ void SLFloaterMediaFilter::draw()
92 for (S32 i = 0; i < (S32)LLViewerParcelMedia::sMediaFilterList.size(); i++) 96 for (S32 i = 0; i < (S32)LLViewerParcelMedia::sMediaFilterList.size(); i++)
93 { 97 {
94 domain = LLViewerParcelMedia::sMediaFilterList[i]["domain"].asString(); 98 domain = LLViewerParcelMedia::sMediaFilterList[i]["domain"].asString();
99 if (sShowIPs)
100 {
101 host.setHostByName(domain);
102 ip = host.getIPString();
103 if (ip != domain && domain.find('/') == std::string::npos)
104 {
105 domain += " (" + ip + ")";
106 }
107 }
108
95 action = LLViewerParcelMedia::sMediaFilterList[i]["action"].asString(); 109 action = LLViewerParcelMedia::sMediaFilterList[i]["action"].asString();
96 if (!domain.empty() && action == "allow") 110 if (!domain.empty() && action == "allow")
97 { 111 {
@@ -123,6 +137,15 @@ void SLFloaterMediaFilter::draw()
123 for (it = LLViewerParcelMedia::sAllowedMedia.begin(); it != LLViewerParcelMedia::sAllowedMedia.end(); it++) 137 for (it = LLViewerParcelMedia::sAllowedMedia.begin(); it != LLViewerParcelMedia::sAllowedMedia.end(); it++)
124 { 138 {
125 domain = *it; 139 domain = *it;
140 if (sShowIPs)
141 {
142 host.setHostByName(domain);
143 ip = host.getIPString();
144 if (ip != domain && domain.find('/') == std::string::npos)
145 {
146 domain += " (" + ip + ")";
147 }
148 }
126 if (listed.count(domain) == 0) 149 if (listed.count(domain) == 0)
127 { 150 {
128 element["columns"][0]["value"] = domain; 151 element["columns"][0]["value"] = domain;
@@ -133,6 +156,15 @@ void SLFloaterMediaFilter::draw()
133 for (it = LLViewerParcelMedia::sDeniedMedia.begin(); it != LLViewerParcelMedia::sDeniedMedia.end(); it++) 156 for (it = LLViewerParcelMedia::sDeniedMedia.begin(); it != LLViewerParcelMedia::sDeniedMedia.end(); it++)
134 { 157 {
135 domain = *it; 158 domain = *it;
159 if (sShowIPs)
160 {
161 host.setHostByName(domain);
162 ip = host.getIPString();
163 if (ip != domain && domain.find('/') == std::string::npos)
164 {
165 domain += " (" + ip + ")";
166 }
167 }
136 if (listed.count(domain) == 0) 168 if (listed.count(domain) == 0)
137 { 169 {
138 element["columns"][0]["value"] = domain; 170 element["columns"][0]["value"] = domain;
@@ -145,18 +177,21 @@ void SLFloaterMediaFilter::draw()
145 if (!gSavedSettings.getBOOL("MediaEnableFilter")) 177 if (!gSavedSettings.getBOOL("MediaEnableFilter"))
146 { 178 {
147 childDisable("clear_lists"); 179 childDisable("clear_lists");
180 childDisable("show_ips");
148 childDisable("blacklist_list"); 181 childDisable("blacklist_list");
149 childDisable("whitelist_list"); 182 childDisable("whitelist_list");
150 childDisable("remove_whitelist"); 183 childDisable("remove_whitelist");
151 childDisable("add_whitelist"); 184 childDisable("add_whitelist");
152 childDisable("remove_blacklist"); 185 childDisable("remove_blacklist");
153 childDisable("add_blacklist"); 186 childDisable("add_blacklist");
187 childDisable("match_ip");
154 childDisable("input_domain"); 188 childDisable("input_domain");
155 childDisable("commit_domain"); 189 childDisable("commit_domain");
156 childSetText("add_text", std::string("****** WARNING: media filtering is currently DISABLED ******")); 190 childSetText("add_text", std::string("****** WARNING: media filtering is currently DISABLED ******"));
157 } 191 }
158 192
159 mIsDirty = false; 193 mIsDirty = false;
194 sShowIPs = false;
160 } 195 }
161 196
162 LLFloater::draw(); 197 LLFloater::draw();
@@ -208,6 +243,12 @@ void SLFloaterMediaFilter::onClearLists(void* data)
208 LLViewerParcelMedia::clearDomainFilterList(); 243 LLViewerParcelMedia::clearDomainFilterList();
209} 244}
210 245
246void SLFloaterMediaFilter::onShowIPs(void* data)
247{
248 sShowIPs = true;
249 setDirty();
250}
251
211void SLFloaterMediaFilter::onWhitelistAdd(void* data) 252void SLFloaterMediaFilter::onWhitelistAdd(void* data)
212{ 253{
213 if (!sInstance) 254 if (!sInstance)
@@ -215,6 +256,7 @@ void SLFloaterMediaFilter::onWhitelistAdd(void* data)
215 return; 256 return;
216 } 257 }
217 sInstance->childDisable("clear_lists"); 258 sInstance->childDisable("clear_lists");
259 sInstance->childDisable("show_ips");
218 sInstance->childDisable("blacklist_list"); 260 sInstance->childDisable("blacklist_list");
219 sInstance->childDisable("whitelist_list"); 261 sInstance->childDisable("whitelist_list");
220 sInstance->childDisable("remove_whitelist"); 262 sInstance->childDisable("remove_whitelist");
@@ -238,6 +280,12 @@ void SLFloaterMediaFilter::onWhitelistRemove(void* data)
238 if (selected) 280 if (selected)
239 { 281 {
240 std::string domain = sInstance->mWhitelistSLC->getSelectedItemLabel(); 282 std::string domain = sInstance->mWhitelistSLC->getSelectedItemLabel();
283 size_t pos = domain.find(' ');
284 if (pos != std::string::npos)
285 {
286 domain = domain.substr(0, pos);
287 }
288
241 LLViewerParcelMedia::sAllowedMedia.erase(domain); 289 LLViewerParcelMedia::sAllowedMedia.erase(domain);
242 290
243 for (S32 i = 0; i < (S32)LLViewerParcelMedia::sMediaFilterList.size(); i++) 291 for (S32 i = 0; i < (S32)LLViewerParcelMedia::sMediaFilterList.size(); i++)
@@ -245,11 +293,32 @@ void SLFloaterMediaFilter::onWhitelistRemove(void* data)
245 if (LLViewerParcelMedia::sMediaFilterList[i]["domain"].asString() == domain) 293 if (LLViewerParcelMedia::sMediaFilterList[i]["domain"].asString() == domain)
246 { 294 {
247 LLViewerParcelMedia::sMediaFilterList.erase(i); 295 LLViewerParcelMedia::sMediaFilterList.erase(i);
248 LLViewerParcelMedia::saveDomainFilterList();
249 break; 296 break;
250 } 297 }
251 } 298 }
252 299
300 if (sInstance->childGetValue("match_ip") && domain.find('/') == std::string::npos)
301 {
302 LLHost host;
303 host.setHostByName(domain);
304 std::string ip = host.getIPString();
305
306 if (ip != domain)
307 {
308 LLViewerParcelMedia::sAllowedMedia.erase(ip);
309
310 for (S32 i = 0; i < (S32)LLViewerParcelMedia::sMediaFilterList.size(); i++)
311 {
312 if (LLViewerParcelMedia::sMediaFilterList[i]["domain"].asString() == ip)
313 {
314 LLViewerParcelMedia::sMediaFilterList.erase(i);
315 break;
316 }
317 }
318 }
319 }
320
321 LLViewerParcelMedia::saveDomainFilterList();
253 setDirty(); 322 setDirty();
254 } 323 }
255} 324}
@@ -261,6 +330,7 @@ void SLFloaterMediaFilter::onBlacklistAdd(void* data)
261 return; 330 return;
262 } 331 }
263 sInstance->childDisable("clear_lists"); 332 sInstance->childDisable("clear_lists");
333 sInstance->childDisable("show_ips");
264 sInstance->childDisable("blacklist_list"); 334 sInstance->childDisable("blacklist_list");
265 sInstance->childDisable("whitelist_list"); 335 sInstance->childDisable("whitelist_list");
266 sInstance->childDisable("remove_whitelist"); 336 sInstance->childDisable("remove_whitelist");
@@ -284,6 +354,12 @@ void SLFloaterMediaFilter::onBlacklistRemove(void* data)
284 if (selected) 354 if (selected)
285 { 355 {
286 std::string domain = sInstance->mBlacklistSLC->getSelectedItemLabel(); 356 std::string domain = sInstance->mBlacklistSLC->getSelectedItemLabel();
357 size_t pos = domain.find(' ');
358 if (pos != std::string::npos)
359 {
360 domain = domain.substr(0, pos);
361 }
362
287 LLViewerParcelMedia::sDeniedMedia.erase(domain); 363 LLViewerParcelMedia::sDeniedMedia.erase(domain);
288 364
289 for (S32 i = 0; i < (S32)LLViewerParcelMedia::sMediaFilterList.size(); i++) 365 for (S32 i = 0; i < (S32)LLViewerParcelMedia::sMediaFilterList.size(); i++)
@@ -291,11 +367,32 @@ void SLFloaterMediaFilter::onBlacklistRemove(void* data)
291 if (LLViewerParcelMedia::sMediaFilterList[i]["domain"].asString() == domain) 367 if (LLViewerParcelMedia::sMediaFilterList[i]["domain"].asString() == domain)
292 { 368 {
293 LLViewerParcelMedia::sMediaFilterList.erase(i); 369 LLViewerParcelMedia::sMediaFilterList.erase(i);
294 LLViewerParcelMedia::saveDomainFilterList();
295 break; 370 break;
296 } 371 }
297 } 372 }
298 373
374 if (sInstance->childGetValue("match_ip") && domain.find('/') == std::string::npos)
375 {
376 LLHost host;
377 host.setHostByName(domain);
378 std::string ip = host.getIPString();
379
380 if (ip != domain)
381 {
382 LLViewerParcelMedia::sDeniedMedia.erase(ip);
383
384 for (S32 i = 0; i < (S32)LLViewerParcelMedia::sMediaFilterList.size(); i++)
385 {
386 if (LLViewerParcelMedia::sMediaFilterList[i]["domain"].asString() == ip)
387 {
388 LLViewerParcelMedia::sMediaFilterList.erase(i);
389 break;
390 }
391 }
392 }
393 }
394
395 LLViewerParcelMedia::saveDomainFilterList();
299 setDirty(); 396 setDirty();
300 } 397 }
301} 398}
@@ -308,6 +405,10 @@ void SLFloaterMediaFilter::onCommitDomain(void* data)
308 } 405 }
309 std::string domain = sInstance->childGetText("input_domain"); 406 std::string domain = sInstance->childGetText("input_domain");
310 domain = LLViewerParcelMedia::extractDomain(domain); 407 domain = LLViewerParcelMedia::extractDomain(domain);
408 LLHost host;
409 host.setHostByName(domain);
410 std::string ip = host.getIPString();
411 bool match_ip = (sInstance->childGetValue("match_ip") && ip != domain && domain.find('/') == std::string::npos);
311 412
312 if (!domain.empty()) 413 if (!domain.empty())
313 { 414 {
@@ -318,7 +419,18 @@ void SLFloaterMediaFilter::onCommitDomain(void* data)
318 if (LLViewerParcelMedia::sMediaFilterList[i]["domain"].asString() == domain) 419 if (LLViewerParcelMedia::sMediaFilterList[i]["domain"].asString() == domain)
319 { 420 {
320 LLViewerParcelMedia::sMediaFilterList.erase(i); 421 LLViewerParcelMedia::sMediaFilterList.erase(i);
321 break; 422 }
423 }
424 if (match_ip)
425 {
426 LLViewerParcelMedia::sDeniedMedia.erase(ip);
427 LLViewerParcelMedia::sAllowedMedia.erase(ip);
428 for (S32 i = 0; i < (S32)LLViewerParcelMedia::sMediaFilterList.size(); i++)
429 {
430 if (LLViewerParcelMedia::sMediaFilterList[i]["domain"].asString() == ip)
431 {
432 LLViewerParcelMedia::sMediaFilterList.erase(i);
433 }
322 } 434 }
323 } 435 }
324 LLSD newmedia; 436 LLSD newmedia;
@@ -332,10 +444,16 @@ void SLFloaterMediaFilter::onCommitDomain(void* data)
332 newmedia["action"] = "deny"; 444 newmedia["action"] = "deny";
333 } 445 }
334 LLViewerParcelMedia::sMediaFilterList.append(newmedia); 446 LLViewerParcelMedia::sMediaFilterList.append(newmedia);
447 if (match_ip)
448 {
449 newmedia["domain"] = ip;
450 LLViewerParcelMedia::sMediaFilterList.append(newmedia);
451 }
335 LLViewerParcelMedia::saveDomainFilterList(); 452 LLViewerParcelMedia::saveDomainFilterList();
336 } 453 }
337 454
338 sInstance->childEnable("clear_lists"); 455 sInstance->childEnable("clear_lists");
456 sInstance->childEnable("show_ips");
339 sInstance->childEnable("blacklist_list"); 457 sInstance->childEnable("blacklist_list");
340 sInstance->childEnable("whitelist_list"); 458 sInstance->childEnable("whitelist_list");
341 sInstance->childEnable("remove_whitelist"); 459 sInstance->childEnable("remove_whitelist");
diff --git a/linden/indra/newview/slfloatermediafilter.h b/linden/indra/newview/slfloatermediafilter.h
index 0f900be..aafa5a2 100644
--- a/linden/indra/newview/slfloatermediafilter.h
+++ b/linden/indra/newview/slfloatermediafilter.h
@@ -52,6 +52,7 @@ public:
52 static void toggleInstance(); 52 static void toggleInstance();
53 53
54 static void onClearLists(void*); 54 static void onClearLists(void*);
55 static void onShowIPs(void*);
55 static void onWhitelistAdd(void*); 56 static void onWhitelistAdd(void*);
56 static void onWhitelistRemove(void*); 57 static void onWhitelistRemove(void*);
57 static void onBlacklistAdd(void*); 58 static void onBlacklistAdd(void*);
@@ -60,6 +61,7 @@ public:
60 61
61private: 62private:
62 static bool sIsWhitelist; 63 static bool sIsWhitelist;
64 static bool sShowIPs;
63 LLScrollListCtrl* mWhitelistSLC; 65 LLScrollListCtrl* mWhitelistSLC;
64 LLScrollListCtrl* mBlacklistSLC; 66 LLScrollListCtrl* mBlacklistSLC;
65 bool mIsDirty; 67 bool mIsDirty;