diff options
author | thickbrick | 2011-03-28 20:11:12 +0200 |
---|---|---|
committer | thickbrick | 2011-03-28 20:11:12 +0200 |
commit | f6347b941b08a620d82ba5a11254362f392a439e (patch) | |
tree | fecfdfd1c0e3e110e0df132898192201565e8270 /linden/indra/newview/llviewerparcelmedia.cpp | |
parent | Fix #811: Map tiles are deformed when NOT on Aurora. (diff) | |
download | meta-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 '')
-rw-r--r-- | linden/indra/newview/llviewerparcelmedia.cpp | 108 |
1 files changed, 82 insertions, 26 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 ¬ification, 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 ¬ification, 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 ¬ification, 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 ¬ification, 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 | |||