本文整理匯總了Python中arch.LOOPBACK_NAME屬性的典型用法代碼示例。如果您正苦於以下問題:Python arch.LOOPBACK_NAME屬性的具體用法?Python arch.LOOPBACK_NAME怎麽用?Python arch.LOOPBACK_NAME使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類arch
的用法示例。
在下文中一共展示了arch.LOOPBACK_NAME屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: route
# 需要導入模塊: import arch [as 別名]
# 或者: from arch import LOOPBACK_NAME [as 別名]
def route(self,dest,verbose=None):
if type(dest) is list and dest:
dest = dest[0]
if dest in self.cache:
return self.cache[dest]
if verbose is None:
verbose=conf.verb
# Transform "192.168.*.1-5" to one IP of the set
dst = dest.split("/")[0]
dst = dst.replace("*","0")
while 1:
l = dst.find("-")
if l < 0:
break
m = (dst[l:]+".").find(".")
dst = dst[:l]+dst[l+m:]
dst = atol(dst)
pathes=[]
for d,m,gw,i,a in self.routes:
aa = atol(a)
if aa == dst:
pathes.append((0xffffffffL,(LOOPBACK_NAME,a,"0.0.0.0")))
if (dst & m) == (d & m):
pathes.append((m,(i,a,gw)))
if not pathes:
if verbose:
warning("No route found (no default route?)")
return LOOPBACK_NAME,"0.0.0.0","0.0.0.0" #XXX linux specific!
# Choose the more specific route (greatest netmask).
# XXX: we don't care about metrics
pathes.sort()
ret = pathes[-1][1]
self.cache[dest] = ret
return ret