From: Edwin R. R. <er...@mo...> - 2003-08-29 13:14:05
|
Hello all, Disclaimer: I'm relatively new to the Java platform, so, please forgive me if I am making any obvious rookie mistakes. Summary: I am working with dnsjava to write some classes to replace our DDNS PERL libraries (NET::DNS). I can successfully connect to my nameservers, run queries, extract zone transfers, and even add "A Records", however, I am having trouble adding an MX record to a zone. 1) Here is a snippet of the code I am using to add an A record (that works): Name Nzone = Name.fromString(zone); Name Nhost = Name.fromString(host, Nzone); Update update = new Update(Nzone); //System.out.println("Update: " + Nhost + " " + typeValue + " " + ttl + " " + ip); Record r = Record.newRecord(Nhost, typeValue, dclass); update.add(Nhost, typeValue, ttl, ip); Resolver res = new SimpleResolver(this.master); res.setTSIGKey(this.keyName, this.keyValue); res.setTCP(true); Message msg = res.send(update); if (doesRecordExist(r, res)) return true; 2) Here is the snippet of code based on the above that tried to adapt to add MX records (does not work yet): Name Nzone = Name.fromString(zone); Name Nhost = Name.fromString(Nfqdn.getLabelString(0), Nzone); MXRecord m = new MXRecord(Nfqdn, dclass, ttl, pref, Ntarget); System.out.println("m: " + m.toString()); Update update = new Update(Nzone); //System.out.println("Update: " + Nhost + " " + typeValue + " " + ttl + " " + ip); Record r = (Record) m; System.out.println("r: " + r.toString()); update.add(r); //I've tried both update.add(r) and update.add(m) Resolver res = new SimpleResolver(this.master); res.setTSIGKey(this.keyName, this.keyValue); res.setTCP(true); Message msg = res.send(update); if (doesRecordExist(r, res)) return true; 3) When i call the toString() method of my MX record objects, they do appear to be correct: m: wwwwww.zzogy.com. 3600 ANY MX 10 mail.yahooo.com. r: wwwwww.zzogy.com. 3600 ANY MX 10 mail.yahooo.com. (these are just tests) Thanks in advance for any assistance/pointers you can offer. I have programmed mostly PERL for the last 10 years or so, but I am really liking Java. It's much cleaner and organized. -Edwin |