| 1 |
/* |
| 2 |
* Copyright 2015-2020 the original author or authors |
| 3 |
* |
| 4 |
* This software is licensed under the Apache License, Version 2.0, |
| 5 |
* the GNU Lesser General Public License version 2 or later ("LGPL") |
| 6 |
* and the WTFPL. |
| 7 |
* You may choose either license to govern your use of this software only |
| 8 |
* upon the condition that you accept all of the terms of either |
| 9 |
* the Apache License 2.0, the LGPL 2.1+ or the WTFPL. |
| 10 |
*/ |
| 11 |
package org.minidns.dnsqueryresult; |
| 12 |
|
| 13 |
import org.minidns.dnsmessage.DnsMessage; |
| 14 |
import org.minidns.dnsmessage.DnsMessage.RESPONSE_CODE; |
| 15 |
|
| 16 |
public abstract class DnsQueryResult { |
| 17 |
|
| 18 |
public enum QueryMethod { |
| 19 |
udp, |
| 20 |
tcp, |
| 21 |
asyncUdp, |
| 22 |
asyncTcp, |
| 23 |
cachedDirect, |
| 24 |
cachedSynthesized, |
| 25 |
testWorld, |
| 26 |
} |
| 27 |
|
| 28 |
public final QueryMethod queryMethod; |
| 29 |
|
| 30 |
public final DnsMessage query; |
| 31 |
|
| 32 |
public final DnsMessage response; |
| 33 |
|
| 34 |
protected DnsQueryResult(QueryMethod queryMethod, DnsMessage query, DnsMessage response) { |
| 35 |
assert queryMethod != null; |
| 36 |
assert query != null; |
| 37 |
assert response != null; |
| 38 |
|
| 39 |
this.queryMethod = queryMethod; |
| 40 |
this.query = query; |
| 41 |
this.response = response; |
| 42 |
} |
| 43 |
|
| 44 |
@Override |
| 45 |
public String toString() { |
| 46 |
return response.toString(); |
| 47 |
} |
| 48 |
|
| 49 |
public boolean wasSuccessful() { |
| 50 |
return response.responseCode == RESPONSE_CODE.NO_ERROR; |
| 51 |
} |
| 52 |
} |