[Twisted-Python] how to only accept local computer requests?
Hi, I have a python server with twisted framework running 24x7. I want to have a config file to setup accepting local computer requests or remote computer requests. If the config file exists, it only accepts local computer request, does not accept requests from other computers. If the config file does not exist, it accepts requests from any computers. Is there any easy way to do it ? Best regards. Michael Li ========== This email message and any attachments are for the sole use of the intended recipients and may contain proprietary and/or confidential information which may be privileged or otherwise protected from disclosure. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipients, please contact the sender by reply email and destroy the original message and any copies of the message as well as any attachments to the original message.
On 5/9/06, Michael Li <mli@deform.com> wrote:
Hi,
I have a python server with twisted framework running 24x7. I want to have a config file to setup accepting local computer requests or remote computer requests. If the config file exists, it only accepts local computer request, does not accept requests from other computers. If the config file does not exist, it accepts requests from any computers. Is there any easy way to do it ?
It's not totally clear from what info you've given, but it sounds like you want to pass the 'interface' argument to TCPServer or listenTCP, whichever you're using. interface='127.0.0.1' to only serve connections from localhost, interface='' to serve connections from anybody. -- Christopher Armstrong International Man of Twistery http://radix.twistedmatrix.com/ http://twistedmatrix.com/ http://canonical.com/
I have a python server with twisted framework running 24x7. I want to have a config file to setup accepting local computer requests or remote computer requests.
When you create instances of twisted.internet.application.TCPServer or .SSLServer, pass the keyword parameter interface = '127.0.0.1' and the server socket will only bind to the localhost interface. If you don't pass the parameter, the socket will bind to all interfaces. -- Nicola Larosa - http://www.tekNico.net/ In high school she already wanted to be a doctor. And she is so ambitious and determined that she overcame every obstacle along the way -- including, unfortunately, not liking it. Now she has a life chosen for her by a high-school kid. -- Paul Graham, January 2006
participants (3)
-
Christopher Armstrong
-
Michael Li
-
Nicola Larosa