Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Penguidom
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
domotika
Penguidom
Commits
1a0673f2
Commit
1a0673f2
authored
Jan 11, 2018
by
Franco (nextime) Lanza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Web starting to give some errors back... it works!
parent
47fd557a
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
189 additions
and
5 deletions
+189
-5
penguidomd.conf
conf/defaults/penguidomd.conf
+12
-0
penguidom.py
penguidom/penguidom.py
+9
-0
paradox37b.py
penguidom/plugins/paradox/paradox37b.py
+2
-2
messengerlinks.py
penguidom/singleton/messengerlinks.py
+99
-0
bot.py
penguidom/web/bot.py
+1
-1
dmjson.py
penguidom/web/dmjson.py
+30
-0
web.py
penguidom/web/web.py
+0
-2
penguidomd
penguidomd
+32
-0
create.sh
ssl/create.sh
+4
-0
No files found.
conf/defaults/penguidomd.conf
View file @
1a0673f2
...
...
@@ -47,6 +47,18 @@ timecheck: yes
tollerance
:
10
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
]
loglevel
:
debug
...
...
penguidom/penguidom.py
View file @
1a0673f2
...
...
@@ -41,6 +41,8 @@ from dmlib import dmdomain
from
singleton
import
Singleton
import
pluggable
import
ikap
from
web
import
web
try
:
...
...
@@ -118,6 +120,13 @@ class penguidomService(service.Service):
self
.
tcp
=
ikap
.
DomIkaServerFactory
(
caller
)
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
):
return
self
.
config
.
get
(
section
,
var
)
...
...
penguidom/plugins/paradox/paradox37b.py
View file @
1a0673f2
...
...
@@ -172,8 +172,8 @@ DISARM = REGISTERS.DISARM
STAY
=
REGISTERS
.
STAY
SLEEP
=
REGISTERS
.
SLEEP
PGM_ON
=
REGISTERS
.
ON
PGM_OFF
=
REGISTER
.
OFF
#PGM_CHANGE = REGISTER.CHANGE
PGM_OFF
=
REGISTER
S
.
OFF
#PGM_CHANGE = REGISTER
S
.CHANGE
penguidom/singleton/messengerlinks.py
0 → 100644
View file @
1a0673f2
###########################################################################
# 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
()
penguidom/web/bot.py
View file @
1a0673f2
...
...
@@ -38,7 +38,7 @@ import time
from
Queue
import
Queue
import
uuid
from
domotika
.singleton
import
messengerlinks
from
penguidom
.singleton
import
messengerlinks
from
StringIO
import
StringIO
import
imghdr
...
...
penguidom/web/dmjson.py
0 → 100644
View file @
1a0673f2
###########################################################################
# 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
)
penguidom/web/web.py
View file @
1a0673f2
...
...
@@ -50,7 +50,6 @@ LOGINFILE=os.path.normpath("/".join([curdir, 'Web/resources/login.html']))
from
common
import
uni
,
GzipRequest
,
StaticFile
,
codeOk
,
permissionDenied
,
RedirectToHome
,
neededPermission
import
ajax
import
sse
WEB_SYSTEM_PATHS
=
[
...
...
@@ -356,7 +355,6 @@ class RootAuthPage(RootPage):
self
.
mind
.
perms
=
self
.
perms
if
'rememberMe'
in
self
.
mind
.
args
:
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
,
" "
.
join
([
self
.
perms
.
username
,
self
.
perms
.
loginpwd
,
self
.
perms
.
passwd
]))
try
:
...
...
penguidomd
View file @
1a0673f2
...
...
@@ -54,6 +54,21 @@ loglevels = {
#LOGLEN=10485760 # 10 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
):
...
...
@@ -75,6 +90,21 @@ class penguidomDaemon(Daemonizer):
IkapServerUDP
=
PENGUIDOMServerService
.
getIkapUDP
()
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'
]:
reactor
.
listenUDP
(
int
(
self
.
daemoncfg
.
get
(
'ikap'
,
'port'
)),
IkapServerUDP
,
...
...
@@ -99,6 +129,8 @@ if __name__ == "__main__":
logdict
=
{
"corelog"
:
{
"file"
:
"penguidom.log"
,
"name"
:[(
"Core"
,
"general"
)]},
"weblog"
:
{
"file"
:
"web.log"
,
"name"
:[(
"Webgui"
,
"web"
)]},
"pluginslog"
:
{
"file"
:
"plugins.log"
,
"name"
:[(
"Plugins"
,
"plugins"
)]},
"protocollog"
:
...
...
ssl/create.sh
0 → 100755
View file @
1a0673f2
#!/bin/bash
openssl genrsa
-out
privkey.key 2048
openssl req
-new
-x509
-key
privkey.key
-out
cacert.crt
-days
3650
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment