dns resource is parametrized by fqdn, class and type
This commit is contained in:
@@ -17,16 +17,26 @@ import de.measite.minidns.Client;
|
||||
import de.measite.minidns.DNSMessage;
|
||||
import de.measite.minidns.Question;
|
||||
import de.measite.minidns.Record;
|
||||
import de.measite.minidns.Record.CLASS;
|
||||
import de.measite.minidns.Record.TYPE;
|
||||
import de.measite.minidns.record.TXT;
|
||||
|
||||
public class DnsResource extends LinkedResource {
|
||||
|
||||
static Pattern magicPattern =
|
||||
final static Pattern magicPattern =
|
||||
Pattern.compile("pgpid\\+cookie=([a-zA-Z0-9]+)(?:#|;)([a-zA-Z0-9]+)");
|
||||
|
||||
DnsResource(Set<String> flags, HashMap<String, String> params, URI uri) {
|
||||
String mFqdn;
|
||||
CLASS mClass;
|
||||
TYPE mType;
|
||||
|
||||
DnsResource(Set<String> flags, HashMap<String, String> params, URI uri,
|
||||
String fqdn, CLASS clazz, TYPE type) {
|
||||
super(flags, params, uri);
|
||||
|
||||
mFqdn = fqdn;
|
||||
mClass = clazz;
|
||||
mType = type;
|
||||
}
|
||||
|
||||
public static String generateText (Context context, byte[] fingerprint, String nonce) {
|
||||
@@ -49,14 +59,33 @@ public class DnsResource extends LinkedResource {
|
||||
&& (params == null || params.isEmpty()))) {
|
||||
return null;
|
||||
}
|
||||
return new DnsResource(flags, params, uri);
|
||||
|
||||
//
|
||||
String spec = uri.getSchemeSpecificPart();
|
||||
// If there are // at the beginning, this includes an authority - we don't support those!
|
||||
if (spec.startsWith("//")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String[] pieces = spec.split("\\?", 2);
|
||||
// In either case, part before a ? is the fqdn
|
||||
String fqdn = pieces[0];
|
||||
// There may be a query part
|
||||
if (pieces.length > 1) {
|
||||
// TODO parse CLASS and TYPE query paramters
|
||||
}
|
||||
|
||||
CLASS clazz = CLASS.IN;
|
||||
TYPE type = TYPE.TXT;
|
||||
|
||||
return new DnsResource(flags, params, uri, fqdn, clazz, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String fetchResource (OperationLog log, int indent) {
|
||||
|
||||
Client c = new Client();
|
||||
DNSMessage msg = c.query(new Question("mugenguild.com", TYPE.TXT));
|
||||
DNSMessage msg = c.query(new Question(mFqdn, mType, mClass));
|
||||
Record aw = msg.getAnswers()[0];
|
||||
TXT txt = (TXT) aw.getPayload();
|
||||
return txt.getText().toLowerCase();
|
||||
|
||||
@@ -121,7 +121,7 @@ public class LinkedIdCreateDnsStep1Fragment extends Fragment {
|
||||
}
|
||||
});
|
||||
|
||||
mEditDns.setText("mugenguild.com");
|
||||
mEditDns.setText("test.mugenguild.com");
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user