provides a Web Proxy to use with Enigma2. At the moment only standard HTTP is support...
authorRico Schulte <ricoschulte@users.schwerkraft.elitedvb.net>
Thu, 3 Jan 2008 20:03:49 +0000 (20:03 +0000)
committerRico Schulte <ricoschulte@users.schwerkraft.elitedvb.net>
Thu, 3 Jan 2008 20:03:49 +0000 (20:03 +0000)
Makefile.am
configure.ac
httpproxy/CONTROL/control [new file with mode: 0644]
httpproxy/Makefile.am [new file with mode: 0644]
httpproxy/src/Makefile.am [new file with mode: 0644]
httpproxy/src/__init__.py [new file with mode: 0644]
httpproxy/src/plugin.py [new file with mode: 0644]

index 8944899..a206304 100644 (file)
@@ -1,2 +1,2 @@
 AUTOMAKE_OPTIONS = gnu
-SUBDIRS = antiscrollbar movietagger webinterface wirelesslan netcaster lastfm logomanager vlcplayer simplerss trafficinfo fritzcall webcamviewer emailclient autotimer epgrefresh werbezapper
+SUBDIRS = antiscrollbar movietagger webinterface wirelesslan netcaster lastfm logomanager vlcplayer simplerss trafficinfo fritzcall webcamviewer emailclient autotimer epgrefresh werbezapper httpproxy
index 87444db..b2c9daf 100644 (file)
@@ -77,4 +77,8 @@ epgrefresh/src/Makefile
 
 werbezapper/Makefile
 werbezapper/src/Makefile
+
+httpproxy/Makefile
+httpproxy/src/Makefile
+
 ])
diff --git a/httpproxy/CONTROL/control b/httpproxy/CONTROL/control
new file mode 100644 (file)
index 0000000..4ab3fba
--- /dev/null
@@ -0,0 +1,11 @@
+Package: enigma2-plugin-extensions-trafficinfo
+Version: 1.0
+Description: view german trafficjam informations 
+Architecture: mipsel
+Section: extra
+Priority: optional
+Maintainer: 3c5x9 <3c5x9@gmx.net>
+Homepage: n/a
+Depends: enigma2(>1.0cvs20070908)
+Rdepends: twisted-web 
+Source: http://enigma2-plugins.schwerkraft.elitedvb.net/
diff --git a/httpproxy/Makefile.am b/httpproxy/Makefile.am
new file mode 100644 (file)
index 0000000..af437a6
--- /dev/null
@@ -0,0 +1 @@
+SUBDIRS = src
diff --git a/httpproxy/src/Makefile.am b/httpproxy/src/Makefile.am
new file mode 100644 (file)
index 0000000..4b66484
--- /dev/null
@@ -0,0 +1,3 @@
+installdir = /usr/lib/enigma2/python/Plugins/Extensions/TrafficInfo
+
+install_PYTHON = __init__.py plugin.py
diff --git a/httpproxy/src/__init__.py b/httpproxy/src/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/httpproxy/src/plugin.py b/httpproxy/src/plugin.py
new file mode 100644 (file)
index 0000000..ad9c923
--- /dev/null
@@ -0,0 +1,92 @@
+# by 3c5x9@2008
+from enigma import eTimer
+
+from Screens.Screen import Screen
+
+from Components.config import config, getConfigListEntry
+from Components.ConfigList import ConfigListScreen
+from Components.Label import Label
+from Components.ActionMap import ActionMap
+from Components.config import config, ConfigSubsection, ConfigInteger,ConfigYesNo
+from Components.Network import Network
+from Plugins.Plugin import PluginDescriptor
+
+from twisted.web import proxy, http
+from twisted.internet import reactor
+
+
+###############################################################################
+config.plugins.httpproxy = ConfigSubsection()
+config.plugins.httpproxy.enable = ConfigYesNo(default = True)
+config.plugins.httpproxy.port = ConfigInteger(8080,limits = (1, 65536))
+
+###############################################################################
+class HTTPProxyConfigScreen(ConfigListScreen,Screen):
+    skin = """
+        <screen position="100,100" size="550,400" title="HTTP Proxy Setup" >
+        <widget name="config" position="0,0" size="550,360" scrollbarMode="showOnDemand" />
+        <widget name="buttonred" position="10,360" size="100,40" backgroundColor="red" valign="center" halign="center" zPosition="2"  foregroundColor="white" font="Regular;18"/>
+        <widget name="buttongreen" position="120,360" size="100,40" backgroundColor="green" valign="center" halign="center" zPosition="2"  foregroundColor="white" font="Regular;18"/>
+        </screen>"""
+
+    def __init__(self, session, args = 0):
+        self.session = session
+        Screen.__init__(self, session)
+        self.list = []
+        self.list.append(getConfigListEntry(_("start HTTP Proxy"), config.plugins.httpproxy.enable))
+        self.list.append(getConfigListEntry(_("use Port"), config.plugins.httpproxy.port))
+
+        ConfigListScreen.__init__(self, self.list)
+        self["buttonred"] = Label(_("cancel"))
+        self["buttongreen"] = Label(_("ok"))
+        self["setupActions"] = ActionMap(["SetupActions"],
+        {
+            "green": self.save,
+            "red": self.cancel,
+            "save": self.save,
+            "cancel": self.cancel,
+            "ok": self.save,
+        }, -2)
+
+    def save(self):
+        print "saving"
+        for x in self["config"].list:
+            x[1].save()
+        self.close(True,self.session)
+
+    def cancel(self):
+        print "cancel"
+        for x in self["config"].list:
+            x[1].cancel()
+        self.close(False,self.session)
+
+###############################################################################
+class ProxyFactory(http.HTTPFactory):
+        protocol = proxy.Proxy
+
+###############################################################################
+def main(session, **kwargs):
+    """ open config screen """
+    session.open(HTTPProxyConfigScreen)
+
+def autostart(**kwargs):
+    """ start proxy in background """
+    if config.plugins.httpproxy.enable.value:
+        try:
+            nw = Network()
+            for adaptername in nw.ifaces:
+                extip = nw.ifaces[adaptername]['ip']
+                if nw.ifaces[adaptername]['up'] is True:
+                    extip = "%i.%i.%i.%i"%(extip[0],extip[1],extip[2],extip[3])
+                    print "starting proxy on ",extip,":", config.plugins.httpproxy.port.value
+                    reactor.listenTCP(int(config.plugins.httpproxy.port.value), ProxyFactory(),interface=extip)
+        except Exception,e:
+            print "starting the http proxy failed!"
+            print e
+
+def Plugins(**kwargs):
+  return [
+          PluginDescriptor(name="HTTP Proxy",description="use your Dreambox as Web Proxy",where = PluginDescriptor.WHERE_PLUGINMENU,fnc = main),
+          PluginDescriptor(where = [PluginDescriptor.WHERE_SESSIONSTART, PluginDescriptor.WHERE_AUTOSTART], fnc = autostart)
+          ]
+