Commits

Anonymous committed debee7b Draft

Quick and dirty allow remote peers

Useful for embedded devices to run a remote (debug) Python console
across a network. Completely unsafe with no security!

Comments (0)

Files changed (2)

     """Decorator to restrict handler method to local proxies only."""
 
     def _restrict_local(self, *args, **kwargs):
+        """
         if self._addr[0] != '127.0.0.1':
             raise ValueError('Attempt to invoke method from remote address.')
+        """
         return foo(self, *args, **kwargs)
     
     return _restrict_local

rfoo/utils/rconsole.py

 class ProxyConsole(code.InteractiveConsole):
     """Proxy interactive console to remote interpreter."""
 
-    def __init__(self, port=PORT):
+    def __init__(self, host=rfoo.LOOPBACK, port=PORT):
         code.InteractiveConsole.__init__(self)
+        self.host = host
         self.port = port
         self.conn = None
 
     def interact(self, banner=None):
         logging.info('Enter.')
-        self.conn = rfoo.InetConnection().connect(port=self.port)
+        self.conn = rfoo.InetConnection().connect(host=self.host, port=self.port)
         return code.InteractiveConsole.interact(self, banner)
 
     def complete(self, phrase, state):
     thread.start_new_thread(_wrapper, ())
 
 
-def interact(banner=None, readfunc=None, port=PORT):
+def interact(banner=None, readfunc=None, host=rfoo.LOOPBACK, port=PORT):
     """Start console and connect to remote console server."""
 
     logging.info('Enter, port=%d.', port)
 
-    console = ProxyConsole(port)
+    console = ProxyConsole(host=host, port=port)
 
     if readfunc is not None:
         console.raw_input = readfunc