Skip to content

Commit 1cb01dd

Browse files
author
bwelling
committed
- nsupdate compatibility and a bug fix to the update client.
(patch from David Sward <[email protected]>) git-svn-id: http://svn.code.sf.net/p/dnsjava/code/trunk@646 c76caeb1-94fd-44dd-870f-0c9d92034fc1
1 parent cdcdc32 commit 1cb01dd

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

Changelog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
8/9/2001
2+
- nsupdate compatibility and a bug fix to the update client.
3+
(patch from David Sward <[email protected]>)
14
8/8/2001
25
- The results of ANY queries were not properly cached.
36

update.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ public class update {
7979
if (operation.equals("server")) {
8080
server = st.nextToken();
8181
res = new SimpleResolver(server);
82+
if (st.hasMoreTokens()) {
83+
String portstr = st.nextToken();
84+
res.setPort(Short.parseShort(portstr));
85+
}
8286
}
8387

8488
else if (operation.equals("key")) {
@@ -234,9 +238,18 @@ else if (operation.equals("assert")) {
234238
print("Invalid update");
235239
return;
236240
}
237-
Record r = (Record) updates.nextElement();
238-
updzone = new Name(r.getName(), 1);
239-
dclass = r.getDClass();
241+
Record r = null;
242+
while (updates.hasMoreElements()) {
243+
r = (Record) updates.nextElement();
244+
if (updzone == null)
245+
updzone = new Name(r.getName(), 1);
246+
if (r.getDClass() != DClass.NONE &&
247+
r.getDClass() != DClass.ANY)
248+
{
249+
dclass = r.getDClass();
250+
break;
251+
}
252+
}
240253
}
241254
Record soa = Record.newRecord(updzone, Type.SOA, dclass);
242255
query.addRecord(soa, Section.ZONE);
@@ -377,6 +390,11 @@ record = parseRR(st, defaultClass, defaultTTL);
377390
name = new Name(s, origin);
378391
if (st.hasMoreTokens()) {
379392
s = st.nextToken();
393+
if ((dclass = DClass.value(s)) >= 0) {
394+
if (!st.hasMoreTokens())
395+
throw new IOException("Invalid format");
396+
s = st.nextToken();
397+
}
380398
if ((type = Type.value(s)) < 0)
381399
throw new IOException("Invalid type: " + s);
382400
if (st.hasMoreTokens()) {
@@ -636,7 +654,7 @@ else if (topic.equalsIgnoreCase("send"))
636654
"sends and resets the current update packet\n");
637655
else if (topic.equalsIgnoreCase("server"))
638656
System.out.println(
639-
"server <name>\n\n" +
657+
"server <name> [port]\n\n" +
640658
"server that receives send updates/queries\n");
641659
else if (topic.equalsIgnoreCase("show"))
642660
System.out.println(

0 commit comments

Comments
 (0)