Author: jflesch
Date: 2007-01-17 18:20:18 +0000 (Wed, 17 Jan 2007)
New Revision: 11606

Modified:
   trunk/apps/Thaw/src/thaw/core/FreenetURIHelper.java
   trunk/apps/Thaw/src/thaw/i18n/thaw.properties
   trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
   trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java
Log:
Add a troll detector when downloading files from some keys

Modified: trunk/apps/Thaw/src/thaw/core/FreenetURIHelper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/FreenetURIHelper.java 2007-01-16 21:21:26 UTC 
(rev 11605)
+++ trunk/apps/Thaw/src/thaw/core/FreenetURIHelper.java 2007-01-17 18:20:18 UTC 
(rev 11606)
@@ -9,6 +9,8 @@

        /**
         * Quick test to see if the string could be a key
+        * only check the head, not the content (this property is used in 
FetchPlugin,
+        * please keep it)
         */
        public static boolean isAKey(String key) {
                if (key == null)

Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2007-01-16 21:21:26 UTC 
(rev 11605)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2007-01-17 18:20:18 UTC 
(rev 11606)
@@ -144,6 +144,14 @@
 thaw.plugin.fetch.pasteFromClipboard=Paste from clipboard
 thaw.plugin.fetch.chooseADestination=You must choose a destination

+thaw.plugin.fetch.freenet0.5.l1=These file keys are for the old and obsolete 
Freenet 0.5.
+thaw.plugin.fetch.freenet0.5.l2=You're using Freenet 0.7.
+thaw.plugin.fetch.freenet0.5.l3=Please tell the troll which gave you thse keys
+thaw.plugin.fetch.freenet0.5.l4=to go fuck itself.
+thaw.plugin.fetch.freenet0.5.l5=Thanks,
+thaw.plugin.fetch.freenet0.5.l6=the Thaw developper.
+
+
 thaw.plugin.console.console=Console
 thaw.plugin.console.saveToFile=Save log to file
 thaw.plugin.console.maxSize=Maximum memory allocated to store log (in Bytes)

Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2007-01-16 21:21:26 UTC 
(rev 11605)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2007-01-17 18:20:18 UTC 
(rev 11606)
@@ -117,6 +117,14 @@
 thaw.plugin.insert.specifyFile=Please specify a file
 thaw.plugin.insert.mime=Type mime (laisser vide s'il doit ?tre autod?tect?)

+thaw.plugin.fetch.freenet0.5.l1=Ces clefs de fichiers sont pour le vieux et 
obsol?te Freenet 0.5.
+thaw.plugin.fetch.freenet0.5.l2=Vous utilisez actuellement Freenet 0.7.
+thaw.plugin.fetch.freenet0.5.l3=Veuillez dire au troll qui vous a donn? ces 
clefs
+thaw.plugin.fetch.freenet0.5.l4=d'aller se faire foutre.
+thaw.plugin.fetch.freenet0.5.l5=Merci,
+thaw.plugin.fetch.freenet0.5.l6=le d?veloppeur de Thaw.
+
+
 thaw.plugin.priority.p0=Urgence (*pas* pour un usage normal)
 thaw.plugin.priority.p1=Tr?s haute
 thaw.plugin.priority.p2=Haute

Modified: trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java   2007-01-16 21:21:26 UTC 
(rev 11605)
+++ trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java   2007-01-17 18:20:18 UTC 
(rev 11606)
@@ -17,6 +17,8 @@
 import thaw.plugins.fetchPlugin.FetchPanel;

 public class FetchPlugin implements thaw.core.Plugin, ActionListener {
+       public final static int MIN_SLASH_POSITION=80;
+
        private Core core;

        private FetchPanel fetchPanel = null;
@@ -96,6 +98,8 @@
                               final int persistence, final boolean globalQueue,
                               final String destination) {

+               boolean trollDetected = false; /* because of trolls coming from 
0.5 */
+
                for(int i = 0 ; i < keys.length ; i++) {
                        if(keys[i].length() < 10)
                                continue;
@@ -104,15 +108,40 @@

                        final String key = FreenetURIHelper.cleanURI(subKey[0]);

-                       if (key != null)
-                               
core.getQueueManager().addQueryToThePendingQueue(new FCPClientGet(key,
-                                                                               
                  priority,
-                                                                               
                  persistence,
-                                                                               
                  globalQueue, -1,
-                                                                               
                  destination));
+                       if (key == null || !FreenetURIHelper.isAKey(key))
+                               continue;
+
+                       int slash_pos = key.indexOf("/");
+
+                       if (slash_pos < 0)
+                               continue;
+
+                       if (slash_pos < MIN_SLASH_POSITION) {
+                               trollDetected = true;
+                               /* We'll let Thaw continue to show how
+                                * useful these keys are
+                                */
+                       }
+
+                       core.getQueueManager().addQueryToThePendingQueue(new 
FCPClientGet(key,
+                                                                               
          priority,
+                                                                               
          persistence,
+                                                                               
          globalQueue, -1,
+                                                                               
          destination));
                }

                fetchFrame.setVisible(false);
+
+               if (trollDetected) {
+                       new thaw.core.WarningWindow(core,
+                                                   
I18n.getMessage("thaw.plugin.fetch.freenet0.5.l1")+"\n"
+                                                   + 
I18n.getMessage("thaw.plugin.fetch.freenet0.5.l2")+"\n"
+                                                   + 
I18n.getMessage("thaw.plugin.fetch.freenet0.5.l3")+"\n"
+                                                   + 
I18n.getMessage("thaw.plugin.fetch.freenet0.5.l4")+"\n"
+                                                   + 
I18n.getMessage("thaw.plugin.fetch.freenet0.5.l5")+"\n"
+                                                   + 
I18n.getMessage("thaw.plugin.fetch.freenet0.5.l6"));
+
+               }
        }




Reply via email to