Exemplo n.º 1
0
def startWebserver(session):
    global running_defered
    global toplevel

    session.mediaplayer = None
    session.messageboxanswer = None
    if toplevel is None:
        toplevel = getToplevel(session)

    errors = ""

    if config.plugins.Webinterface.enabled.value is not True:
        print "[Webinterface] is disabled!"

    else:
        # IF SSL is enabled we need to check for the certs first
        # If they're not there we'll exit via return here
        # and get called after Certificates are installed properly
        if config.plugins.Webinterface.https.enabled.value:
            if not checkCertificates():
                print "[Webinterface] Installing Webserver Certificates for SSL encryption"
                installCertificates(session, startWebserver)
                return

        for adaptername in iNetwork.ifaces:
            ip = '.'.join("%d" % d for d in iNetwork.ifaces[adaptername]['ip'])

            #Only if it's up and has a "good" IP
            if ip != '0.0.0.0' and iNetwork.ifaces[adaptername]['up'] == True:
                #HTTP
                if config.plugins.Webinterface.http.enabled.value is True:
                    ret = startServerInstance(
                        session, ip,
                        config.plugins.Webinterface.http.port.value,
                        config.plugins.Webinterface.http.auth.value)
                    if ret == False:
                        errors = "%s%s:%i\n" % (errors, ip, config.plugins.
                                                Webinterface.http.port.value)
            #HTTPS
                if config.plugins.Webinterface.https.enabled.value is True:
                    ret = startServerInstance(
                        session, ip,
                        config.plugins.Webinterface.https.port.value,
                        config.plugins.Webinterface.https.auth.value, True)
                    if ret == False:
                        errors = "%s%s:%i\n" % (errors, ip, config.plugins.
                                                Webinterface.https.port.value)

    #LOCAL HTTP Connections (Streamproxy)
        ret = startServerInstance(session, '127.0.0.1', 80,
                                  config.plugins.Webinterface.streamauth.value)
        if ret == False:
            errors = "%s%s:%i\n" % (errors, '127.0.0.1', 80)

        if errors != "":
            session.open(MessageBox,
                         "Webinterface - Couldn't listen on:\n %s" % (errors),
                         type=MessageBox.TYPE_ERROR,
                         timeout=30)
Exemplo n.º 2
0
def startWebserver(session, l2k):
    global running_defered
    global toplevel

    session.mediaplayer = None
    session.messageboxanswer = None
    if toplevel is None:
        toplevel = getToplevel(session)

    errors = ""

    if config.plugins.Webinterface.enabled.value is not True:
        print "[Webinterface] is disabled!"

    else:
        # IF SSL is enabled we need to check for the certs first
        # If they're not there we'll exit via return here
        # and get called after Certificates are installed properly
        if config.plugins.Webinterface.https.enabled.value:
            installCertificates(session)

        # Listen on all Interfaces
        ip = "0.0.0.0"
        #HTTP
        if config.plugins.Webinterface.http.enabled.value is True:
            ret = startServerInstance(
                session, ip, config.plugins.Webinterface.http.port.value,
                config.plugins.Webinterface.http.auth.value, l2k)
            if ret == False:
                errors = "%s%s:%i\n" % (
                    errors, ip, config.plugins.Webinterface.http.port.value)
            else:
                registerBonjourService(
                    'http', config.plugins.Webinterface.http.port.value)

        #Streaming requires listening on 127.0.0.1:80 no matter what, ensure it its available
        #if config.plugins.Webinterface.http.port.value != 80 or not config.plugins.Webinterface.http.enabled.value:
        #	#LOCAL HTTP Connections (Streamproxy)
        #	ret = startServerInstance(session, '127.0.0.1', 80, config.plugins.Webinterface.http.auth.value, l2k)
        #	if ret == False:
        #		errors = "%s%s:%i\n" %(errors, '127.0.0.1', 80)
        #
        #	if errors != "":
        #		session.open(MessageBox, "Webinterface - Couldn't listen on:\n %s" % (errors), type=MessageBox.TYPE_ERROR, timeout=30)

        #HTTPS
        if config.plugins.Webinterface.https.enabled.value is True:
            ret = startServerInstance(
                session, ip, config.plugins.Webinterface.https.port.value,
                config.plugins.Webinterface.https.auth.value, l2k, True)
            if ret == False:
                errors = "%s%s:%i\n" % (
                    errors, ip, config.plugins.Webinterface.https.port.value)
            else:
                registerBonjourService(
                    'https', config.plugins.Webinterface.https.port.value)
