Java Code Examples for org.xbill.DNS.Type#value()

The following examples show how to use org.xbill.DNS.Type#value() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: lookup.java    From dnsjava with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public static void main(String[] args) throws Exception {
  int type = Type.A;
  int start = 0;
  if (args.length > 2 && args[0].equals("-t")) {
    type = Type.value(args[1]);
    if (type < 0) {
      throw new IllegalArgumentException("invalid type");
    }
    start = 2;
  }
  for (int i = start; i < args.length; i++) {
    Lookup l = new Lookup(args[i], type);
    l.run();
    printAnswer(args[i], l);
  }
}
 
Example 2
Source File: update.java    From dnsjava with BSD 2-Clause "Simplified" License 6 votes vote down vote up
Record parseRR(Tokenizer st, int classValue, long TTLValue) throws IOException {
  Name name = st.getName(zone);
  long ttl;
  int type;

  String s = st.getString();

  try {
    ttl = TTL.parseTTL(s);
    s = st.getString();
  } catch (NumberFormatException e) {
    ttl = TTLValue;
  }

  if (DClass.value(s) >= 0) {
    classValue = DClass.value(s);
    s = st.getString();
  }

  if ((type = Type.value(s)) < 0) {
    throw new IOException("Invalid type: " + s);
  }

  return Record.fromString(name, type, classValue, ttl, st, zone);
}
 
Example 3
Source File: update.java    From dnsjava with BSD 2-Clause "Simplified" License 6 votes vote down vote up
void doProhibit(Tokenizer st) throws IOException {
  Tokenizer.Token token;
  Name name;
  Record record;
  int type;

  name = st.getName(zone);
  token = st.get();
  if (token.isString()) {
    if ((type = Type.value(token.value)) < 0) {
      throw new IOException("Invalid type: " + token.value);
    }
  } else {
    type = Type.ANY;
  }
  record = Record.newRecord(name, type, DClass.NONE, 0);
  query.addRecord(record, Section.PREREQ);
  print(record);
}
 
Example 4
Source File: DNSFormActivity.java    From androdns with Apache License 2.0 5 votes vote down vote up
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    Spinner spProtocol = (Spinner) findViewById(R.id.spinnerProto);
    if (parent == spProtocol) {

        // set TCP flag state from proto
        String proto = (String) spProtocol.getSelectedItem();
        CheckBox tcpCheckbox = (CheckBox) findViewById(R.id.cbTCP);
        if (!proto.equalsIgnoreCase("DNS")) { //DoH and DoT are always TCP
            tcpCheckbox.setEnabled(false);
        } else {
            tcpCheckbox.setEnabled(true);
        }

        setDefaultPortFromProto();

    }

    // set qtype number from spinner
    Spinner spKnownTypes = (Spinner) findViewById(R.id.spinnerKnownTypes);
    if (parent == spKnownTypes) {
        String selected = (String) spKnownTypes.getSelectedItem();
        String selectedNumber = "" + Type.value(selected);
        (((EditText) findViewById(R.id.txtQTYPE))).setText(selectedNumber);
    }

    updateBookmarkImageState();
}
 
Example 5
Source File: update.java    From dnsjava with BSD 2-Clause "Simplified" License 5 votes vote down vote up
void doRequire(Tokenizer st) throws IOException {
  Tokenizer.Token token;
  Name name;
  Record record;
  int type;

  name = st.getName(zone);
  token = st.get();
  if (token.isString()) {
    if ((type = Type.value(token.value)) < 0) {
      throw new IOException("Invalid type: " + token.value);
    }
    token = st.get();
    boolean iseol = token.isEOL();
    st.unget();
    if (!iseol) {
      record = Record.fromString(name, type, defaultClass, 0, st, zone);
    } else {
      record = Record.newRecord(name, type, DClass.ANY, 0);
    }
  } else {
    record = Record.newRecord(name, Type.ANY, DClass.ANY, 0);
  }

  query.addRecord(record, Section.PREREQ);
  print(record);
}
 
Example 6
Source File: update.java    From dnsjava with BSD 2-Clause "Simplified" License 5 votes vote down vote up
void doDelete(Tokenizer st) throws IOException {
  Tokenizer.Token token;
  String s;
  Name name;
  Record record;
  int type;

  name = st.getName(zone);
  token = st.get();
  if (token.isString()) {
    s = token.value;
    if (DClass.value(s) >= 0) {
      s = st.getString();
    }
    if ((type = Type.value(s)) < 0) {
      throw new IOException("Invalid type: " + s);
    }
    token = st.get();
    boolean iseol = token.isEOL();
    st.unget();
    if (!iseol) {
      record = Record.fromString(name, type, DClass.NONE, 0, st, zone);
    } else {
      record = Record.newRecord(name, type, DClass.ANY, 0);
    }
  } else {
    record = Record.newRecord(name, Type.ANY, DClass.ANY, 0);
  }

  query.addRecord(record, Section.UPDATE);
  print(record);
}