打字猴:1.700478841e+09
1700478841 protected boolean isLocal(String domain){
1700478842
1700478843 return domain.endsWith(”.cn”);
1700478844
1700478845 }
1700478846
1700478847 }
1700478848
1700478849 代码清单32-35 全球顶级DNS服务器
1700478850
1700478851 public class TopDnsServer extends DnsServer{
1700478852
1700478853 @Override
1700478854
1700478855 protected Recorder echo(String domain){
1700478856
1700478857 Recorder recorder=super.echo(domain);
1700478858
1700478859 recorder.setOwner(“全球顶级DNS服务器”);
1700478860
1700478861 return recorder;
1700478862
1700478863 }
1700478864
1700478865 @Override
1700478866
1700478867 protected boolean isLocal(String domain){
1700478868
1700478869 //所有的域名最终的解析地点
1700478870
1700478871 return true;
1700478872
1700478873 }
1700478874
1700478875 }
1700478876
1700478877 所有的DNS服务器都准备好了,下面我们写一个客户端来模拟一下IP地址是怎么解析的,如代码清单32-36所示。
1700478878
1700478879 代码清单32-36 场景类
1700478880
1700478881 public class Client{
1700478882
1700478883 public static void main(String[]args)throws Exception{
1700478884
1700478885 //上海域名服务器
1700478886
1700478887 DnsServer sh=new SHDnsServer();
1700478888
1700478889 //中国顶级域名服务器
1700478890
[ 上一页 ]  [ :1.700478841e+09 ]  [ 下一页 ]