Package freenet.config

Examples of freenet.config.InvalidConfigValueException


    public void set(String val) throws InvalidConfigValueException {
      if (dir == null) { dir = new File(val); return; }
      if (dir.equals(new File(val))) return;
      // FIXME support it
      // Don't need to translate the below as very few users will use it.
      throw new InvalidConfigValueException("Moving program directory on the fly not supported at present");
    }
View Full Code Here


      if (dir == null) { dir = new File(val); return; }
      if (dir.equals(new File(val))) return;
      File f = new File(val);
      if(!((f.exists() && f.isDirectory()) || (f.mkdir())))
        // Relatively commonly used, despite being advanced (i.e. not something we want to show to newbies). So translate it.
        throw new InvalidConfigValueException(l10n(moveErrMsg));
      dir = new File(val);
    }
View Full Code Here

          @Override
          public void set(Integer val) throws InvalidConfigValueException {
            if (get().equals(val))
                  return;
            if(val < 100)
              throw new InvalidConfigValueException(l10n("valueTooLow"));
            threadLimit = val;
          }
    },false);
   
    threadLimit = statsConfig.getInt("threadLimit");
View Full Code Here

          @Override
          public void set(String val) throws InvalidConfigValueException {
            try {
            allowedFullAccess.setAllowedHosts(val);
            } catch(IllegalArgumentException e) {
              throw new InvalidConfigValueException(e);
            }
          }
     
    });
    allowedFullAccess = new AllowedHosts(fproxyConfig.getString("allowedHostsFullAccess"));
    fproxyConfig.register("doRobots", false, configItemOrder++, true, false, "SimpleToadletServer.doRobots", "SimpleToadletServer.doRobotsLong",
        new BooleanCallback() {
          @Override
          public Boolean get() {
            return doRobots;
          }
          @Override
          public void set(Boolean val) throws InvalidConfigValueException {
            doRobots = val;
          }
    });
    doRobots = fproxyConfig.getBoolean("doRobots");
   
    // We may not know what the overall thread limit is yet so just set it to 100.
    fproxyConfig.register("maxFproxyConnections", 100, configItemOrder++, true, false, "SimpleToadletServer.maxFproxyConnections", "SimpleToadletServer.maxFproxyConnectionsLong",
        new IntCallback() {

          @Override
          public Integer get() {
            synchronized(SimpleToadletServer.this) {
              return maxFproxyConnections;
            }
          }

          @Override
          public void set(Integer val) {
            synchronized(SimpleToadletServer.this) {
              maxFproxyConnections = val;
              SimpleToadletServer.this.notifyAll();
            }
          }
     
    }, false);
    maxFproxyConnections = fproxyConfig.getInt("maxFproxyConnections");
   
    fproxyConfig.register("metaRefreshSamePageInterval", 1, configItemOrder++, true, false, "SimpleToadletServer.metaRefreshSamePageInterval", "SimpleToadletServer.metaRefreshSamePageIntervalLong",
        new IntCallback() {

          @Override
          public Integer get() {
            return HTMLFilter.metaRefreshSamePageMinInterval;
          }

          @Override
          public void set(Integer val)
              throws InvalidConfigValueException,
              NodeNeedRestartException {
            if(val < -1) throw new InvalidConfigValueException("-1 = disabled, 0+ = set a minimum interval"); // FIXME l10n
            HTMLFilter.metaRefreshSamePageMinInterval = val;
          }
    }, false);
    HTMLFilter.metaRefreshSamePageMinInterval = Math.max(-1, fproxyConfig.getInt("metaRefreshSamePageInterval"));
   
    fproxyConfig.register("metaRefreshRedirectInterval", 1, configItemOrder++, true, false, "SimpleToadletServer.metaRefreshRedirectInterval", "SimpleToadletServer.metaRefreshRedirectIntervalLong",
        new IntCallback() {

          @Override
          public Integer get() {
            return HTMLFilter.metaRefreshRedirectMinInterval;
          }

          @Override
          public void set(Integer val)
              throws InvalidConfigValueException,
              NodeNeedRestartException {
            if(val < -1) throw new InvalidConfigValueException("-1 = disabled, 0+ = set a minimum interval"); // FIXME l10n
            HTMLFilter.metaRefreshRedirectMinInterval = val;
          }
    }, false);
    HTMLFilter.metaRefreshRedirectMinInterval = Math.max(-1, fproxyConfig.getInt("metaRefreshRedirectInterval"));

    fproxyConfig.register("refilterPolicy", "RE_FILTER",
        configItemOrder++, true, false, "SimpleToadletServer.refilterPolicy", "SimpleToadletServer.refilterPolicyLong", new ReFilterCallback());
   
    this.refilterPolicy = REFILTER_POLICY.valueOf(fproxyConfig.getString("refilterPolicy"));
   
    // Network seclevel not physical seclevel because bad filtering can cause network level anonymity breaches.
    SimpleToadletServer.isPanicButtonToBeShown = fproxyConfig.getBoolean("showPanicButton");
    SimpleToadletServer.noConfirmPanic = fproxyConfig.getBoolean("noConfirmPanic");
   
    this.bf = bucketFactory;
    port = fproxyConfig.getInt("port");
    bindTo = fproxyConfig.getString("bindTo");
    String cssName = fproxyConfig.getString("css");
    if((cssName.indexOf(':') != -1) || (cssName.indexOf('/') != -1))
      throw new InvalidConfigValueException("CSS name must not contain slashes or colons!");
    cssTheme = THEME.themeFromName(cssName);
    pageMaker = new PageMaker(cssTheme, node);
 
    if(!fproxyConfig.getOption("CSSOverride").isDefault()) {
      cssOverride = new File(fproxyConfig.getString("CSSOverride"));
View Full Code Here

    @Override
    public void set(Boolean val) throws InvalidConfigValueException {
      if (get().equals(val))
        return;
      if(!SSL.available()) {
        throw new InvalidConfigValueException("Enable SSL support before use ssl with Fproxy");
      }
      ssl = val;
      throw new InvalidConfigValueException("Cannot change SSL on the fly, please restart freenet");
    }
View Full Code Here

        } else {
          // This is an advanced option for reasons of reducing clutter,
          // but it is expected to be used by regular users, not devs.
          // So we translate the error messages.
          networkInterface.setBindTo(oldValue, false);
          throw new InvalidConfigValueException(l10n("couldNotChangeBindTo", "failedInterfaces", Arrays.toString(failedAddresses)));
        }
      }
    }
