{
    "name"  : "端口映射配置是否正确",
    "problems" : {
        "port1" : {
            "desc"      : "【问题】服务器内网IP地址未配置端口映射规则。",
            "advice"    : "【建议】可以在WEB上配置端口映射规则。"
        },
		 "port2" : {
            "desc"      : "【问题】端口映射规则配置错误。",
            "advice"    : "【建议】请检查端口映射规则，内外网IP地址是否配反。"
        },
		 "port3" : {
            "desc"      : "【问题】端口映射规则未配置permit-inside。",
            "advice"    : "【建议】如果希望内网用户使用公网IP地址访问内网服务器，请配置permit-inside。"
        }
    }
}
---------------------------code-------------------------------
res = cli("show run | in ip nat inside source static")
if res.indexOf('.') == -1:
	add_problem("port1")
    return "warn"
end

res = cli("show run | in ip nat inside source static")
resArr = res.split(/\r?\n/) 
i = 0
while i < resArr.length :
    resArrTmp = resArr[i]
    resArrTmp = resArrTmp.trim()
	if resArrTmp.match(/static ([0-9].*)/gi) == -1 && resArrTmp.match(/udp ([0-9].*)/gi) == -1 && resArrTmp.match(/tcp ([0-9].*)/gi) == -1 :
		add_problem("port2")
        return "warn"
	end	  
    i = i + 1
end

res = cli("show run | in ip nat inside source static")
resArr = res.split(/\r?\n/) 
i = 0
while i < resArr.length :
    resArrTmp = resArr[i]
    resArrTmp = resArrTmp.trim()
     if resArrTmp.indexOf('.') != -1:
		if resArrTmp.indexOf("match") == -1 && resArrTmp.indexOf("permit-inside") == -1 :
			add_problem("port3")
			return "warn"
		end
	end	
    i = i + 1
end

return 'success'
