Exemplo n.º 1
0
  private void generate() {
    token = settings.getProperty("web.token");
    if (token == null) {
      Random rand = new Random(System.currentTimeMillis() * System.nanoTime() * MAGIC_RANDOM_SEED);
      byte[] token_bytes = new byte[TOKEN_LENGTH];
      for (int i = 0; i < TOKEN_LENGTH; i++) {
        token_bytes[i] = (byte) ((48 + rand.nextInt(74)) & 0xff);
      }
      token = new String(token_bytes);
    }
    String port = settings.getProperty("web.port");
    if (port == null) {
      Random rand = new Random(System.currentTimeMillis() * System.nanoTime() * MAGIC_RANDOM_SEED);
      this.port = 1024 + rand.nextInt(64500);
    } else {
      this.port = Integer.valueOf(port);
    }

    listen = settings.getProperty("web.listen");
    if (listen == null) {
      listen = "0.0.0.0";
    }
    view = settings.getProperty("web.view", "/view");
  }
Exemplo n.º 2
0
 private WebServerMain(String[] args) {
   for (String arg : args) {
     if (arg.startsWith("-Dconfig=")) {
       settings = new ScannerSetting(arg.substring(9));
       return;
     }
   }
   settings = new ScannerSetting();
   for (String arg : args) {
     Matcher m = define_pattern.matcher(arg);
     if (m.matches()) {
       settings.setProperty(m.group(1), m.group(2));
     }
   }
 }