Exemplo n.º 3
0
def startWebserver(session, l2k):
	global running_defered
	global toplevel
	
	session.mediaplayer = None
	session.messageboxanswer = None
	if toplevel is None:
		toplevel = getToplevel(session)
	
	errors = ""
	
	if config.plugins.Webinterface.enabled.value is not True:
		print "[Webinterface] is disabled!"
	
	else:
		# IF SSL is enabled we need to check for the certs first
		# If they're not there we'll exit via return here 
		# and get called after Certificates are installed properly
		if config.plugins.Webinterface.https.enabled.value:
			if not checkCertificates():
				print "[Webinterface] Installing Webserver Certificates for SSL encryption"
				installCertificates(session, startWebserver, l2k)
				return
		# Listen on all Interfaces
		ip = "0.0.0.0"
		#HTTP
		if config.plugins.Webinterface.http.enabled.value is True:
			ret = startServerInstance(session, ip, config.plugins.Webinterface.http.port.value, config.plugins.Webinterface.http.auth.value, l2k)
			if ret == False:
				errors = "%s%s:%i\n" %(errors, ip, config.plugins.Webinterface.http.port.value)
			else:
				registerBonjourService('http', config.plugins.Webinterface.http.port.value)
			
		#Streaming requires listening on 127.0.0.1:80 no matter what, ensure it its available
		if config.plugins.Webinterface.http.port.value != 80 or not config.plugins.Webinterface.http.enabled.value:
			#LOCAL HTTP Connections (Streamproxy)
			ret = startServerInstance(session, '127.0.0.1', 80, config.plugins.Webinterface.http.auth.value, l2k)			
			if ret == False:
				errors = "%s%s:%i\n" %(errors, '127.0.0.1', 80)
			
			if errors != "":
				session.open(MessageBox, "Webinterface - Couldn't listen on:\n %s" % (errors), type=MessageBox.TYPE_ERROR, timeout=30)
				
		#HTTPS		
		if config.plugins.Webinterface.https.enabled.value is True:					
			ret = startServerInstance(session, ip, config.plugins.Webinterface.https.port.value, config.plugins.Webinterface.https.auth.value, l2k, True)
			if ret == False:
				errors = "%s%s:%i\n" %(errors, ip, config.plugins.Webinterface.https.port.value)
			else:
				registerBonjourService('https', config.plugins.Webinterface.https.port.value)
Exemplo n.º 4
0
def startWebserver(session):
	global running_defered
	global toplevel
	
	session.mediaplayer = None
	session.messageboxanswer = None
	if toplevel is None:
		toplevel = getToplevel(session)
	
	errors = ""
	
	if config.plugins.Webinterface.enabled.value is not True:
		print "[Webinterface] is disabled!"
	
	else:
		# IF SSL is enabled we need to check for the certs first
		# If they're not there we'll exit via return here 
		# and get called after Certificates are installed properly
		if config.plugins.Webinterface.https.enabled.value:
			if not checkCertificates():
				print "[Webinterface] Installing Webserver Certificates for SSL encryption"
				installCertificates(session, startWebserver)
				return
				
		for adaptername in iNetwork.ifaces:				
			ip = '.'.join("%d" % d for d in iNetwork.ifaces[adaptername]['ip'])
						
			#Only if it's up and has a "good" IP
			if ip != '0.0.0.0' and iNetwork.ifaces[adaptername]['up'] == True:
			#HTTP
				if config.plugins.Webinterface.http.enabled.value is True:
					ret = startServerInstance(session, ip, config.plugins.Webinterface.http.port.value, config.plugins.Webinterface.http.auth.value)
					if ret == False:
						errors = "%s%s:%i\n" %(errors, ip, config.plugins.Webinterface.http.port.value)
			#HTTPS		
				if config.plugins.Webinterface.https.enabled.value is True:					
					ret = startServerInstance(session, ip, config.plugins.Webinterface.https.port.value, config.plugins.Webinterface.https.auth.value, True)
					if ret == False:
						errors = "%s%s:%i\n" %(errors, ip, config.plugins.Webinterface.https.port.value)
	
	#LOCAL HTTP Connections (Streamproxy)
		ret = startServerInstance(session, '127.0.0.1', 80, config.plugins.Webinterface.streamauth.value)			
		if ret == False:
			errors = "%s%s:%i\n" %(errors, '127.0.0.1', 80)
		
		if errors != "":
			session.open(MessageBox, "Webinterface - Couldn't listen on:\n %s" % (errors), type=MessageBox.TYPE_ERROR, timeout=30)
Exemplo n.º 5
0
def startServerInstance(session, ipaddress, port, useauth=False, usessl=False):
	try:
		toplevel = getToplevel(session)
		if useauth:
# HTTPAuthResource handles the authentication for every Resource you want it to			
			root = HTTPAuthResource(toplevel, "Enigma2 WebInterface")
			site = server.Site(root)			
		else:
			site = server.Site(toplevel)
	
		if usessl:
			ctx = ssl.DefaultOpenSSLContextFactory('/etc/enigma2/server.pem', '/etc/enigma2/cacert.pem', sslmethod=SSL.SSLv23_METHOD)
			d = reactor.listenSSL(port, site, ctx, interface=ipaddress)
		else:
			d = reactor.listenTCP(port, site, interface=ipaddress)
		running_defered.append(d)
		print "[Webinterface] started on %s:%i" % (ipaddress, port), "auth=", useauth, "ssl=", usessl
	
	except Exception, e:
		print "[Webinterface] starting FAILED on %s:%i!" % (ipaddress, port), e
		session.open(MessageBox, 'starting FAILED on %s:%i!\n\n%s' % (ipaddress, port, str(e)), MessageBox.TYPE_ERROR)
