{
    "name"  : "默认路由的配置",
    "problems" : {
        "noDefaultRoute" : {
            "desc"      : "【问题】接口${0}没有配置默认路由，请确认是否需要开启",
            "advice"    : "【建议】该条线路是否存在质量问题，该条线路是否是专线（只能访问某些特定的资源）？如均不是，可以考虑开启默认路由"
        }
    }
}

---------------------------code-------------------------------
result = get_share_value('result')
if result == 'break' || result == 'needless' :
    return 'skip'
end

hasConfIntf = ''
rep = /via\s[a-zA-Z\d\s\/]+/g
response = cli('show ip route 0.0.0.0')
intfArr = response.match(rep)
if intfArr != null :
    foreach int in intfArr :
        hasConfIntf = hasConfIntf + int.replace('via ', '') + '. '
    end
end

rep = /[\d\.]{7,}..generated\s/g
ipArr = response.match(rep)
gatewayArr = cli('show interface gateway')
if ipArr != null :
    foreach ip in ipArr :
        ip = ip.match(/([\d\.]+)/)
        ip = ip[1]
        rep = format('[\\r\\n]+([a-zA-Z\\d\\s\\/]+)\\s*?%s',ip)
        rep = newRegExp(rep)
        intf = gatewayArr.match(rep)
        if intf != null :
            intf = intf[1]
            hasConfIntf = hasConfIntf + intf.replace('  ', '') + '. '
        end
    end
end

isAllConf = true
noConfIntfArr = ''
wan_int_info = get_share_value('wan_int_info')
foreach wan in wan_int_info:
    rep = newRegExp(wan)
    if rep.test(hasConfIntf) == false :
        if noConfIntfArr == '' :
            noConfIntfArr = noConfIntfArr + wan.intf
        else :
            noConfIntfArr = noConfIntfArr + ', ' + wan.intf
        end
        isAllConf = false
    end
end

print noConfIntfArr
if isAllConf == false :
    add_problem('noDefaultRoute', [noConfIntfArr])
    return 'warn'
end

return 'success'

