Re: [codepatch] Re: [discuss] block all hosts
Chuck McNulty <[email protected]> Mon, 28 Mar 2005 15:14:38 -0500
| Newsgroups | gmane.network.gnutella.limewire.general |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format. --------------040806060207010902040905 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Okay, thanks for having some patience with me as I learn CVS. Here is the output of: cvs diff -u for each of the files. I could also, I think, just get one diff file with all of the diffs instead of breaking it up by file if it would be easier. -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 --------------040806060207010902040905 Content-Type: text/plain; name="MessagesBundle.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="MessagesBundle.diff" Index: MessagesBundle.properties =================================================================== RCS file: /cvs/lib/messagebundles/MessagesBundle.properties,v retrieving revision 1.181 diff -u -r1.181 MessagesBundle.properties --- MessagesBundle.properties 22 Mar 2005 16:25:10 -0000 1.181 +++ MessagesBundle.properties 28 Mar 2005 17:58:11 -0000 @@ -385,6 +385,7 @@ SEARCH_FILTER_RESULTS=Filter Results: SEARCH_BACK_TO_SEARCH=Back To Search SEARCH_BLOCK_HOST=Do you want to block search results from the host at +SEARCH_BLOCK_ALL_HOSTS=Do you want to block all hosts for this search result? #Media Types MEDIA_ANY_TYPE=Any Type --------------040806060207010902040905 Content-Type: text/plain; name="ResultPanel.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ResultPanel.diff" Index: ResultPanel.java =================================================================== RCS file: /cvs/gui/com/limegroup/gnutella/gui/search/ResultPanel.java,v retrieving revision 1.141 diff -u -r1.141 ResultPanel.java --- ResultPanel.java 10 Jan 2005 19:37:35 -0000 1.141 +++ ResultPanel.java 28 Mar 2005 17:58:44 -0000 @@ -7,8 +7,10 @@ import java.awt.event.MouseListener; import java.io.IOException; import java.util.Date; +import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.Set; import javax.swing.Box; import javax.swing.JComponent; @@ -22,6 +24,7 @@ import com.limegroup.gnutella.BrowseHostHandler; import com.limegroup.gnutella.GUID; import com.limegroup.gnutella.MediaType; +import com.limegroup.gnutella.RemoteFileDesc; import com.limegroup.gnutella.RouterService; import com.limegroup.gnutella.URN; import com.limegroup.gnutella.gui.BoxPanel; @@ -38,11 +41,13 @@ import com.limegroup.gnutella.search.QueryHandler; import com.limegroup.gnutella.settings.FilterSettings; import com.limegroup.gnutella.util.Launcher; +import com.limegroup.gnutella.util.IpPort; import com.limegroup.gnutella.licenses.License; import com.limegroup.gnutella.licenses.VerificationListener; import com.limegroup.gnutella.gui.LicenseWindow; + public class ResultPanel extends AbstractTableMediator implements VerificationListener { @@ -348,8 +353,41 @@ line.doChat(); } + + /** + * 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); + } + } + + } + + /** - * Blocks the host that sent the selected result. + * Blocks the first host (and no alternates) that sent the selected result. */ void blockHost() { TableLine line = getSelectedLine(); @@ -359,20 +397,29 @@ String host = line.getHostname(); int answer = GUIMediator.showYesNoMessage("SEARCH_BLOCK_HOST", " " + host + "?"); if (answer == GUIMediator.YES_OPTION && host != null) { - 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); } } - + + + /** + * 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(); + } + + /** * Shows a LicenseWindow for the selected line. */ --------------040806060207010902040905 Content-Type: text/plain; name="SearchResultMenu.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="SearchResultMenu.diff" Index: SearchResultMenu.java =================================================================== RCS file: /cvs/gui/com/limegroup/gnutella/gui/search/SearchResultMenu.java,v retrieving revision 1.8 diff -u -r1.8 SearchResultMenu.java --- SearchResultMenu.java 10 Jan 2005 19:37:35 -0000 1.8 +++ SearchResultMenu.java 26 Mar 2005 20:44:41 -0000 @@ -85,7 +85,7 @@ private class BlockListener implements ActionListener { public void actionPerformed(ActionEvent e) { - PANEL.blockHost(); + PANEL.blockAllHosts(); } } --------------040806060207010902040905 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ discuss mailing list [email protected] http://www.limewire.org/mailman/listinfo/discuss --------------040806060207010902040905--