示例#1
0
 @Override
 public void onEvent(Event e) {
   if (e instanceof FuseBind) {
     FuseBind f = (FuseBind) e;
     onNewMountpoint(f.source, f.mountpoint);
   } else {
     Logger.error("unknown event: " + e);
   }
 }
示例#2
0
  public void saveDNSlist() {

    try {
      Logger.info(
          "saveDNSList() saving dnss to: "
              + System.getContext().getFilesDir().getAbsolutePath()
              + "/tools/ettercap/share/etter.dns");
      File f =
          new File(
              System.getContext().getFilesDir().getAbsolutePath()
                  + "/tools/ettercap/share/etter.dns");
      FileOutputStream fos = new FileOutputStream(f);
      fos.write(mTextDnsList.getText().toString().getBytes());
      fos.close();

      Toast.makeText(this, "Saved", Toast.LENGTH_SHORT).show();
    } catch (Exception e) {
      Logger.error("readDNSList() error: " + e.getLocalizedMessage());
      Toast.makeText(this, "Error: " + e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
    }
  }
示例#3
0
  public void readDNSlist() {
    String _line = "";

    try {
      BufferedReader inputReader =
          new BufferedReader(
              new FileReader(
                  System.getContext().getFilesDir().getAbsolutePath()
                      + "/tools/ettercap/share/etter.dns"));
      while ((_line = inputReader.readLine()) != null) {
        mTextDnsList.append(_line + "\n");
      }

      inputReader.close();
    } catch (Exception e) {
      Logger.error("readDNSList() error: " + e.getLocalizedMessage());
    }
  }
示例#4
0
 // TODO: make more setValue methods each with the corresponding type.
 public void setValue(String value) throws NumberFormatException {
   switch (mType) {
     case STRING:
       mValue = value;
       break;
     case ADDRESS:
       try {
         mValue = InetAddress.getByName(value).getHostAddress();
       } catch (UnknownHostException uhe) {
         throw new NumberFormatException("invalid IP address: " + value);
       }
       break;
     case PORT:
       int i = Integer.parseInt(value);
       if (i < 0 || i > 65535) throw new NumberFormatException("port must be between 0 and 65535");
       break;
     case BOOLEAN:
       value = value.toLowerCase();
       if (value.equals("true") || value.equals("false")) mValue = value;
       else throw new NumberFormatException("boolean must be true or false");
       break;
     case ENUM:
       // TODO: handle integer enums
       ArrayList<String> valid = ((ArrayList<String>) mAttributes.get("enums"));
       if (!valid.contains(value)) {
         String valid_line = "";
         for (String v : valid) {
           valid_line += " " + v;
         }
         Logger.warning("expected: (" + valid_line + ") got: " + value);
         throw new NumberFormatException("invalid choice");
       }
       mValue = value;
       break;
     case PATH:
       // TODO:
       mValue = value;
       break;
   }
 }