{
    "name"  : "正向DNS代理配置检查",
    "problems" : {
        "dnsDelegate" : {
            "desc"      : "【问题】当前dns代理的域名服务器未配置静态路由,",
            "advice"    : "【建议】需要给dns代理的域名服务器配置静态路由,如电信线路接口配置ip name-server 202.101.98.101 表示DNS服务器的地址为202.101.98.101需要针对这个地址配置明静态细路由走电信接口的下一跳。"
        },
		"NATError" : {
            "desc"      : "【问题】当前dns代理的域名服务器未配置静态路由,",
            "advice"    : "【建议】需要给dns代理的域名服务器配置静态路由,如电信线路接口配置ip name-server 202.101.98.101 表示DNS服务器的地址为202.101.98.101需要针对这个地址配置明静态细路由走电信接口的下一跳。"
        }
    }
}
---------------------------code-------------------------------
res = cli("show version detail")
resArr = res.match(/System software version : EG_RGOS 11.1\((.+)\).+/)
versionNumber = resArr[1]
if versionNumber >= 6 :
    return "success"
end

res = cli("show run | in dns-proxy enable")
resArr = res.split(/\r?\n/)
if resArr.length == 2 :
    return "success"
end

res = cli("show dns-proxy name-server")
resArr = res.split(/\r?\n/)
if resArr.length == 6 || res.indexOf('.') == -1:
    return "success"
end

dnsServiceArr = []
i = 5
while i < (resArr.length - 1):
    resArrTmp = resArr[i]
    resArrTmp = resArrTmp.trim()
    ressignalArr =  resArrTmp.split(/\s+/)
    serviceIP = ressignalArr[2]
    dnsServiceArr.push(serviceIP)
    i = i + 1
end

j = 0
while j < dnsServiceArr.length :
    serverIP = dnsServiceArr[j]
    cmd = "show run | in ip route " + serverIP
    res = cli(cmd)
    resArr = res.split(/\r?\n/)
    if resArr.length == 2 :
        add_problem("dnsDelegate")
        return "warn"
    end
    j = j + 1
end

res = cli("show run | in ip nat inside")
resArr = res.match(/\n\s+\w+/) 
print resArr
if resArr !=null :
	res = cli("show run | in dns-proxy enable")
	resArr = res.match(/dns-proxy/ig)
	if resArr[1] == null :
		print 'warn'
		add_problem("NATError")
		return 'warn'
	end
end

return 'success'
 


