MCPcopy Create free account
hub / github.com/qiyeboy/IPProxyPool / getIpAddr

Method getIpAddr

test/testIPAddress.py:89–112  ·  view source on GitHub ↗
(self, ip)

Source from the content-addressed store, hash-verified

87 (self.curEndIp,) = struct.unpack("I", buf)
88
89 def getIpAddr(self, ip):
90 L = 0
91 R = self.indexCount - 1
92 while L < R - 1:
93 M = int((L + R) / 2)
94 self.setIpRange(M)
95 if ip == self.curStartIp:
96 L = M
97 break
98 if ip > self.curStartIp:
99 L = M
100 else:
101 R = M
102 self.setIpRange(L)
103 # version information, 255.255.255.X, urgy but useful
104 if ip & 0xffffff00 == 0xffffff00:
105 self.setIpRange(R)
106 if self.curStartIp <= ip <= self.curEndIp:
107 address = self.getAddr(self.curEndIpOffset)
108 # 把GBK转为utf-8
109 address = str(address)
110 else:
111 address = "未找到该IP的地址"
112 return address
113
114 def getIpRange(self, ip):
115 self.getIpAddr(ip)

Callers 3

getVersionMethod · 0.95
getIpRangeMethod · 0.95
testIPAddress.pyFile · 0.45

Calls 2

setIpRangeMethod · 0.95
getAddrMethod · 0.95

Tested by

no test coverage detected