def _verify(self, conn, address):
import string
challenge = self._generate_challenge()
conn.send("%d\n" % challenge)
response = ""
while "\n" not in response and len(response) < 100:
data = conn.recv(100)
if not data:
break
response = response + data
try:
response = string.atol(string.strip(response))
except string.atol_error:
if self._verbose > 0:
print "Invalid response syntax", repr(response)
return 0
if not self._compare_challenge_response(challenge, response):
if self._verbose > 0:
print "Invalid response value", repr(response)
return 0
if self._verbose > 1:
print "Response matches challenge. Go ahead!"
return 1
评论列表
文章目录