예제 #1
0
파일: Master.java 프로젝트: lemmy/dnsjava
  private Record parseRR(MyStringTokenizer st, boolean useLast, Record last, Name origin)
      throws IOException {
    Name name;
    int ttl;
    short type, dclass;

    if (!useLast) name = new Name(st.nextToken(), origin);
    else name = last.getName();

    String s = st.nextToken();

    try {
      ttl = TTL.parseTTL(s);
      s = st.nextToken();
    } catch (NumberFormatException e) {
      if (!useLast || last == null) ttl = defaultTTL;
      else ttl = last.getTTL();
    }

    if ((dclass = DClass.value(s)) > 0) s = st.nextToken();
    else dclass = DClass.IN;

    if ((type = Type.value(s)) < 0) throw new IOException("Parse error");

    return Record.fromString(name, type, dclass, ttl, st, origin);
  }
예제 #2
0
파일: Master.java 프로젝트: lemmy/dnsjava
 private void parseInclude(MyStringTokenizer st) throws IOException {
   if (!st.hasMoreTokens()) throw new IOException("Missing file to include");
   File newfile;
   String filename = st.nextToken();
   if (file.getParent() == null) newfile = new File(filename);
   else newfile = new File(file.getParent(), filename);
   if (st.hasMoreTokens()) included = new Master(newfile, new Name(st.nextToken()));
   else included = new Master(newfile, origin);
 }
예제 #3
0
  public static void main(String args[]) throws IOException {

    InputStreamReader isr = new InputStreamReader(System.in);
    BufferedReader br = new BufferedReader(isr);

    while (true) {
      MyStringTokenizer st = new MyStringTokenizer(br.readLine());
      while (st.hasMoreTokens()) System.out.println(st.nextToken());
    }
  }
예제 #4
0
 KEYRecord(Name _name, short _dclass, int _ttl, MyStringTokenizer st, Name origin)
     throws IOException {
   super(_name, Type.KEY, _dclass, _ttl);
   flags = (short) Integer.decode(st.nextToken()).intValue();
   proto = (byte) Integer.parseInt(st.nextToken());
   alg = (byte) Integer.parseInt(st.nextToken());
   /* If this is a null key, there's no key data */
   if (!((flags & (FLAG_NOKEY)) == (FLAG_NOKEY))) key = base64.fromString(st.remainingTokens());
   else key = null;
 }
예제 #5
0
 Record rdataFromString(Name name, short dclass, int ttl, MyStringTokenizer st, Name origin)
     throws TextParseException {
   SIGRecord rec = new SIGRecord(name, dclass, ttl);
   rec.covered = Type.value(st.nextToken());
   rec.alg = Byte.parseByte(st.nextToken());
   rec.labels = Byte.parseByte(st.nextToken());
   rec.origttl = TTL.parseTTL(st.nextToken());
   rec.expire = parseDate(st.nextToken());
   rec.timeSigned = parseDate(st.nextToken());
   rec.footprint = (short) Integer.parseInt(st.nextToken());
   rec.signer = Name.fromString(st.nextToken(), origin);
   if (st.hasMoreTokens()) rec.signature = base64.fromString(st.remainingTokens());
   return rec;
 }
예제 #6
0
파일: Master.java 프로젝트: lemmy/dnsjava
  /** Returns the next record in the master file */
  public Record nextRecord() throws IOException {
    String line;
    MyStringTokenizer st;

    if (included != null) {
      Record rec = included.nextRecord();
      if (rec != null) return rec;
      included = null;
    }
    while (true) {
      line = readExtendedLine(br);
      if (line == null) return null;
      if (line.length() == 0 || line.startsWith(";")) continue;

      boolean space = line.startsWith(" ") || line.startsWith("\t");
      st = new MyStringTokenizer(line);

      String s = st.nextToken();
      if (s.equals("$ORIGIN")) {
        origin = parseOrigin(st);
        continue;
      }
      if (s.equals("$TTL")) {
        defaultTTL = parseTTL(st);
        continue;
      }
      if (s.equals("$INCLUDE")) {
        parseInclude(st);
        /*
         * If we continued, we wouldn't be looking in
         * the new file.  Recursing works better.
         */
        return nextRecord();
      } else if (s.charAt(0) == '$') throw new IOException("Invalid directive: " + s);
      st.putBackToken(s);
      return (last = parseRR(st, space, last, origin));
    }
  }
예제 #7
0
파일: MXRecord.java 프로젝트: lemmy/dnsjava
 public MXRecord(Name _name, short _dclass, int _ttl, MyStringTokenizer st, Name origin)
     throws IOException {
   super(_name, Type.MX, _dclass, _ttl);
   priority = Short.parseShort(st.nextToken());
   target = new Name(st.nextToken(), origin);
 }
예제 #8
0
파일: Master.java 프로젝트: lemmy/dnsjava
 private Name parseOrigin(MyStringTokenizer st) throws IOException {
   if (!st.hasMoreTokens()) throw new IOException("Missing ORIGIN");
   return new Name(st.nextToken());
 }
예제 #9
0
파일: Master.java 프로젝트: lemmy/dnsjava
 private int parseTTL(MyStringTokenizer st) throws IOException {
   if (!st.hasMoreTokens()) throw new IOException("Missing TTL");
   return Integer.parseInt(st.nextToken());
 }
예제 #10
0
 public NS_CNAME_PTRRecord(
     Name _name, short _type, short _dclass, int _ttl, MyStringTokenizer st, Name origin)
     throws IOException {
   super(_name, _type, _dclass, _ttl);
   target = new Name(st.nextToken(), origin);
 }