Re: [codepatch] Re: [discuss] block all hosts

Chuck McNulty <[email protected]> Tue, 29 Mar 2005 15:20:23 -0500
Newsgroups gmane.network.gnutella.limewire.general
Message-ID <[email protected]>
Hi Sam, I'm still testing my patch for effectiveness, and so far I've 
been somewhat disappointed.  I blocked a couple hundred hosts yesterday, 
and it seemed like the results from spammers tapered off, but when I 
tested again today I got just as many hits as I ever have.  I blocked a 
few more hundred today and it doesn't seem to have had much effect on 
the number of spam hits.   I'll keep trying over the next few days to 
see if I can effectively block them using this method (and also to test 
if there are any performance problems as the list of blocked hosts grows 
into the thousands), but I'm a lot less confident than I was yesterday. 

I still think it's a worthwhile patch, it just doesn't solve the problem 
(yet) that I'd hoped it would solve.  On the bright side, the less 
sophisticated spammers (the ones that put a whole lot of popular search 
queries in a single file name) have been blocked much more effectively 
so far. 

I think a much more effective solution is going to be to block the SHA 
hashes, which I think are fairly constant.  Bitzi at any rate knows of 
most of them and has marked them as "Dangerous" which is a hopeful 
sign.  Is there anything I could do to move along merging in the work 
that has already been done to block files?

