1700479013
1700479014
public void update(Observable arg0,Object arg1){
1700479015
1700479016
Recorder recorder=(Recorder)arg1;
1700479017
1700479018
//如果本机能解析
1700479019
1700479020
if(isLocal(recorder)){
1700479021
1700479022
recorder.setIp(genIpAddress());
1700479023
1700479024
}else{//本机不能解析,则提交到上级DNS
1700479025
1700479026
responsFromUpperServer(recorder);
1700479027
1700479028
}
1700479029
1700479030
//签名
1700479031
1700479032
sign(recorder);
1700479033
1700479034
}
1700479035
1700479036
//作为被观察者,允许增加观察者,这里上级DNS一般只有一个
1700479037
1700479038
public void setUpperServer(DnsServer dnsServer){
1700479039
1700479040
//先清空,然后再增加
1700479041
1700479042
super.deleteObservers();
1700479043
1700479044
super.addObserver(dnsServer);
1700479045
1700479046
}
1700479047
1700479048
//向父DNS请求解析,也就是通知观察者
1700479049
1700479050
private void responsFromUpperServer(Recorder recorder){
1700479051
1700479052
super.setChanged();
1700479053
1700479054
super.notifyObservers(recorder);
1700479055
1700479056
}
1700479057
1700479058
//每个DNS服务器签上自己的名字
1700479059
1700479060
protected abstract void sign(Recorder recorder);
1700479061
1700479062
//每个DNS服务器都必须定义自己的处理级别
[
上一页 ]
[ :1.700479013e+09 ]
[
下一页 ]