def render(self, request): request.received_headers['uri']=self.uri request.setHeader("pragma", "no-cache") try: request.content.seek(0,0) except: log.debug("VLC MEDIA PROXY FD CLOSED (YET)") prods=producers.MediaProducers() prod = prods.get(self.uri) sn = sha1() sn.update(self.uri) streamname = sn.hexdigest() streamuri = self.uri if streamuri.startswith("http://") or streamuri.startswith("https://") and not self.direct: streamuri="http://127.0.0.1:"+str(self.core.configGet('web','port'))+"/mediaproxy/raw/?uri="+str(urllib.quote(self.uri)) if not prod: log.info("Create new vlc producer for uri "+str(self.uri)) p=producers.VLCTelnet() vlct = p.getClient() if not vlct: return permissionDenied() vlct.newBroadcast(streamname, streamuri) prod = self.proxyClientFactoryClass(self.uri, streamname) prods.add(self.uri, prod) prod.buildProtocol(request, self.vcodec) request.notifyFinish().addErrback(self._responseFailed, request, prod) return NOT_DONE_YET
def child_(self, ctx): if int(self.core.configGet('media', 'localtranscode')) > 0: request = inevow.IRequest(ctx) if 'uri' in request.args: uri = urllib.unquote(request.args['uri'][0]) return VLCProxyResource(uri, self.vtype, self.core, reqargs) return permissionDenied()
def child_(self, ctx): request = inevow.IRequest(ctx) log.debug("COPY") if 'uri' in request.args: uri = urllib.unquote(request.args['uri'][0]) return GenericProxyResource(uri, request.method) return permissionDenied()
def child_(self, ctx): request = inevow.IRequest(ctx) log.debug("COPY") if 'uri' in request.args: uri = urllib.unquote(request.args['uri'][0]) if uri.startswith('http://') or uri.startswith('https://'): return RAWHTTPProxyResource(uri) else: log.debug("RAW NON HTTP REQUESTED") if str(self.core.configGet('media','transcode_raw')) in ['vlc','VLC']: return VLCProxyResource(uri, 'h264', self.core) return FFMpegProxyResource(uri, 'mpegts', self.core) return permissionDenied()
def childFactory(self, ctx, name): #log.info("childFactory "+str(name)) request = inevow.IRequest(ctx) #log.info("childFactory2 "+str(request)) if name in self.core.configGet('proxy', 'localproxypaths').split(','): self._sendProxySession(request, ctx) return proxy.WebProxyResource('localhost', 80, path='/'+name) host=request.getHeader('host') log.debug("HOST CALLED: "+str(host)) if host and host in self.core.configGet('proxy', 'localproxyhosts').split(','): self._sendProxySession(request, ctx) return proxy.WebProxyResource('localhost', 80, path='/'+name) log.debug("No child found (%s)" % name) return permissionDenied()
def addPerms(dbres, ctx, name, session, request): try: log.info(dbres) if dbres and len(dbres)>0: session.dmpermissions[request.path]=dbres[0][0] if neededPermission(request.method) in session.dmpermissions[request.path]: log.info("PERMISSION DB OK, USER: "******" SESSION: "+str(session.uid)) #+" ARGS: "+str(request.args)+" REQ "+str(request)) self.core.updateSession(session.uid, session, self) return rend.Page.locateChild(self, ctx, name) except: try: log.info("Error getting permission from DB USER: "******" SESSION: "+str(session.uid)+" ARGS: "+str(request.args)+" REQ "+str(request)) except: log.info("Error getting permission from DB USER: GUEST SESSION: "+str(session.uid)+" ARGS: "+str(request.args)+" REQ "+str(request)) try: log.info("PERMISSION DB DENIED, USER: "******" SESSION: "+str(session.uid)+" ARGS: "+str(request.args)+" REQ "+str(request)) except: log.info("PERMISSION DB DENIED, USER: GUEST SESSION: "+str(session.uid)+" ARGS: "+str(request.args)+" REQ "+str(request)) return permissionDenied(), ()
def locateChild(self, ctx, name): session = inevow.ISession(ctx) request = inevow.IRequest(ctx) try: uname = session.mind.perms.username except: uname = 'guest' if not 'sse' in dir(session): session.sse = False if not 'dmpermissions' in dir(session): session.dmpermissions={} if request.path in WEB_SYSTEM_PATHS: log.info("WEB_SYSTEM_PATH: USER: "******" SESSION: "+str(session.uid)) #+" ARGS: "+str(request.args)+" REQ "+str(request)) return rend.Page.locateChild(self, ctx, name) if request.path in session.dmpermissions.keys(): if neededPermission(request.method) in session.dmpermissions[request.path]: log.debug("PERMISSION OK, SESSION: "+str(session.uid)) #+" ARGS: "+str(request.args)+" REQ "+str(request)) self.core.updateSession(session.uid, session, self) return rend.Page.locateChild(self, ctx, name) else: return self._addPermissions(ctx, name, session, request) log.debug("PERMISSION DENIED, SESSION: "+str(session.uid)+" ARGS: "+str(request.args)+" REQ "+str(request)) #return rend.Page.locateChild(self, ctx, name) return permissionDenied(), ()
def childFactory(self, ctx, name): return permissionDenied()
def child_(self, ctx): return permissionDenied()
def childFactory(self, ctx, name): log.debug("No child found (%s)" % name) return permissionDenied()