Also I tried to take a deeper look into how many results were being 
filtered in a search, and I think I found a bug which I'll be trying to 
kill in the next couple of days.  It seems that line 488 of 
SearchResultDisplayer.java is never reached, when it clearly should be 
some of the time (especially when I'm blocking hundreds of hosts).  Here 
is the code... basically (current < total) never seems to evaluate to true.
   
    /**
     * Returns the title of the specified ResultPanel.
     */
    private String titleOf(ResultPanel rp) {
        int current = rp.filteredSources();
        int total = rp.totalSources();
        if(current < total)
            return rp.getQuery() + " ("  + current + "/" + total + ")";
        else
            return rp.getQuery() + " (" + total + ")";
    }   


In a related issue, does LimeWire really want to report the total number 
of all hosts (including alternates) in the tab title?  It seems to me 
that it would make more sense to only show the number of unique results, 
as that is a much more meaningful number for the end user.  I could fix 
that pretty easily I think.  Would a patch for that be accepted?


-Charles


Sam Berlin wrote:

> Hi Chuck,
>
> Thanks for sending in the patch -- if possible, could you create the  
> patch with the '-u' parameter?  More information is at  
> http://limewire.org/contribute.shtml .  The -u parameter creates 
> what's  called a "contextual" diff, so that even if the file has 
> changed  slightly, the patch command can still figure out where to 
> patch the  file.  It also makes reviewing the diff easier, since the 
> context is  included.
>
> Thanks,
>  Sam
>
> On Mar 28, 2005, at 1:10 PM, Chuck McNulty wrote:
>
>> Hi Sam,
>>
>> Here are the promised diff files.  The function blockHost() will  
>> continue to work as it has, however SearchResultMenu.java now calls 
>> a  new function blockAllHosts().
>> The meat of blockHost() has been moved to another new function 
>> called  blockOneHost(String host), which is called from both 
>> blockHost() and  blockAllHosts(), the difference being that 
>> blockAllHosts() calls  blockOneHost() for each host and alternate, 
>> whereas blockHost()  continues to only call it for the first host 
>> that it sees.
>> I've added a new string to MessagesBundle.properties to handle the 
>> new  string.
>>
>> I'm somewhat new to CVS (this is the first time I've used it to do  
>> more than just look at code) so please let me know if I did the diff  
>> files correctly.  I couldn't figure out how to use WinCVS to output  
>> the diff results directly to a file, so I had to copy the output 
>> into  a text file, and I'm not sure I copied all of the lines I 
>> needed too.
>>
>> Please let me know what you think.  I've been using it to block the  
>> search result spammers and so far it looks like it's working great.
>>
>> -Charles
>>
>> Sam Berlin wrote:
>>
>>> Hi Chuck,
>>>
>>> I guess that sounds fine.  As far as translations go, if the prior  
>>> wording
>>> won't fit at all with the new wording, just make a new KEY=value in  
>>> the
>>> message bundle, and the old one can be deleted.
>>>
>>> The block file functionality was (and still is) on the  
>>> 'file-filter-branch'
>>> (  http://www.limewire.org/fisheye/viewrep/~br=file-filter-branch/ 
>>> limecvs ) .
>>> I don't recall if there's any particular reason we didn't merge it 
>>> --  maybe
>>> just lack of time.
>>>
>>> Thanks,
>>> Sam
>>>
>>>> -----Original Message-----
>>>> From: [email protected]  
>>>> [mailto:[email protected]] On Behalf Of Charles
>>>> Sent: Sunday, March 27, 2005 11:34 AM
>>>> To: [email protected]
>>>> Subject: Re: [discuss] block all hosts
>>>>
>>>> Hi, I'll send you the diffs on Monday for what I've done so far. I  
>>>> doesn't seem to me like it would be worth it to include both 
>>>> "Block  All Hosts" and "Block First Host." I think the expected, 
>>>> and most  useful behaviour is to always block all hosts (which of 
>>>> course still  blocks just one if there is only one). I'd love to 
>>>> re-add the "Block  File"
>>>> selection, though, and I'll look into that on Monday as well.
>>>>
>>>> -Chuck
>>>>
>>>> Sam Berlin wrote:
>>>>
>>>>
>>>>> Hi Chuck,
>>>>>
>>>>> That'd be a really nice addition.  Your new message sounds good  
>>>>> (although it'd be nice to add the search result name into
>>>>
>>>> it).  There
>>>>
>>>>> could be a new menu item "Block All Hosts" and the "Block
>>>>
>>>> Host" could
>>>>
>>>>> become "Block First Host".  These would be selections from a new  
>>>>> submenu "Block" (where 'Block Host' used to be).  We have an
>>>>
>>>> old branch
>>>>
>>>>> that allows user-selected SHA1 filters too, so that could be
>>>>
>>>> added with a 'Block File' selection.
>>>>
>>>>> There's no need to worry about translating it into other 
>>>>> languages  (unless you know some and want to translate it) -- 
>>>>> there are  scripts set up to add the message into the other 
>>>>> languages' message
>>>>
>>>> bundle, and
>>>>
>>>>> eventually translations will be submitted.
>>>>>
>>>>> Thanks,
>>>>> Sam
>>>>>
>>>>>
>>>>>
>>>>>> -----Original Message-----
>>>>>> From: [email protected]
>>>>>> [mailto:[email protected]] On Behalf Of
>>>>>
>>>> Chuck McNulty
>>>>
>>>>>> Sent: Saturday, March 26, 2005 4:29 PM
>>>>>> To: [email protected]
>>>>>> Subject: [discuss] block all hosts
>>>>>>
>>>>>> Hi, I've just finished code that allows a user to block all 
>>>>>> hosts  (including alts) from a search result, rather than just 
>>>>>> the first  host, however this kind of messes up the confirmation 
>>>>>> string,  which now reads "Do you want to block search results 
>>>>>> from the host  at ?" Obviously the string should now read 
>>>>>> something like  "Do
>>>>>
>>>> you want to
>>>>
>>>>>> block all hosts for this search result?"  My question is
>>>>>
>>>> how would I
>>>>
>>>>>> submit this string for translation to all of the other 
>>>>>> languages.   Also, is this code desirable for the main trunk?
>>>>>> I'd be happy to submit the diffs to someone for review.
>>>>>>
>>>>>> -Charles
>>>>>>
>>>>>> _______________________________________________
>>>>>> discuss mailing list
>>>>>> [email protected]
>>>>>> http://www.limewire.org/mailman/listinfo/discuss
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>> _______________________________________________
>>>> discuss mailing list
>>>> [email protected]
>>>> http://www.limewire.org/mailman/listinfo/discuss
>>>>
>>>
>>> _______________________________________________
>>> discuss mailing list
>>> [email protected]
>>> http://www.limewire.org/mailman/listinfo/discuss
>>>
>>
>> diff -r1.181 MessagesBundle.properties
>> 387a388
>>
>>> SEARCH_BLOCK_ALL_HOSTS=Do you want to block all hosts for this 
>>> search  result?
>>
>> diff -r1.141 ResultPanel.java
>> 9a10
>>
>>> import java.util.Iterator;
>>
>> 11a13
>>
>>> import java.util.Set;
>>
>> 24a27
>>
>>> import com.limegroup.gnutella.RemoteFileDesc;
>>
>> 40a44
>>
>>> import com.limegroup.gnutella.util.IpPort;
>>
>> 45a50
>>
>>>
>> 350a356,388
>>
>>>
>>>     /**
>>>      * Blocks all hosts and alternates that sent the selected result.
>>>      */
>>>     void blockAllHosts() {
>>>         TableLine line = getSelectedLine();
>>>         if(line == null)
>>>             return;
>>>
>>>         Set alts = line.getAlts();
>>>
>>>         RemoteFileDesc[] rfds;
>>>         rfds = line.getAllRemoteFileDescs();
>>>
>>>         int answer =  
>>> GUIMediator.showYesNoMessage("SEARCH_BLOCK_ALL_HOSTS");
>>>         if (answer == GUIMediator.YES_OPTION) {
>>>
>>>             for(Iterator i = alts.iterator(); i.hasNext(); ) {
>>>                 IpPort next = (IpPort)i.next();
>>>                 String host = next.getAddress();
>>>                 blockOneHost(host);
>>>             }
>>>
>>>             for(int i = 0; i < rfds.length; i++) {
>>>                 RemoteFileDesc next = rfds[i];
>>>                 String host = next.getHost();
>>>                 blockOneHost(host);
>>>             }
>>>         }
>>>
>>>     }
>>>
>>>
>> 352c390
>> <      * Blocks the host that sent the selected result.
>> ---
>>
>>>      * Blocks the first host (and no alternates) that sent the  
>>> selected result.
>>
>> 362,372c400
>> <             String[] bannedIps =  
>> FilterSettings.BLACK_LISTED_IP_ADDRESSES.getValue();
>> <             // Ignore if this host is already banned.
>> <             for (int i = 0; i < bannedIps.length; i++)
>> <                 if (host.equalsIgnoreCase(bannedIps[i]))
>> <                     return;
>> <             String[] newBannedIps = new String[bannedIps.length + 1];
>> <             System.arraycopy(bannedIps, 0, newBannedIps, 0,
>> <                              bannedIps.length);
>> <             newBannedIps[bannedIps.length] = host;
>> <              
>> FilterSettings.BLACK_LISTED_IP_ADDRESSES.setValue(newBannedIps);
>> <             RouterService.adjustSpamFilters();
>> ---
>>
>>>             blockOneHost(host);
>>
>> 375c403,422
>> <
>> ---
>>
>>>
>>>
>>>     /**
>>>      * Blocks a given host.
>>>      */
>>>     void blockOneHost(String host) {
>>>         String[] bannedIps =  
>>> FilterSettings.BLACK_LISTED_IP_ADDRESSES.getValue();
>>>         // Ignore if this host is already banned.
>>>         for (int i = 0; i < bannedIps.length; i++)
>>>             if (host.equalsIgnoreCase(bannedIps[i]))
>>>                 return;
>>>         String[] newBannedIps = new String[bannedIps.length + 1];
>>>         System.arraycopy(bannedIps, 0, newBannedIps, 0,
>>>                          bannedIps.length);
>>>         newBannedIps[bannedIps.length] = host;
>>>          
>>> FilterSettings.BLACK_LISTED_IP_ADDRESSES.setValue(newBannedIps);
>>>         RouterService.adjustSpamFilters();
>>>     }
>>>
>> diff -r1.8 SearchResultMenu.java
>> 88c88
>> <             PANEL.blockHost();
>> ---
>>
>>>             PANEL.blockAllHosts();
>>
>> _______________________________________________
>> codepatch mailing list
>> [email protected]
>> http://www.limewire.org/mailman/listinfo/codepatch
>
>
> _______________________________________________
> discuss mailing list
> [email protected]
> http://www.limewire.org/mailman/listinfo/discuss


_______________________________________________
discuss mailing list
[email protected]
http://www.limewire.org/mailman/listinfo/discuss