home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2007 April / PCpro_2007_04.ISO / files / dsl / jNetTool.exe / org / xbill / DNS / SimpleResolver$Stream.class (.txt) < prev    next >
Encoding:
Java Class File  |  2005-06-05  |  2.4 KB  |  59 lines

  1. package org.xbill.DNS;
  2.  
  3. import java.io.IOException;
  4. import java.net.Socket;
  5.  
  6. class SimpleResolver$Stream {
  7.    SimpleResolver res;
  8.    Socket sock;
  9.    TSIG tsig;
  10.    TSIG.StreamVerifier verifier;
  11.  
  12.    SimpleResolver$Stream(SimpleResolver res) throws IOException {
  13.       this.res = res;
  14.       this.sock = new Socket(SimpleResolver.access$0(res), SimpleResolver.access$1(res));
  15.       this.sock.setSoTimeout(SimpleResolver.access$2(res));
  16.       this.tsig = SimpleResolver.access$3(res);
  17.    }
  18.  
  19.    void send(Message query) throws IOException {
  20.       if (this.tsig != null) {
  21.          this.tsig.apply(query, (TSIGRecord)null);
  22.          this.verifier = new TSIG.StreamVerifier(this.tsig, query.getTSIG());
  23.       }
  24.  
  25.       byte[] out = query.toWire(65535);
  26.       SimpleResolver.access$4(this.res, this.sock, out);
  27.    }
  28.  
  29.    Message next() throws IOException {
  30.       byte[] in = SimpleResolver.access$5(this.res, this.sock);
  31.       Message response = SimpleResolver.access$6(this.res, in);
  32.       if (response.getHeader().getRcode() != 0) {
  33.          return response;
  34.       } else {
  35.          if (this.verifier != null) {
  36.             TSIGRecord tsigrec = response.getTSIG();
  37.             int error = this.verifier.verify(response, in);
  38.             if (error == 0 && tsigrec != null) {
  39.                response.tsigState = 1;
  40.             } else if (error == 0) {
  41.                response.tsigState = 2;
  42.             } else {
  43.                response.tsigState = 4;
  44.             }
  45.          }
  46.  
  47.          return response;
  48.       }
  49.    }
  50.  
  51.    void close() {
  52.       try {
  53.          this.sock.close();
  54.       } catch (IOException var2) {
  55.       }
  56.  
  57.    }
  58. }
  59.