473,399 Members | 2,278 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Using SRP on TCPServer module

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

Oct 14 '05 #1
1 2323
"dcrespo" <dc*****@gmail.com> writes:
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.


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.
Oct 14 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: huy | last post by:
Hi All, Can someone explain why this bit of code can't keep up with some java code which spawns about 200 (threads) simultaneous connections each sending about 10 mesgs each. I basically don't...
2
by: Tortelini | last post by:
I am making custom web server using HTTPServer and want to be able to access it simultaneously from different computers. To achieve multithreading, I have been experimenting with ThreadingMixIn...
1
by: orit | last post by:
I have the following xml file: <?xml version="1.0" encoding="utf-8" ?> <course id="2555" title="Developing Microsoft .NET Applications for Windows (Visual C# .NET)" length="5 days"...
0
by: Glich via DotNetMonster.com | last post by:
#using <mscorlib.dll> #using <System.dll> #include "stdlib.h" #include "stdio.h" using namespace System; using namespace System::Text; using namespace System::IO; using namespace...
2
by: Alpha | last post by:
Hi, I'm able to make connection to a server using socket connection. However, when I send a command string the server just ignores it. All command string needs to start with "0xF9" at Byte 0. ...
6
by: Ant | last post by:
Hi all, I'm putting together a simple help module for my applications, using html files stored in the application directory somewhere. Basically it sets up a basic web server, and then uses the...
2
by: Eric Spaulding | last post by:
Is there an easy way to pass arguments to a handler class that is used by the standard TCPServer? normally --srvr =SocketServer.TCPServer(('',port_num), TCPHandlerClass) I'd like to be able...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
1
by: =?Utf-8?B?RGFydGgtQ3ot?= | last post by:
Hi, I'm beginner in Visual C++ so I want to ask you a question. And I'm not good in English:D So I have the program which communicates over sockets. The program has to connect to the server and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.