检查通配符域名
wildhost的Python项目详细描述
野生宿主
检查通配符域名。在
安装
pip install wildhost
使用
导入模块
^{pr2}$将主机名传递给check
函数。在
>>>wildhost.check('foo.bar.domain.tld')
如果名称的所有级别都不是通配符,None
将返回。在
>>>wildhost.check('mail.google.com')
这将返回None
,因为google.com
和{
对于通配符名称,将返回lowest级别的通配符名称。在
>>>wildhost.check('foo.bar.spam.grok.sharefile.com')'sharefile.com'
性能
模块缓存通配符结果,并在进一步检查中使用它们。例如:
>>>wildhost.check('foo.bar.spam.grok.sharefile.com')# this will be a fresh check'sharefile.com'>>>wildhost.check('boom.blast.sharefile.com')# this will use the cache'sharefile.com'
一旦sharefile.com
是通配符,sharefile.com
的任何其他子域也将被评估为通配符。这是通过静态检查确定的,因此非常快。在
然而,有一个警告。在不太可能的场景中,api.sharefile.com
将丢失,如果它恰好是一个有效的子域。在
在这种情况下,如果有疑问,请使用wildcard.check_fresh
函数忽略缓存。在
>>>wildcard.check_fresh('api.sharefile.com')
如果实际上不是通配符,则返回None
。在
check_fresh
needs to make network requests, where ascheck
caches the results and is very fast. Choose one that is suitable for the problem at hand.
- 项目
标签: