[Twisted-Python] Web Proxy that does something different once a day
Hello, I am new to python and I am potentially interested in writing a new protocol with Twisted. However I wanted to start with a simpler problem that I have been working on, so that I can understand better how twisted works. A particular client wants to enforce a home page for the first internet connection each day. They have a intranet portal that gives messages to employees and they want to be sure that each employee, no matter how they have their homepage set, will see the messages the first time they connect. After the first connection they want the proxy to simply forward requests to the internet without filtering. Since I need to understand this issue for my other project too, how do I get the python loop do one thing based on a "new day" for an IP address and then do something else after that action has been completed. Example code that addresses my problem would be great, but I would be happy to have links to examples that do this... Thanks!! -- Fred Trotter http://www.fredtrotter.com
I'm not sure if this is the level you need an answer on, but I would put a dictionary in the proxy keyed by IP address and with a value of the last time that user was forced to the intranet site. Check that against the current time and a 16 hour offset and send a redirect message if it's out of date. Hoping someone else chimes in with how to stick a redirect into a proxy, glancing at the code I'm not sure how to tell you to do that, though it's clearly possible. Andy Fundinger On 9/18/07, Fred Trotter <fred.trotter@gmail.com> wrote:
Hello, I am new to python and I am potentially interested in writing a new protocol with Twisted. However I wanted to start with a simpler problem that I have been working on, so that I can understand better how twisted works.
A particular client wants to enforce a home page for the first internet connection each day. They have a intranet portal that gives messages to employees and they want to be sure that each employee, no matter how they have their homepage set, will see the messages the first time they connect. After the first connection they want the proxy to simply forward requests to the internet without filtering.
Since I need to understand this issue for my other project too, how do I get the python loop do one thing based on a "new day" for an IP address and then do something else after that action has been completed. Example code that addresses my problem would be great, but I would be happy to have links to examples that do this...
Thanks!!
-- Fred Trotter http://www.fredtrotter.com
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
-- Blog: http://channel3b.wordpress.com Second Life Name: Ciemaar Flintoff I am a sig Virus. Please put me in your sig so that I can continue to replicate.
Fred Trotter wrote:
Hello, I am new to python and I am potentially interested in writing a new protocol with Twisted. However I wanted to start with a simpler problem that I have been working on, so that I can understand better how twisted works.
A particular client wants to enforce a home page for the first internet connection each day. They have a intranet portal that gives messages to employees and they want to be sure that each employee, no matter how they have their homepage set, will see the messages the first time they connect. After the first connection they want the proxy to simply forward requests to the internet without filtering.
Since I need to understand this issue for my other project too, how do I get the python loop do one thing based on a "new day" for an IP address and then do something else after that action has been completed. Example code that addresses my problem would be great, but I would be happy to have links to examples that do this...
Fred, To effectively achieve what you've outlined is really quite involved, and the answer to your question is heavily tied to the implementation. You will be controlling access by clients to the internet. You will make that decision based essentially three factors: - Client IP Address making access request. - When the client IP address last accessed what version of the Required Reading. - What is the current version of the Required Reading / when did it renew. In order to provide some example code, the frame work of the implementation needs to be known. Cheers, Matt.
Matt thanks for replying. Obviously I am interested in using Python and Twisted for this. But otherwise I have no implementation requirements. As for your summary of what I wanted... * Yes, we would have to track per IP address. * Yes, we would have to track when an IP last accessed the required reading.. * No we do not need to worry about what "version" they read of the required reading. So the required reading is just a website whose content can change without worrying about this application. * We want them to go the "homepage" for more than just required reading. These are low level information workers who need the links on the home page to do their jobs, but might still set their personal homepage to yahoo. Since they tend to waste time at yahoo, but tend to work at the websites linked from my "required reading" forcing them to go there to start the day is a gentle reminder that they need to work. So the point of the process is not to enforce the required reading, but to enforce a "start-the-work-day homepage" for the computers on the network. Which means the problem is only about half as complex!! -FT
Fred,
To effectively achieve what you've outlined is really quite involved, and the answer to your question is heavily tied to the implementation.
You will be controlling access by clients to the internet. You will make that decision based essentially three factors: - Client IP Address making access request. - When the client IP address last accessed what version of the Required Reading. - What is the current version of the Required Reading / when did it renew.
In order to provide some example code, the frame work of the implementation needs to be known.
Cheers, Matt.
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
-- Fred Trotter http://www.fredtrotter.com
participants (3)
-
Andy Fundinger
-
Fred Trotter
-
Matt Hubbard