View Full Code Here

    public void set(String allowedHosts) throws InvalidConfigValueException {
      if (!allowedHosts.equals(get())) {
        try {
        networkInterface.setAllowedHosts(allowedHosts);
        } catch(IllegalArgumentException e) {
          throw new InvalidConfigValueException(e);
        }
      }
    }
View Full Code Here

    }
   
    @Override
    public void set(String CSSName) throws InvalidConfigValueException {
      if((CSSName.indexOf(':') != -1) || (CSSName.indexOf('/') != -1))
        throw new InvalidConfigValueException(l10n("illegalCSSName"));
      cssTheme = THEME.themeFromName(CSSName);
      pageMaker.setTheme(cssTheme);
      NodeClientCore core = SimpleToadletServer.this.core;
      if (core.node.pluginManager != null)
        core.node.pluginManager.setFProxyTheme(cssTheme);
View Full Code Here

      if(val.equals(get()) || val.equals(""))
        cssOverride = null;
      else {
        File tmp = new File(val.trim());
        if(!core.allowUploadFrom(tmp))
          throw new InvalidConfigValueException(l10n("cssOverrideNotInUploads", "filename", tmp.toString()));
        else if(!tmp.canRead() || !tmp.isFile())
          throw new InvalidConfigValueException(l10n("cssOverrideCantRead", "filename", tmp.toString()));
        File parent = tmp.getParentFile();
        // Basic sanity check.
        // Prevents user from specifying root dir.
        // They can still shoot themselves in the foot, but only when developing themes/using custom themes.
        // Because of the .. check above, any malicious thing cannot break out of the dir anyway.
        if(parent.getParentFile() == null)
          throw new InvalidConfigValueException(l10n("cssOverrideCantUseRootDir", "filename", parent.toString()));
        cssOverride = tmp;
      }
      if(cssOverride == null)
        pageMaker.setOverride(null);
      else {
View Full Code Here

   *
   * See the Node.bandwidthMinimum localization string.
   * @param limit Bandwidth limit in bytes.
   */
  private InvalidConfigValueException lowBandwidthLimit(int limit) {
    return new InvalidConfigValueException(l10n("bandwidthMinimum",
        new String[] { "limit", "minimum" },
        new String[] { Integer.toString(limit), Integer.toString(minimumBandwidth) }));
  }
View Full Code Here

TOP

Related Classes of freenet.config.InvalidConfigValueException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.