1700478689
}
1700478690
1700478691
public void setOwner(String owner){
1700478692
1700478693
this.owner=owner;
1700478694
1700478695
}
1700478696
1700478697
//输出记录信息
1700478698
1700478699
@Override
1700478700
1700478701
public String toString(){
1700478702
1700478703
String str=“域名:”+this.domain;
1700478704
1700478705
str=str+”\nIP地址:”+this.ip;
1700478706
1700478707
str=str+”\n解析者:”+this.owner;
1700478708
1700478709
return str;
1700478710
1700478711
}
1700478712
1700478713
}
1700478714
1700478715
为什么要覆写toString方法呢?是为了打印展示的需要,可以直接把Recorder的信息打印出来。我们再来看抽象域名服务器,如代码清单32-32所示。
1700478716
1700478717
代码清单32-32 抽象域名服务器
1700478718
1700478719
public abstract class DnsServer{
1700478720
1700478721
//上级DNS是谁
1700478722
1700478723
private DnsServer upperServer;
1700478724
1700478725
//解析域名
1700478726
1700478727
public final Recorder resolve(String domain){
1700478728
1700478729
Recorder recorder=null;
1700478730
1700478731
if(isLocal(domain)){//是本服务器能解析的域名
1700478732
1700478733
recorder=echo(domain);
1700478734
1700478735
}else{//本服务器不能解析
1700478736
1700478737
//提交上级DNS进行解析
1700478738
[
上一页 ]
[ :1.700478689e+09 ]
[
下一页 ]