本文整理汇总了Python中karesansui.lib.checker.Checker.check_cidr方法的典型用法代码示例。如果您正苦于以下问题:Python Checker.check_cidr方法的具体用法?Python Checker.check_cidr怎么用?Python Checker.check_cidr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类karesansui.lib.checker.Checker
的用法示例。
在下文中一共展示了Checker.check_cidr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: validates_server
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import check_cidr [as 别名]
def validates_server(obj):
checker = Checker()
check = True
_ = obj._
checker.errors = []
if not is_param(obj.input, "uniqkey"):
check = False
checker.add_error(_('"%s" is required.') % _("Unique Key"))
else:
check = checker.check_unique_key(_("Unique Key"), obj.input.uniqkey, CHECK_EMPTY | CHECK_VALID) and check
if not is_param(obj.input, "port"):
check = False
checker.add_error(_('"%s" is required.') % _("Port Number"))
else:
check = (
checker.check_number(
_("Port Number"),
obj.input.port,
CHECK_EMPTY | CHECK_VALID | CHECK_MIN | CHECK_MAX,
PORT_MIN_NUMBER,
PORT_MAX_NUMBER,
)
and check
)
if not is_param(obj.input, "access"):
check = False
checker.add_error(_('"%s" is required.') % _("Access Policy"))
else:
if obj.input.access == "all":
check = True and check
elif obj.input.access == "network":
if not obj.input.has_key("network"):
check = False
checker.add_error(_('"%s" is required.') % _("Permit access from same network"))
else:
check = (
checker.check_cidr(
_("Permit Access From Same Network"), obj.input.network, CHECK_EMPTY | CHECK_VALID
)
and check
)
elif obj.input.access == "ipaddress":
if not obj.input.has_key("access_ipaddress"):
check = False
checker.add_error(_('"%s" is required.') % _("Permit access from specified IP address"))
else:
obj.input.ip_list = obj.input.access_ipaddress.split()
obj.input.ip_list = get_no_overlap_list(obj.input.ip_list)
if len(obj.input.ip_list) == 0:
check = False
checker.add_error(_('"%s" is required.') % _("IP Address"))
for input_ip in obj.input.ip_list:
check = (
checker.check_ipaddr(_("Permit specified IP address"), input_ip, CHECK_EMPTY | CHECK_VALID)
and check
)
else:
check = False
if not is_param(obj.input, "ssl_status"):
check = False
checker.add_error(_('"%s" is required.') % _("SSL Settings"))
else:
if obj.input.ssl_status == "enable":
check = True and check
elif obj.input.ssl_status == "disable":
check = True and check
else:
check = False
obj.view.alert = checker.errors
return check