Web starting to give some errors back... it works!

parent 47fd557a
...@@ -47,6 +47,18 @@ timecheck: yes ...@@ -47,6 +47,18 @@ timecheck: yes
tollerance: 10 tollerance: 10
netpwd: netpwd:
[web]
enable: yes
interface: 0.0.0.0
sslport: 443
sslonly: yes
port: 81
privkey: ssl/privkey.key
cacert: ssl/cacert.crt
loglevel: info
cookie_aeskey: CHANGE_ME_PLEASE
[plugins] [plugins]
loglevel: debug loglevel: debug
......
...@@ -41,6 +41,8 @@ from dmlib import dmdomain ...@@ -41,6 +41,8 @@ from dmlib import dmdomain
from singleton import Singleton from singleton import Singleton
import pluggable import pluggable
import ikap import ikap
from web import web
try: try:
...@@ -118,6 +120,13 @@ class penguidomService(service.Service): ...@@ -118,6 +120,13 @@ class penguidomService(service.Service):
self.tcp = ikap.DomIkaServerFactory(caller) self.tcp = ikap.DomIkaServerFactory(caller)
return self.tcp return self.tcp
def getAuthWebServer(self):
from nevow import appserver
caller = ConvenienceCaller(lambda c: self._callback('web', c))
self.authsite = web.getAuthResource(caller)
return appserver.NevowSite(self.authsite)
def on_configGet(self, section, var): def on_configGet(self, section, var):
return self.config.get(section, var) return self.config.get(section, var)
......
...@@ -172,8 +172,8 @@ DISARM = REGISTERS.DISARM ...@@ -172,8 +172,8 @@ DISARM = REGISTERS.DISARM
STAY = REGISTERS.STAY STAY = REGISTERS.STAY
SLEEP = REGISTERS.SLEEP SLEEP = REGISTERS.SLEEP
PGM_ON = REGISTERS.ON PGM_ON = REGISTERS.ON
PGM_OFF = REGISTER.OFF PGM_OFF = REGISTERS.OFF
#PGM_CHANGE = REGISTER.CHANGE #PGM_CHANGE = REGISTERS.CHANGE
###########################################################################
# Copyright (c) 2018- Franco (nextime) Lanza <franco@nexlab.it>
#
# Penguidom System client Daemon "penguidomd" [https://git.nexlab.net/domotika/Penguidom]
#
# This file is part of penguidom.
#
# penguidom is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from nexlibs.singleton import Singleton
from twisted.internet import reactor
EXPIRETIME=300
class MessengerLinksSingleton(Singleton):
links = {}
expires = {}
def __init__(self, *args, **kwargs):
Singleton.__init__( self )
def del_expire(self, linkid):
if linkid in self.expires.keys():
try:
self.expires[linkid].cancel()
except:
pass
del self.expires[linkid]
def add_expire(self, linkid):
self.del_expire(linkid)
self.expires[linkid] = reactor.callLater(EXPIRETIME, self.del_link, linkid)
def add_link(self, linkid, usr):
self.links[linkid] = usr;
self.add_expire(linkid)
def del_link(self, linkid):
if linkid in self.links.keys():
del self.links[linkid]
def get_link(self, linkid):
if linkid in self.links.keys():
return self.links[linkid]
return False
def linkid_exists(self, linkid):
if linkid in self.links.keys():
return True
return False
def MessengerLinkRegistry():
return MessengerLinksSingleton.getInstance()
class MessengerPSIDSingleton(Singleton):
links = {}
def __init__(self, *args, **kwargs):
Singleton.__init__( self )
def add_link(self, linkid, usr):
self.links[linkid] = usr;
def del_link(self, linkid):
if linkid in self.links.keys():
del self.links[linkid]
def get_link(self, linkid):
if linkid in self.links.keys():
return self.links[linkid]
return False
def linkid_exists(self, linkid):
if linkid in self.links.keys():
return True
return False
def MessengerPSIDRegistry():
return MessengerPSIDSingleton.getInstance()
...@@ -38,7 +38,7 @@ import time ...@@ -38,7 +38,7 @@ import time
from Queue import Queue from Queue import Queue
import uuid import uuid
from domotika.singleton import messengerlinks from penguidom.singleton import messengerlinks
from StringIO import StringIO from StringIO import StringIO
import imghdr import imghdr
......
###########################################################################
# Copyright (c) 2018- Franco (nextime) Lanza <franco@nexlab.it>
#
# Penguidom System client Daemon "penguidomd" [https://git.nexlab.net/domotika/Penguidom]
#
# This file is part of penguidom.
#
# penguidom is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import json
from twisted.web import static
def jsonize(data, add_data=False):
return static.Data(json.dumps(data), 'application/json')
def jsonize_text(data, add_data=False):
return json.dumps(data)
...@@ -50,7 +50,6 @@ LOGINFILE=os.path.normpath("/".join([curdir, 'Web/resources/login.html'])) ...@@ -50,7 +50,6 @@ LOGINFILE=os.path.normpath("/".join([curdir, 'Web/resources/login.html']))
from common import uni, GzipRequest, StaticFile, codeOk, permissionDenied, RedirectToHome, neededPermission from common import uni, GzipRequest, StaticFile, codeOk, permissionDenied, RedirectToHome, neededPermission
import ajax import ajax
import sse
WEB_SYSTEM_PATHS=[ WEB_SYSTEM_PATHS=[
...@@ -356,7 +355,6 @@ class RootAuthPage(RootPage): ...@@ -356,7 +355,6 @@ class RootAuthPage(RootPage):
self.mind.perms = self.perms self.mind.perms = self.perms
if 'rememberMe' in self.mind.args: if 'rememberMe' in self.mind.args:
log.debug("Setting rememberMe cookie for avatar "+str(self.avatarId)) log.debug("Setting rememberMe cookie for avatar "+str(self.avatarId))
#session = inevow.ISession(ctx)
rme=dmcrypt.B64AESEncrypt(str(self.core.configGet('web', 'cookie_aeskey')), self.perms.passwd, rme=dmcrypt.B64AESEncrypt(str(self.core.configGet('web', 'cookie_aeskey')), self.perms.passwd,
" ".join([self.perms.username, self.perms.loginpwd, self.perms.passwd])) " ".join([self.perms.username, self.perms.loginpwd, self.perms.passwd]))
try: try:
......
...@@ -54,6 +54,21 @@ loglevels = { ...@@ -54,6 +54,21 @@ loglevels = {
#LOGLEN=10485760 # 10 mega #LOGLEN=10485760 # 10 mega
LOGLEN=26214400 # 25 mega LOGLEN=26214400 # 25 mega
from OpenSSL import SSL
class PenguiSSLContext(ssl.DefaultOpenSSLContextFactory):
def cacheContext(self):
if self._context is None:
ctx = self._contextFactory(self.sslmethod)
# Disallow SSLv2! It's insecure! SSLv3 has been around since
# 1996. It's time to move on.
ctx.set_options(SSL.OP_NO_SSLv2)
ctx.use_certificate_chain_file(self.certificateFileName)
ctx.use_privatekey_file(self.privateKeyFileName)
self._context = ctx
class penguidomDaemon(Daemonizer): class penguidomDaemon(Daemonizer):
...@@ -75,6 +90,21 @@ class penguidomDaemon(Daemonizer): ...@@ -75,6 +90,21 @@ class penguidomDaemon(Daemonizer):
IkapServerUDP = PENGUIDOMServerService.getIkapUDP() IkapServerUDP = PENGUIDOMServerService.getIkapUDP()
IkapServerTCP = PENGUIDOMServerService.getIkapTCP() IkapServerTCP = PENGUIDOMServerService.getIkapTCP()
WebAuthServer = PENGUIDOMServerService.getAuthWebServer()
privkey = self.daemoncfg.get('web', 'privkey')
cacert = self.daemoncfg.get('web', 'cacert')
if not privkey.startswith('/'): privkey="/".join([self.curdir, privkey])
if not cacert.startswith('/'): cacert="/".join([self.curdir, cacert])
sslContext = PenguiSSLContext(privkey, cacert)
if str(self.daemoncfg.get('web', 'enable')).lower() in ['yes', '1', 'y','true']:
reactor.listenSSL(int(self.daemoncfg.get('web', 'sslport')), WebAuthServer,
contextFactory=sslContext,
interface=str(self.daemoncfg.get('web', 'interface')))
if not str(self.daemoncfg.get('web', 'sslonly')).lower() in ['yes', '1', 'y','true']:
reactor.listenTCP(int(self.daemoncfg.get('web', 'port')), WebAuthServer,
interface=str(self.daemoncfg.get('web', 'interface')))
if str(self.daemoncfg.get('ikap', 'enable')).lower() in ['yes', '1', 'y','true']: if str(self.daemoncfg.get('ikap', 'enable')).lower() in ['yes', '1', 'y','true']:
reactor.listenUDP(int(self.daemoncfg.get('ikap', 'port')), IkapServerUDP, reactor.listenUDP(int(self.daemoncfg.get('ikap', 'port')), IkapServerUDP,
...@@ -99,6 +129,8 @@ if __name__ == "__main__": ...@@ -99,6 +129,8 @@ if __name__ == "__main__":
logdict={"corelog": logdict={"corelog":
{"file":"penguidom.log","name":[("Core","general")]}, {"file":"penguidom.log","name":[("Core","general")]},
"weblog":
{"file":"web.log","name":[("Webgui","web")]},
"pluginslog": "pluginslog":
{"file":"plugins.log","name":[("Plugins","plugins")]}, {"file":"plugins.log","name":[("Plugins","plugins")]},
"protocollog": "protocollog":
......
#!/bin/bash
openssl genrsa -out privkey.key 2048
openssl req -new -x509 -key privkey.key -out cacert.crt -days 3650
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment