Package freenet.config

Examples of freenet.config.SubConfig


    }
  }


  public static FCPServer maybeCreate(Node node, NodeClientCore core, Config config, PersistentRequestRoot root) throws IOException, InvalidConfigValueException {
    SubConfig fcpConfig = new SubConfig("fcp", config);
    short sortOrder = 0;
    fcpConfig.register("enabled", true, sortOrder++, true, false, "FcpServer.isEnabled", "FcpServer.isEnabledLong", new FCPEnabledCallback(core));
    fcpConfig.register("ssl", false, sortOrder++, true, true, "FcpServer.ssl", "FcpServer.sslLong", new FCPSSLCallback());
    fcpConfig.register("port", FCPServer.DEFAULT_FCP_PORT /* anagram of 1984, and 1000 up from old number */, 2, true, true, "FcpServer.portNumber", "FcpServer.portNumberLong", new FCPPortNumberCallback(core), false);
    fcpConfig.register("bindTo", NetworkInterface.DEFAULT_BIND_TO, sortOrder++, true, true, "FcpServer.bindTo", "FcpServer.bindToLong", new FCPBindtoCallback(core));
    fcpConfig.register("allowedHosts", NetworkInterface.DEFAULT_BIND_TO, sortOrder++, true, true, "FcpServer.allowedHosts", "FcpServer.allowedHostsLong", new FCPAllowedHostsCallback(core));
    fcpConfig.register("allowedHostsFullAccess", NetworkInterface.DEFAULT_BIND_TO, sortOrder++, true, true, "FcpServer.allowedHostsFullAccess", "FcpServer.allowedHostsFullAccessLong", new FCPAllowedHostsFullAccessCallback(core));

    AssumeDDADownloadIsAllowedCallback cb4;
    AssumeDDAUploadIsAllowedCallback cb5;
    NeverDropAMessageCallback cb6;
    MaxMessageQueueLengthCallback cb7;
    fcpConfig.register("assumeDownloadDDAIsAllowed", false, sortOrder++, true, false, "FcpServer.assumeDownloadDDAIsAllowed", "FcpServer.assumeDownloadDDAIsAllowedLong", cb4 = new AssumeDDADownloadIsAllowedCallback());
    fcpConfig.register("assumeUploadDDAIsAllowed", false, sortOrder++, true, false, "FcpServer.assumeUploadDDAIsAllowed", "FcpServer.assumeUploadDDAIsAllowedLong", cb5 = new AssumeDDAUploadIsAllowedCallback());
    fcpConfig.register("maxMessageQueueLength", 1024, sortOrder++, true, false, "FcpServer.maxMessageQueueLength", "FcpServer.maxMessageQueueLengthLong", cb7 = new MaxMessageQueueLengthCallback(), false);
    fcpConfig.register("neverDropAMessage", false, sortOrder++, true, false, "FcpServer.neverDropAMessage", "FcpServer.neverDropAMessageLong", cb6 = new NeverDropAMessageCallback());

    if(SSL.available()) {
      ssl = fcpConfig.getBoolean("ssl");
    }

    FCPServer fcp = new FCPServer(fcpConfig.getString("bindTo"), fcpConfig.getString("allowedHosts"), fcpConfig.getString("allowedHostsFullAccess"), fcpConfig.getInt("port"), node, core, fcpConfig.getBoolean("enabled"), fcpConfig.getBoolean("assumeDownloadDDAIsAllowed"), fcpConfig.getBoolean("assumeUploadDDAIsAllowed"), fcpConfig.getBoolean("neverDropAMessage"), fcpConfig.getInt("maxMessageQueueLength"), root);

    if(fcp != null) {
      cb4.server = fcp;
      cb5.server = fcp;
      cb6.server = fcp;
      cb7.server = fcp;
    }

    fcpConfig.finishedInitialization();
    return fcp;
  }
View Full Code Here


    return NodeL10n.getBase().getString("InvalidAddressOverrideUserAlert."+key);
  }

  @Override
  public HTMLNode getHTMLText() {
    SubConfig sc = node.config.get("node");
    Option<?> o = sc.getOption("ipAddressOverride");
   
    HTMLNode textNode = new HTMLNode("div");
    NodeL10n.getBase().addL10nSubstitution(textNode, "InvalidAddressOverrideUserAlert.unknownAddressWithConfigLink",
        new String[] { "link" },
        new HTMLNode[] { HTMLNode.link("/config/node")});
    HTMLNode formNode = textNode.addChild("form", new String[] { "action", "method" }, new String[] { "/config/node", "post" });
    formNode.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", node.clientCore.formPassword });
    formNode.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "subconfig", sc.getPrefix() });
    HTMLNode listNode = formNode.addChild("ul", "class", "config");
    HTMLNode itemNode = listNode.addChild("li");
    itemNode.addChild("span", "class", "configshortdesc", o.getLocalisedShortDesc()).addChild("input", new String[] { "type", "name", "value" }, new String[] { "text", sc.getPrefix() + ".ipAddressOverride", o.getValueDisplayString() });
    itemNode.addChild("span", "class", "configlongdesc", o.getLocalisedLongDesc());
    formNode.addChild("input", new String[] { "type", "value" }, new String[] { "submit", NodeL10n.getBase().getString("UserAlert.apply") });
    formNode.addChild("input", new String[] { "type", "value" }, new String[] { "reset", NodeL10n.getBase().getString("UserAlert.reset") });
    return textNode;
  }
View Full Code Here

  public static TextModeClientInterfaceServer maybeCreate(Node node, NodeClientCore core, Config config) throws IOException {

    TextModeClientInterfaceServer server = null;

    SubConfig TMCIConfig = new SubConfig("console", config);

    TMCIConfig.register("enabled", false, 1, true, true /* FIXME only because can't be changed on the fly */, "TextModeClientInterfaceServer.enabled", "TextModeClientInterfaceServer.enabledLong", new TMCIEnabledCallback(core));
    TMCIConfig.register("ssl", false, 1, true, true , "TextModeClientInterfaceServer.ssl", "TextModeClientInterfaceServer.sslLong", new TMCISSLCallback());
    TMCIConfig.register("bindTo", NetworkInterface.DEFAULT_BIND_TO, 2, true, false, "TextModeClientInterfaceServer.bindTo", "TextModeClientInterfaceServer.bindToLong", new TMCIBindtoCallback(core));
    TMCIConfig.register("allowedHosts", NetworkInterface.DEFAULT_BIND_TO, 2, true, false, "TextModeClientInterfaceServer.allowedHosts", "TextModeClientInterfaceServer.allowedHostsLong", new TMCIAllowedHostsCallback(core));
    TMCIConfig.register("port", 2323, 1, true, false, "TextModeClientInterfaceServer.telnetPortNumber", "TextModeClientInterfaceServer.telnetPortNumberLong", new TCMIPortNumberCallback(core), false);
    TMCIConfig.register("directEnabled", false, 1, true, false, "TextModeClientInterfaceServer.enableInputOutput", "TextModeClientInterfaceServer.enableInputOutputLong", new TMCIDirectEnabledCallback(core));

    boolean TMCIEnabled = TMCIConfig.getBoolean("enabled");
    int port =  TMCIConfig.getInt("port");
    String bind_ip = TMCIConfig.getString("bindTo");
    String allowedHosts = TMCIConfig.getString("allowedHosts");
    boolean direct = TMCIConfig.getBoolean("directEnabled");
    if(SSL.available()) {
      ssl = TMCIConfig.getBoolean("ssl");
    }

    if(TMCIEnabled)
      server = new TextModeClientInterfaceServer(node, core, port, bind_ip, allowedHosts);

    if(direct) {
          HighLevelSimpleClient client = core.makeClient(RequestStarter.INTERACTIVE_PRIORITY_CLASS, true, false);
      TextModeClientInterface directTMCI =
        new TextModeClientInterface(node, core, client, core.getDownloadsDir(), System.in, System.out);
      node.executor.execute(directTMCI, "Direct text mode interface");
      core.setDirectTMCI(directTMCI);
    }

    TMCIConfig.finishedInitialization();

    return server; // caller must call start()
  }
View Full Code Here

    return l10n("noNodeNickShort");
  }

  @Override
  public HTMLNode getHTMLText() {
    SubConfig sc = node.config.get("node");
    Option<?> o = sc.getOption("name");

    HTMLNode alertNode = new HTMLNode("div");
    HTMLNode textNode = alertNode.addChild("div");
    textNode.addChild("#", l10n("noNodeNick"));
    HTMLNode formNode = alertNode.addChild("form", new String[] { "action", "method" }, new String[] { "/config/"+sc.getPrefix(), "post" });
    formNode.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", node.clientCore.formPassword });
    formNode.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "subconfig", sc.getPrefix() });
    HTMLNode listNode = formNode.addChild("ul", "class", "config");
    HTMLNode itemNode = listNode.addChild("li");
    itemNode.addChild("span", new String[]{ "class", "title", "style" },
        new String[]{ "configshortdesc", NodeL10n.getBase().getString("ConfigToadlet.defaultIs", new String[] { "default" }, new String[] { o.getDefault() }),
        "cursor: help;" }).addChild(o.getShortDescNode());
View Full Code Here

  public final ClientRequestScheduler sskFetchSchedulerRT;
  public final ClientRequestScheduler sskPutSchedulerRT;

  private final NodeStats stats;
  RequestStarterGroup(Node node, NodeClientCore core, int portNumber, RandomSource random, Config config, SimpleFieldSet fs, ClientContext ctx, long dbHandle) throws InvalidConfigValueException {
    SubConfig schedulerConfig = new SubConfig("node.scheduler", config);
    this.stats = core.nodeStats;
   
    throttleWindowBulk = new ThrottleWindowManager(2.0, fs == null ? null : fs.subset("ThrottleWindow"), node);
    throttleWindowRT = new ThrottleWindowManager(2.0, fs == null ? null : fs.subset("ThrottleWindowRT"), node);
   
    throttleWindowCHK = new ThrottleWindowManager(2.0, fs == null ? null : fs.subset("ThrottleWindowCHK"), node);
    throttleWindowSSK = new ThrottleWindowManager(2.0, fs == null ? null : fs.subset("ThrottleWindowSSK"), node);
    throttleWindowInsert = new ThrottleWindowManager(2.0, fs == null ? null : fs.subset("ThrottleWindowInsert"), node);
    throttleWindowRequest = new ThrottleWindowManager(2.0, fs == null ? null : fs.subset("ThrottleWindowRequest"), node);
    chkRequestThrottleBulk = new MyRequestThrottle(5000, "CHK Request", fs == null ? null : fs.subset("CHKRequestThrottle"), 32768, false);
    chkRequestThrottleRT = new MyRequestThrottle(5000, "CHK Request (RT)", fs == null ? null : fs.subset("CHKRequestThrottleRT"), 32768, true);
    chkRequestStarterBulk = new RequestStarter(core, chkRequestThrottleBulk, "CHK Request starter ("+portNumber+ ')', stats.requestOutputThrottle, stats.requestInputThrottle, stats.localChkFetchBytesSentAverage, stats.localChkFetchBytesReceivedAverage, false, false, false);
    chkRequestStarterRT = new RequestStarter(core, chkRequestThrottleRT, "CHK Request starter ("+portNumber+ ')', stats.requestOutputThrottle, stats.requestInputThrottle, stats.localChkFetchBytesSentAverage, stats.localChkFetchBytesReceivedAverage, false, false, true);
    chkFetchSchedulerBulk = new ClientRequestScheduler(false, false, false, random, chkRequestStarterBulk, node, core, "CHKrequester", ctx);
    chkFetchSchedulerRT = new ClientRequestScheduler(false, false, true, random, chkRequestStarterRT, node, core, "CHKrequester", ctx);
    chkRequestStarterBulk.setScheduler(chkFetchSchedulerBulk);
    chkRequestStarterRT.setScheduler(chkFetchSchedulerRT);
   
    registerSchedulerConfig(schedulerConfig, "CHKrequester", chkFetchSchedulerBulk, chkFetchSchedulerRT, false, false);
   
    //insertThrottle = new ChainedRequestThrottle(10000, 2.0F, requestThrottle);
    // FIXME reenable the above
    chkInsertThrottleBulk = new MyRequestThrottle(20000, "CHK Insert", fs == null ? null : fs.subset("CHKInsertThrottle"), 32768, false);
    chkInsertThrottleRT = new MyRequestThrottle(20000, "CHK Insert (RT)", fs == null ? null : fs.subset("CHKInsertThrottleRT"), 32768, true);
    chkInsertStarterBulk = new RequestStarter(core, chkInsertThrottleBulk, "CHK Insert starter ("+portNumber+ ')', stats.requestOutputThrottle, stats.requestInputThrottle, stats.localChkInsertBytesSentAverage, stats.localChkInsertBytesReceivedAverage, true, false, false);
    chkInsertStarterRT = new RequestStarter(core, chkInsertThrottleRT, "CHK Insert starter ("+portNumber+ ')', stats.requestOutputThrottle, stats.requestInputThrottle, stats.localChkInsertBytesSentAverage, stats.localChkInsertBytesReceivedAverage, true, false, true);
    chkPutSchedulerBulk = new ClientRequestScheduler(true, false, false, random, chkInsertStarterBulk, node, core, "CHKinserter", ctx);
    chkPutSchedulerRT = new ClientRequestScheduler(true, false, true, random, chkInsertStarterRT, node, core, "CHKinserter", ctx);
    chkInsertStarterBulk.setScheduler(chkPutSchedulerBulk);
    chkInsertStarterRT.setScheduler(chkPutSchedulerRT);
   
    registerSchedulerConfig(schedulerConfig, "CHKinserter", chkPutSchedulerBulk, chkPutSchedulerRT, false, true);
   
    sskRequestThrottleBulk = new MyRequestThrottle(5000, "SSK Request", fs == null ? null : fs.subset("SSKRequestThrottle"), 1024, false);
    sskRequestThrottleRT = new MyRequestThrottle(5000, "SSK Request (RT)", fs == null ? null : fs.subset("SSKRequestThrottleRT"), 1024, true);
    sskRequestStarterBulk = new RequestStarter(core, sskRequestThrottleBulk, "SSK Request starter ("+portNumber+ ')', stats.requestOutputThrottle, stats.requestInputThrottle, stats.localSskFetchBytesSentAverage, stats.localSskFetchBytesReceivedAverage, false, true, false);
    sskRequestStarterRT = new RequestStarter(core, sskRequestThrottleRT, "SSK Request starter ("+portNumber+ ')', stats.requestOutputThrottle, stats.requestInputThrottle, stats.localSskFetchBytesSentAverage, stats.localSskFetchBytesReceivedAverage, false, true, true);
    sskFetchSchedulerBulk = new ClientRequestScheduler(false, true, false, random, sskRequestStarterBulk, node, core, "SSKrequester", ctx);
    sskFetchSchedulerRT = new ClientRequestScheduler(false, true, true, random, sskRequestStarterRT, node, core, "SSKrequester", ctx);
    sskRequestStarterBulk.setScheduler(sskFetchSchedulerBulk);
    sskRequestStarterRT.setScheduler(sskFetchSchedulerRT);
   
    registerSchedulerConfig(schedulerConfig, "SSKrequester", sskFetchSchedulerBulk, sskFetchSchedulerRT, true, false);
   
    //insertThrottle = new ChainedRequestThrottle(10000, 2.0F, requestThrottle);
    // FIXME reenable the above
    sskInsertThrottleBulk = new MyRequestThrottle(20000, "SSK Insert", fs == null ? null : fs.subset("SSKInsertThrottle"), 1024, false);
    sskInsertThrottleRT = new MyRequestThrottle(20000, "SSK Insert", fs == null ? null : fs.subset("SSKInsertThrottleRT"), 1024, true);
    sskInsertStarterBulk = new RequestStarter(core, sskInsertThrottleBulk, "SSK Insert starter ("+portNumber+ ')', stats.requestOutputThrottle, stats.requestInputThrottle, stats.localSskInsertBytesSentAverage, stats.localSskFetchBytesReceivedAverage, true, true, false);
    sskInsertStarterRT = new RequestStarter(core, sskInsertThrottleRT, "SSK Insert starter ("+portNumber+ ')', stats.requestOutputThrottle, stats.requestInputThrottle, stats.localSskInsertBytesSentAverage, stats.localSskFetchBytesReceivedAverage, true, true, true);
    sskPutSchedulerBulk = new ClientRequestScheduler(true, true, false, random, sskInsertStarterBulk, node, core, "SSKinserter", ctx);
    sskPutSchedulerRT = new ClientRequestScheduler(true, true, true, random, sskInsertStarterRT, node, core, "SSKinserter", ctx);
    sskInsertStarterBulk.setScheduler(sskPutSchedulerBulk);
    sskInsertStarterRT.setScheduler(sskPutSchedulerRT);
   
    registerSchedulerConfig(schedulerConfig, "SSKinserter", sskPutSchedulerBulk, sskPutSchedulerRT, true, true);
   
    schedulerConfig.finishedInitialization();
  }
View Full Code Here

    this.node = node;
    this.accepted = Collections.synchronizedMap(new HashMap<PeerNode, Counter>());
    this.timer = new Timer(true);

    int sortOrder = 0;
    final SubConfig nodeConfig = node.config.get("node");

    nodeConfig.register("probeBandwidth", true, sortOrder++, true, true, "Node.probeBandwidthShort",
      "Node.probeBandwidthLong", new BooleanCallback() {
      @Override
      public Boolean get() {
        return respondBandwidth;
      }

      @Override
      public void set(Boolean val) {
        respondBandwidth = val;
      }
    });
    respondBandwidth = nodeConfig.getBoolean("probeBandwidth");
    nodeConfig.register("probeBuild", true, sortOrder++, true, true, "Node.probeBuildShort",
      "Node.probeBuildLong", new BooleanCallback() {
      @Override
      public Boolean get() {
        return respondBuild;
      }

      @Override
      public void set(Boolean val) {
        respondBuild = val;
      }
    });
    respondBuild = nodeConfig.getBoolean("probeBuild");
    nodeConfig.register("probeIdentifier", true, sortOrder++, true, true,
      "Node.probeRespondIdentifierShort", "Node.probeRespondIdentifierLong", new BooleanCallback() {
      @Override
      public Boolean get() {
        return respondIdentifier;
      }

      @Override
      public void set(Boolean val) {
        respondIdentifier = val;
      }
    });
    respondIdentifier = nodeConfig.getBoolean("probeIdentifier");
    nodeConfig.register("probeLinkLengths", true, sortOrder++, true, true, "Node.probeLinkLengthsShort",
      "Node.probeLinkLengthsLong", new BooleanCallback() {
      @Override
      public Boolean get() {
        return respondLinkLengths;
      }

      @Override
      public void set(Boolean val) {
        respondLinkLengths = val;
      }
    });
    respondLinkLengths = nodeConfig.getBoolean("probeLinkLengths");
    nodeConfig.register("probeLocation", true, sortOrder++, true, true, "Node.probeLocationShort",
      "Node.probeLocationLong", new BooleanCallback() {
      @Override
      public Boolean get() {
        return respondLocation;
      }

      @Override
      public void set(Boolean val) {
        respondLocation = val;
      }
    });
    respondLocation = nodeConfig.getBoolean("probeLocation");
    nodeConfig.register("probeStoreSize", true, sortOrder++, true, true, "Node.probeStoreSizeShort",
      "Node.probeStoreSizeLong", new BooleanCallback() {
      @Override
      public Boolean get() {
        return respondStoreSize;
      }

      @Override
      public void set(Boolean val) {
        respondStoreSize = val;
      }
    });
    respondStoreSize = nodeConfig.getBoolean("probeStoreSize");
    nodeConfig.register("probeUptime", true, sortOrder++, true, true, "Node.probeUptimeShort",
      "Node.probeUptimeLong", new BooleanCallback() {
      @Override
      public Boolean get() {
        return respondUptime;
      }

      @Override
      public void set(Boolean val) throws InvalidConfigValueException, NodeNeedRestartException {
        respondUptime = val;
      }
    });
    respondUptime = nodeConfig.getBoolean("probeUptime");
    nodeConfig.register("probeRejectStats", true, sortOrder++, true, true, "Node.probeRejectStatsShort",
        "Node.probeRejectStatsLong", new BooleanCallback() {
        @Override
        public Boolean get() {
          return respondRejectStats;
        }

        @Override
        public void set(Boolean val) throws InvalidConfigValueException, NodeNeedRestartException {
          respondRejectStats = val;
        }
      });
      respondRejectStats = nodeConfig.getBoolean("probeRejectStats");
     
    nodeConfig.register("probeOverallBulkOutputCapacityUsage", true, sortOrder++, true, true, "Node.respondOverallBulkOutputCapacityUsage",
        "Node.respondOverallBulkOutputCapacityUsageLong", new BooleanCallback() {

          @Override
          public Boolean get() {
            return respondOverallBulkOutputCapacityUsage;
          }

          @Override
          public void set(Boolean val)
              throws InvalidConfigValueException,
              NodeNeedRestartException {
            respondOverallBulkOutputCapacityUsage = val;
          }
     
    });
    respondOverallBulkOutputCapacityUsage = nodeConfig.getBoolean("probeOverallBulkOutputCapacityUsage");

    nodeConfig.register("identifier", -1, sortOrder++, true, true, "Node.probeIdentifierShort",
      "Node.probeIdentifierLong", new LongCallback() {
      @Override
      public Long get() {
        return probeIdentifier;
      }

      @Override
      public void set(Long val) {
        probeIdentifier = val;
        //-1 is reserved for picking a random value; don't pick it randomly.
        while(probeIdentifier == -1) probeIdentifier = node.random.nextLong();
      }
    }, false);
    probeIdentifier = nodeConfig.getLong("identifier");

    /*
     * set() is not used when setting up an option with its default value, so do so manually to avoid using
     * an identifier of -1.
     */
    try {
      if(probeIdentifier == -1) {
        nodeConfig.getOption("identifier").setValue("-1");
        //TODO: Store config here as it has changed?
        node.config.store();
      }
    } catch (InvalidConfigValueException e) {
      Logger.error(Probe.class, "node.identifier set() unexpectedly threw.", e);
View Full Code Here

  }

  @Override
  public HTMLNode getHTMLText() {
    HTMLNode textNode = new HTMLNode("div");
    SubConfig sc = node.config.get("node");
    Option<?> o = sc.getOption("tempIPAddressHint");
   
    NodeL10n.getBase().addL10nSubstitution(textNode, "IPUndetectedUserAlert."+(node.ipDetector.isDetecting() ? "detectingWithConfigLink" : "unknownAddressWithConfigLink"),
        new String[] { "link" },
        new HTMLNode[] { HTMLNode.link("/config/"+sc.getPrefix()) });
   
    int peers = node.peers.getDarknetPeers().length;
    if(peers > 0)
      textNode.addChild("p", l10n("noIPMaybeFromPeers", "number", Integer.toString(peers)));
   
    if(node.ipDetector.noDetectPlugins()) {
      HTMLNode p = textNode.addChild("p");
      NodeL10n.getBase().addL10nSubstitution(p, "IPUndetectedUserAlert.loadDetectPlugins", new String[] { "plugins", "config", },
          new HTMLNode[] { HTMLNode.link("/plugins/"), HTMLNode.link("/config/node") });
    } else if(!node.ipDetector.hasJSTUN() && !node.ipDetector.isDetecting()) {
      HTMLNode p = textNode.addChild("p");
      NodeL10n.getBase().addL10nSubstitution(p, "IPUndetectedUserAlert.loadJSTUN", new String[] { "plugins" },
          new HTMLNode[] { HTMLNode.link("/plugins/") });
    }
   
    addPortForwardSuggestion(textNode);
   
    HTMLNode formNode = textNode.addChild("form", new String[] { "action", "method" }, new String[] { "/config/"+sc.getPrefix(), "post" });
    formNode.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", node.clientCore.formPassword });
    formNode.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "subconfig", sc.getPrefix() });
    HTMLNode listNode = formNode.addChild("ul", "class", "config");
    HTMLNode itemNode = listNode.addChild("li");
    itemNode.addChild("span", "class", "configshortdesc", o.getLocalisedShortDesc()).addChild("input", new String[] { "type", "name", "value" }, new String[] { "text", sc.getPrefix() + ".tempIPAddressHint", o.getValueDisplayString() });
    itemNode.addChild("span", "class", "configlongdesc", o.getLocalisedLongDesc());
    formNode.addChild("input", new String[] { "type", "value" }, new String[] { "submit", NodeL10n.getBase().getString("UserAlert.apply") });
    formNode.addChild("input", new String[] { "type", "value" }, new String[] { "reset", NodeL10n.getBase().getString("UserAlert.reset") });
   
    return textNode;
View Full Code Here

  private MyCallback<NETWORK_THREAT_LEVEL> networkThreatLevelCallback;
  private MyCallback<PHYSICAL_THREAT_LEVEL> physicalThreatLevelCallback;
 
  public SecurityLevels(Node node, PersistentConfig config) {
    this.node = node;
    SubConfig myConfig = new SubConfig("security-levels", config);
    int sortOrder = 0;
    networkThreatLevelCallback = new MyCallback<NETWORK_THREAT_LEVEL>() {

      @Override
      public String get() {
        synchronized(SecurityLevels.this) {
          return networkThreatLevel.name();
        }
      }

      @Override
      public String[] getPossibleValues() {
        NETWORK_THREAT_LEVEL[] values = NETWORK_THREAT_LEVEL.values();
        String[] names = new String[values.length];
        for(int i=0;i<names.length;i++)
          names[i] = values[i].name();
        return names;
      }

      @Override
      protected NETWORK_THREAT_LEVEL getValue() {
        return networkThreatLevel;
      }

      @Override
      protected void setValue(String val) throws InvalidConfigValueException {
        NETWORK_THREAT_LEVEL newValue = parseNetworkThreatLevel(val);
        if(newValue == null)
          throw new InvalidConfigValueException("Invalid value for network threat level: "+val);
        synchronized(SecurityLevels.this) {
          networkThreatLevel = newValue;
        }
      }

    };
    myConfig.register("networkThreatLevel", "HIGH", sortOrder++, false, true, "SecurityLevels.networkThreatLevelShort", "SecurityLevels.networkThreatLevel", networkThreatLevelCallback);
    NETWORK_THREAT_LEVEL netLevel = NETWORK_THREAT_LEVEL.valueOf(myConfig.getString("networkThreatLevel"));
    if(myConfig.getRawOption("networkThreatLevel") != null) {
      networkThreatLevel = netLevel;
    } else {
      // Call all the callbacks so that the config is consistent with the threat level.
      setThreatLevel(netLevel);
    }
    // FIXME remove back compat
    String s = myConfig.getRawOption("friendsThreatLevel");
    if(s != null) {
      friendsThreatLevel = parseFriendsThreatLevel(s);
    } else {
      friendsThreatLevel = null;
    }
    physicalThreatLevelCallback = new MyCallback<PHYSICAL_THREAT_LEVEL>() {

      @Override
      public String get() {
        synchronized(SecurityLevels.this) {
          return physicalThreatLevel.name();
        }
      }

      @Override
      public String[] getPossibleValues() {
        PHYSICAL_THREAT_LEVEL[] values = PHYSICAL_THREAT_LEVEL.values();
        String[] names = new String[values.length];
        for(int i=0;i<names.length;i++)
          names[i] = values[i].name();
        return names;
      }

      @Override
      protected PHYSICAL_THREAT_LEVEL getValue() {
        return physicalThreatLevel;
      }

      @Override
      protected void setValue(String val) throws InvalidConfigValueException {
        PHYSICAL_THREAT_LEVEL newValue = PHYSICAL_THREAT_LEVEL.valueOf(val);
        if(newValue != null)
          throw new InvalidConfigValueException("Invalid value for physical threat level: "+val);
        synchronized(SecurityLevels.this) {
          physicalThreatLevel = newValue;
        }
      }

    };
    myConfig.register("physicalThreatLevel", "NORMAL", sortOrder++, false, true, "SecurityLevels.physicalThreatLevelShort", "SecurityLevels.physicalThreatLevel", physicalThreatLevelCallback);
    PHYSICAL_THREAT_LEVEL physLevel = PHYSICAL_THREAT_LEVEL.valueOf(myConfig.getString("physicalThreatLevel"));
    if(myConfig.getRawOption("physicalThreatLevel") != null) {
      physicalThreatLevel = physLevel;
    } else {
      // Call all the callbacks so that the config is consistent with the threat level.
      setThreatLevel(physLevel);
    }
   
    myConfig.finishedInitialization();
  }