Exemplo n.º 6
0
def startWebserver(session, l2k):
    global running_defered
    global toplevel

    session.mediaplayer = None
    session.messageboxanswer = None
    if toplevel is None:
        toplevel = getToplevel(session)

    errors = ""

    if config.plugins.Webinterface.enabled.value is not True:
        print "[Webinterface] is disabled!"

    else:
        # IF SSL is enabled we need to check for the certs first
        # If they're not there we'll exit via return here
        # and get called after Certificates are installed properly
        if config.plugins.Webinterface.https.enabled.value:
            installCertificates(session)

        # Listen on all Interfaces

        #HTTP
        port = config.plugins.Webinterface.http.port.value
        auth = config.plugins.Webinterface.http.auth.value
        if config.plugins.Webinterface.http.enabled.value is True:
            ret = startServerInstance(session, port, useauth=auth, l2k=l2k)
            if not ret:
                errors = "%s port %i\n" % (errors, port)
            else:
                registerBonjourService('http', port)

        #Streaming requires listening on localhost:80 no matter what, ensure it its available
        if config.plugins.Webinterface.http.port.value != 80 or not config.plugins.Webinterface.http.enabled.value:
            #LOCAL HTTP Connections (Streamproxy)
            local4 = "127.0.0.1"
            local4mapped = "::ffff:127.0.0.1"
            local6 = "::1"

            ret = startServerInstance(session,
                                      80,
                                      useauth=auth,
                                      l2k=l2k,
                                      ipaddress=local4)
            if not ret:
                errors = "%s%s:%i\n" % (errors, local4, 80)
            ret = startServerInstance(session,
                                      80,
                                      useauth=auth,
                                      l2k=l2k,
                                      ipaddress=local4mapped,
                                      ipaddress2=local6)
            #ip6 is optional
#			if not ret:
#				errors = "%s%s/%s:%i\n" %(errors, local4mapped, local6, 80)

#HTTPS
        if config.plugins.Webinterface.https.enabled.value is True:
            sport = config.plugins.Webinterface.https.port.value
            sauth = config.plugins.Webinterface.https.auth.value

            ret = startServerInstance(session,
                                      sport,
                                      useauth=sauth,
                                      l2k=l2k,
                                      usessl=True)
            if not ret:
                errors = "%s%s:%i\n" % (errors, "0.0.0.0 / ::", sport)
            else:
                registerBonjourService('https', sport)

        if errors:
            session.open(MessageBox,
                         "Webinterface - Couldn't listen on:\n %s" % (errors),
                         type=MessageBox.TYPE_ERROR,
                         timeout=30)
Exemplo n.º 7
0
def startWebserver(session, l2k):
	global running_defered
	global toplevel

	session.mediaplayer = None
	session.messageboxanswer = None
	if toplevel is None:
		toplevel = getToplevel(session)

	errors = ""

	if config.plugins.Webinterface.enabled.value is not True:
		print "[Webinterface] is disabled!"

	else:
		# IF SSL is enabled we need to check for the certs first
		# If they're not there we'll exit via return here
		# and get called after Certificates are installed properly
		if config.plugins.Webinterface.https.enabled.value:
			installCertificates(session)

		# Listen on all Interfaces

		#HTTP
		port = config.plugins.Webinterface.http.port.value
		auth = config.plugins.Webinterface.http.auth.value
		if config.plugins.Webinterface.http.enabled.value is True:
			ret = startServerInstance(session, port, useauth=auth, l2k=l2k)
			if not ret:
				errors = "%s port %i\n" %(errors, port)
			else:
				registerBonjourService('http', port)

		#Streaming requires listening on localhost:80 no matter what, ensure it its available
		if config.plugins.Webinterface.http.port.value != 88 or not config.plugins.Webinterface.http.enabled.value:
			#LOCAL HTTP Connections (Streamproxy)
			local4 = "127.0.0.1"
			local4mapped = "::ffff:127.0.0.1"
			local6 = "::1"

			ret = startServerInstance(session, 88, useauth=auth, l2k=l2k, ipaddress=local4)
			if not ret:
				errors = "%s%s:%i\n" %(errors, local4, 88)
			ret = startServerInstance(session, 88, useauth=auth, l2k=l2k, ipaddress=local4mapped, ipaddress2=local6)
			#ip6 is optional
#			if not ret:
#				errors = "%s%s/%s:%i\n" %(errors, local4mapped, local6, 80)

		#HTTPS
		if config.plugins.Webinterface.https.enabled.value is True:
			sport = config.plugins.Webinterface.https.port.value
			sauth = config.plugins.Webinterface.https.auth.value

			ret = startServerInstance(session, sport, useauth=sauth, l2k=l2k, usessl=True)
			if not ret:
				errors = "%s%s:%i\n" %(errors, "0.0.0.0 / ::", sport)
			else:
				registerBonjourService('https', sport)

		if errors:
			session.open(MessageBox, "Webinterface - Couldn't listen on:\n %s" % (errors), type=MessageBox.TYPE_ERROR, timeout=30)