sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
dcrespo's Avatar

Using SRP on TCPServer module


Question posted by: dcrespo (Guest) on October 14th, 2005 05:15 PM
Hi all,

Below, you can see a class that when it receives a host connection, it
gets validated. Then, if the validation returns True, then process the
request. Also, if I want to stop the server, I simply access the
self.QuitFlag in lock mode, and set it to 1.

Now that you know what I have, I would like to add SRP functionality to
the validation of each new connection.
What I need to add to my code to get SRP to work? I don't know where to
start. The docs are poor.

Thanks

Daniel

------------------------------------------------------

class TCPServer(SocketServer.ThreadingTCPServer):

def __init__(self,socket,lock):
self.socket = socket
SocketServer.ThreadingTCPServer.__init__(self,
socket,SocketServer.StreamRequestHandler)
SocketServer.ThreadingTCPServer.allow_reuse_addres s = True
self.timeout = 0.1
self.lock = lock
self.lock.acquire()
self.QuitFlag = 0
self.lock.release()

def get_request(self):
socklist = [self.socket]
while 1:
# Select with a timeout, then poll a quit flag. An
alternate
# approach would be to let the master thread "wake us up"
# with a socket connection.
ready = select.select(socklist, [], [], self.timeout)
self.lock.acquire()
time_to_quit = self.QuitFlag
self.lock.release()
if time_to_quit:
raise TimeToQuit # Get out now
if ready[0]: # A socket was ready to read
return
SocketServer.ThreadingTCPServer.get_request(self)
else: # We timed out, no connection yet
pass # Just go back to the select()

#Process the request
def process_request_thread(self,request,client_address ):
"""
This function gets triggered when the connection is accepted
"""
pass

#Verify the request
def verify_request(self,request,client_address):
"""
This function triggers when some host wants to connect
"""
if DoValidationOf(client_address):
return True
else:
return False

1 Answer Posted
Paul Rubin's Avatar
Guest - n/a Posts
#2: Re: Using SRP on TCPServer module

"dcrespo" <dcrespo@gmail.com> writes:[color=blue]
> Now that you know what I have, I would like to add SRP functionality to
> the validation of each new connection.
> What I need to add to my code to get SRP to work? I don't know where to
> start. The docs are poor.[/color]

I don't know of a Python SRP module that only does SRP. I've been
thinking of writing one.

TLSLite (http://trevp.net/tlslite) implements SRP as an extension to
TLS. Maybe it's what you should be using instead of just sending
cleartext through TCPServer. Connecting up TLSLite to TCPServer is
pretty straightforward and I think there's an example in the TLSLite docs.
 
Not the answer you were looking for? Post your question . . .
196,790 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 196,790 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Community Contributors