예제 #1
0
파일: SelfRoute.java 프로젝트: kreon/jnode
  @Override
  public Object handle(Request req, Response resp) {
    String index = HTML.getContents("index.html");
    if (index.length() > 0) {
      return index;
    }
    SystemInfo info = MainHandler.getCurrentInstance().getInfo();

    String text =
        String.format(
            FORMAT_TABLE,
            String.format(FORMAT_TR, "Имя узла", info.getStationName())
                + String.format(FORMAT_TR, "Расположение узла", info.getLocation())
                + String.format(FORMAT_TR, "Сисоп", info.getSysop())
                + String.format(FORMAT_TR, "FTN-адрес(а)", getAddrList(info.getAddressList()))
                + String.format(FORMAT_TR, "Версия софта", MainHandler.getVersion())
                + String.format(FORMAT_TR, "ОС", getOS()));
    return HTML.start(false).append(text).footer().get();
  }
예제 #2
0
 @Override
 public Object handle(Request req, Response resp) {
   if (!enabled) {
     return "ERROR\r\nAUTOPOINT DISABLED\r\n";
   }
   String name = req.queryParams("_name");
   String email = req.queryParams("_email");
   String password = req.queryParams("_password");
   String about = req.queryParams("_about");
   String error = "";
   // check this shit
   {
     if (!name.matches("^[A-Z][a-z]+ [A-Z][a-z]+$")) {
       error += "NAME_CHECK_FAILED ";
     }
     if (!email.matches(
         "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$")) {
       error += "MAIL_CHECK_FAILED ";
     }
     if (password.length() < 8) {
       error += "MIN_PASSWD_LEN=8 ";
     }
     if (!(password.matches(".*[0-9].*")
         && password.matches(".*[A-Z].*")
         && password.matches(".*[a-z].*"))) {
       error += "WEAK_PASSWD ";
     }
     if (error.length() > 0) {
       error(error);
       return "ERROR\r\n" + error;
     }
   }
   // seems ok
   FtnAddress guessedAddress = guessNewPointAddress();
   if (guessedAddress == null) {
     error("NO_PNT_ADDRESS_SPACE");
     return "ERROR\r\nNO_PNT_ADDRESS_SPACE";
   }
   // do point request
   PointRequest pReq = new PointRequest();
   pReq.setAddr(guessedAddress.toString());
   pReq.setEmail(email);
   pReq.setName(name);
   pReq.setPassword(password);
   // save
   ORMManager.get(PointRequest.class).save(pReq);
   // create link
   Link link = new Link();
   link.setLinkAddress(guessedAddress.toString());
   link.setLinkName(name);
   link.setProtocolAddress("-");
   link.setProtocolPassword(password);
   link.setPaketPassword(password);
   ORMManager.get(Link.class).save(link);
   // write echomail
   {
     String techArea = MainHandler.getCurrentInstance().getProperty("stat.area", null);
     String text = guessedAddress + "," + name + "," + about;
     if (techArea != null) {
       Echoarea area = FtnTools.getAreaByName(techArea, null);
       FtnTools.writeEchomail(area, "New HTDGPoint", text);
     }
     FtnTools.writeNetmail(
         guessedAddress,
         FtnTools.getPrimaryFtnAddress(),
         MainHandler.getCurrentInstance().getInfo().getStationName(),
         MainHandler.getCurrentInstance().getInfo().getSysop(),
         "New HTDG point",
         text);
     ok(text);
   }
   return "OK\r\n" + guessedAddress;
 }