Changeset 1ab67de


Ignore:
Timestamp:
Mar 23, 2017 2:55:56 PM (4 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
0a2097a2
Parents:
4727706
Message:

Plugins: Blacklist i2pbote and BwSchedule?
Translate exceptions thrown from PluginStarter?

Location:
apps/routerconsole/java/src/net/i2p/router
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • apps/routerconsole/java/src/net/i2p/router/update/PluginUpdateRunner.java

    r4727706 r1ab67de  
    458458                    return;
    459459                }
     460                String blacklistVersion = PluginStarter.jetty9Blacklist.get(appName);
     461                if (blacklistVersion != null &&
     462                    VersionComparator.comp(version, blacklistVersion) <= 0) {
     463                    to.delete();
     464                    statusDone("<b>" + _t("Plugin requires Jetty version {0} or lower", "8.9999") + "</b>");
     465                    return;
     466                }
    460467                maxVersion = ConfigClientsHelper.stripHTML(props, "max-jetty-version");
    461468                if (maxVersion != null &&
  • apps/routerconsole/java/src/net/i2p/router/web/PluginStarter.java

    r4727706 r1ab67de  
    6868    private static Map<String, Collection<String>> pluginWars = new ConcurrentHashMap<String, Collection<String>>();
    6969
     70    /**
     71     *  Plugin name to plugin version of plugins that do not work
     72     *  with Jetty 9, but do not have a max-jetty-version=8.9999 set.
     73     *  Unmodifiable.
     74     *
     75     *  @since 0.9.30
     76     */
     77    public static final Map<String, String> jetty9Blacklist;
     78
     79    static {
     80        Map<String, String> map = new HashMap<String, String>(4);
     81        map.put("i2pbote", "0.4.5");
     82        map.put("BwSchedule", "0.0.36");
     83        jetty9Blacklist = Collections.unmodifiableMap(map);
     84    }
     85
    7086    public PluginStarter(RouterContext ctx) {
    7187        _context = ctx;
     
    298314        Properties props = pluginProperties(ctx, appName);
    299315
    300 
    301 
     316        // For the following, we use the exact same translated strings as in PluginUpdateRunner
     317        // to avoid duplication
    302318
    303319        String minVersion = ConfigClientsHelper.stripHTML(props, "min-i2p-version");
     
    307323            log.error(foo);
    308324            disablePlugin(appName);
     325            foo = gettext("This plugin requires I2P version {0} or higher", minVersion, ctx);
    309326            throw new Exception(foo);
    310327        }
     
    316333            log.error(foo);
    317334            disablePlugin(appName);
     335            foo = gettext("This plugin requires Java version {0} or higher", minVersion, ctx);
    318336            throw new Exception(foo);
    319337        }
     
    326344            log.error(foo);
    327345            disablePlugin(appName);
     346            foo = gettext("Plugin requires Jetty version {0} or higher", minVersion, ctx);
     347            throw new Exception(foo);
     348        }
     349
     350        String blacklistVersion = jetty9Blacklist.get(appName);
     351        String curVersion = ConfigClientsHelper.stripHTML(props, "version");
     352        if (blacklistVersion != null &&
     353            VersionComparator.comp(curVersion, blacklistVersion) <= 0) {
     354            String foo = "Plugin " + appName + " requires Jetty version 8.9999 or lower";
     355            log.error(foo);
     356            disablePlugin(appName);
     357            foo = gettext("Plugin requires Jetty version {0} or lower", "8.9999", ctx);
    328358            throw new Exception(foo);
    329359        }
     
    335365            log.error(foo);
    336366            disablePlugin(appName);
     367            foo = gettext("Plugin requires Jetty version {0} or lower", maxVersion, ctx);
    337368            throw new Exception(foo);
    338369        }
     
    10031034    }
    10041035
     1036    /**
     1037     * translate a string
     1038     * @since 0.9.30
     1039     */
     1040    private static String gettext(String s, Object o, I2PAppContext ctx) {
     1041        return Messages.getString(s, o, ctx);
     1042    }
     1043
    10051044    /** translate a string */
    10061045    private static String ngettext(String s, String p, int n, I2PAppContext ctx) {
Note: See TracChangeset for help on using the changeset viewer.