View Full Code Here

    isL10nPlugin = (plug instanceof FredPluginL10n);
    isBaseL10nPlugin = (plug instanceof FredPluginBaseL10n);
    isConfigurablePlugin = (plug instanceof FredPluginConfigurable);
    if(isConfigurablePlugin) {
      config = FilePersistentConfig.constructFilePersistentConfig(new File(node.getCfgDir(), "plugin-"+getPluginClassName()+".ini"), "config options for plugin: "+getPluginClassName());
      subconfig = new SubConfig(getPluginClassName(), config);
      ((FredPluginConfigurable)plug).setupConfig(subconfig);
      config.finishedInit();
      configToadlet = new ConfigToadlet(pr.getHLSimpleClient(), config, subconfig, node, node.clientCore, (FredPluginConfigurable)plug);
    } else {
      config = null;
View Full Code Here

        }
        else if (selection == types.length+1) {
          System.err.print("Enter new HTL: ");
          htl = Byte.valueOf(r.readLine());
        } else if (selection == types.length+2) {
          SubConfig nodeConfig = nodes[index].config.get("node");
          String[] options = { "probeBandwidth", "probeBuild", "probeIdentifier", "probeLinkLengths", "probeLinkLengths", "probeUptime" };
          for (String option : options) {
            System.err.print(option + ": ");
            nodeConfig.set(option, Boolean.valueOf(r.readLine()));
          }
        } else nodes[index].startProbe(htl, random.nextLong(), types[selection], print);
      } catch (Exception e) {
        //If a non-number is entered or one outside the bounds.
        System.out.print(e.toString());
View Full Code Here

TOP

Related Classes of freenet.config.SubConfig

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.