本文整理汇总了Python中util.Util.verify_name方法的典型用法代码示例。如果您正苦于以下问题:Python Util.verify_name方法的具体用法?Python Util.verify_name怎么用?Python Util.verify_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util.Util
的用法示例。
在下文中一共展示了Util.verify_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import verify_name [as 别名]
def __init__(self, name, ip, iface, hostname="", loginfo=""):
"""
Create a new host object, with the given name, IP specification and interface
name -- Nickname for the host
ip -- IP specification for the host or subnet (e.g. "127.0.0.1 10.0.0.0/24")
iface -- Interface nickname this is connected to (only one!)
"""
# verify and store name
if name == "" and not Util.verify_name(name):
raise PyromanException("Host '%s' lacking a valid name at %s" \
% (name, iface, loginfo))
if Firewall.hosts.has_key(name):
raise PyromanException("Duplicate host specification: '%s' at %s" % (name, loginfo))
self.name = name
# verify and store IPs
if ip == "":
raise PyromanException("Host '%s' definition lacking IP address at %s" % (name, loginfo))
self.ip = Util.splitter.split(ip)
for i in self.ip:
if not Util.verify_ipnet(i):
raise PyromanException("IP specification '%s' invalid for host '%s' at %s" \
% (i, name, loginfo))
# verify and store interface
self.iface = iface
if iface == "":
raise PyromanException("Host definition '%s' lacking kernel interfaces at %s" \
% (name, loginfo))
# store "real" hostname (which may be longer than nick)
# this is used for "localhost detection"
self.hostname = hostname
# store loginfo
self.loginfo = loginfo
# register with firewall
Firewall.hosts[name] = self
示例2: __init__
# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import verify_name [as 别名]
def __init__(self, name, sports="", dports="", include="", loginfo=""):
"""
Create new service object with string parameters
sports -- source port specifications like "www/tcp dns/udp"
dports -- destination port specifications
include -- include rules for other services to be included/aliased
loginfo -- reference line number for user error messages
"""
if name == "" or not Util.verify_name(name, servicename=True):
raise PyromanException("service lacking a proper name: '%s' at %s" \
% (name, loginfo))
if Firewall.services.has_key(name):
raise PyromanException("Duplicate service specification: '%s' at %s" % (name, loginfo))
if sports == "" and dports == "" and include == "" and (name != "ANY"):
raise PyromanException("service specification invalid: '%s' at %s" % (name, loginfo))
self.name = name
self.loginfo = loginfo
try:
self.sports = map( lambda p: Port(p), Util.splitter.split(sports) )
self.dports = map( lambda p: Port(p), Util.splitter.split(dports) )
except PortInvalidSpec, p:
raise PyromanException("Service '%s' contains invalid port spec '%s' at %s: %s" \
% (name, p.spec, loginfo, p.err))
示例3: __init__
# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import verify_name [as 别名]
def __init__(self, name, iface, loginfo):
"""
Create a new interface
name -- name for this interface (-group)
iface -- kernel interface names, e.g. "eth0 eth1"
"""
if name == "" or not Util.verify_name(name):
raise PyromanException("Interface lacking a valid name (name: %s, iface: %s) at %s" \
% (name, iface, loginfo))
if Firewall.interfaces.has_key(name):
raise PyromanException("Duplicate interface specification: %s at %s" % (name, loginfo))
if iface == "":
raise PyromanException("Interface definition lacking kernel interfaces: %s at %s" \
% (name, loginfo))
self.name = name
self.iface = Util.splitter.split(iface)
self.loginfo = loginfo
# register with firewall
Firewall.interfaces[name] = self