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
cc1d3454
Commit
cc1d3454
authored
Jan 05, 2018
by
Franco (nextime) Lanza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Few fix on ikap implementation
parent
cafdb270
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
14 deletions
+18
-14
ikap.py
penguidom/ikap.py
+12
-12
penguidom.py
penguidom/penguidom.py
+6
-2
No files found.
penguidom/ikap.py
View file @
cc1d3454
...
...
@@ -88,8 +88,8 @@ class DomIkaBaseProtocol(object):
self
.
initializated
=
False
def
retriveMemKey
(
self
):
if
len
(
self
.
core
.
configGet
(
'
protocol
'
,
'netpwd'
))
>
4
:
memkey
=
dmcrypt
.
DMHash256
(
self
.
core
.
configGet
(
'
protocol
'
,
'netpwd'
))
if
len
(
self
.
core
.
configGet
(
'
ikap
'
,
'netpwd'
))
>
4
:
memkey
=
dmcrypt
.
DMHash256
(
self
.
core
.
configGet
(
'
ikap
'
,
'netpwd'
))
log
.
info
(
"Protocol password is configured"
)
else
:
log
.
info
(
"Protocol password is DEFAULT"
)
...
...
@@ -99,8 +99,8 @@ class DomIkaBaseProtocol(object):
def
checkTimeLimits
(
self
,
epoch
):
# check if we are out of time limits
now
=
int
(
time
.
time
())
if
isTrue
(
self
.
core
.
configGet
(
'
protocol
'
,
'timecheck'
)):
tollerance
=
int
(
self
.
core
.
configGet
(
'
protocol
'
,
'tollerance'
))
if
isTrue
(
self
.
core
.
configGet
(
'
ikap
'
,
'timecheck'
)):
tollerance
=
int
(
self
.
core
.
configGet
(
'
ikap
'
,
'tollerance'
))
if
(
int
(
epoch
)
<
now
-
tollerance
or
int
(
epoch
)
>
now
+
tollerance
):
return
False
return
True
...
...
@@ -115,7 +115,7 @@ class DomIkaBaseProtocol(object):
self
.
aesdata
=
AES256
(
struct
.
unpack
(
'<8L'
,
self
.
memkey
),
struct
.
unpack
(
'<4L'
,
self
.
memiv
))
self
.
debugmode
=
False
if
self
.
core
.
configGet
(
'
protocol
'
,
'loglevel'
)
.
lower
()
==
'debug'
:
if
self
.
core
.
configGet
(
'
ikap
'
,
'loglevel'
)
.
lower
()
==
'debug'
:
self
.
debugmode
=
True
self
.
ikahdr
=
proto
.
IkaPacketHeader
()
...
...
@@ -292,8 +292,8 @@ class DomIkaUDP(DatagramProtocol, DomIkaBaseProtocol):
def
retrivePort
(
self
,
msgtype
):
if
msgtype
in
[
C
.
IKAP_BROADCAST
,
C
.
IKAP_MSG_REQUEST
,
C
.
IKAP_MSG_REQUESTCONF
,
C
.
IKAP_MSG_SETCONF
,
C
.
IKAP_MSG_ACK
]:
return
int
(
self
.
core
.
configGet
(
'ikap
server
'
,
'port'
))
return
int
(
self
.
core
.
configGet
(
'ikap
server
'
,
'notifyport'
))
return
int
(
self
.
core
.
configGet
(
'ikap'
,
'port'
))
return
int
(
self
.
core
.
configGet
(
'ikap'
,
'notifyport'
))
def
startProtocol
(
self
):
...
...
@@ -301,7 +301,7 @@ class DomIkaUDP(DatagramProtocol, DomIkaBaseProtocol):
self
.
transport
.
socket
.
setsockopt
(
SOL_SOCKET
,
SO_BROADCAST
,
True
)
try
:
self
.
transport
.
socket
.
setsockopt
(
SOL_SOCKET
,
IN
.
SO_BINDTODEVICE
,
self
.
core
.
configGet
(
'ikap
server
'
,
'ethdev'
))
self
.
core
.
configGet
(
'ikap'
,
'ethdev'
))
except
:
self
.
transport
.
socket
.
setsockopt
(
SOL_SOCKET
,
IN
.
SO_BINDTODEVICE
,
"eth0"
)
...
...
@@ -310,7 +310,7 @@ class DomIkaUDP(DatagramProtocol, DomIkaBaseProtocol):
self
.
transport
.
socket
.
setsockopt
(
SOL_SOCKET
,
SO_BROADCAST
,
True
)
try
:
self
.
transport
.
socket
.
setsockopt
(
SOL_SOCKET
,
IN
.
SO_BINDTODEVICE
,
self
.
core
.
configGet
(
'ikap
server
'
,
'ethdev'
))
self
.
core
.
configGet
(
'ikap'
,
'ethdev'
))
except
:
self
.
transport
.
socket
.
setsockopt
(
SOL_SOCKET
,
IN
.
SO_BINDTODEVICE
,
"eth0"
)
self
.
initializated
=
True
...
...
@@ -323,7 +323,7 @@ class DomIkaUDP(DatagramProtocol, DomIkaBaseProtocol):
self
.
transport
.
socket
.
setsockopt
(
SOL_SOCKET
,
SO_BROADCAST
,
True
)
try
:
self
.
transport
.
socket
.
setsockopt
(
SOL_SOCKET
,
IN
.
SO_BINDTODEVICE
,
self
.
core
.
configGet
(
'ikap
server
'
,
'ethdev'
))
self
.
core
.
configGet
(
'ikap'
,
'ethdev'
))
except
:
self
.
transport
.
socket
.
setsockopt
(
SOL_SOCKET
,
IN
.
SO_BINDTODEVICE
,
"eth0"
)
...
...
@@ -334,7 +334,7 @@ class DomIkaUDP(DatagramProtocol, DomIkaBaseProtocol):
log
.
debug
(
'SEND UDP PACKET:
%
r'
%
p
.
cleanpacket
())
def
datagramReceived
(
self
,
data
,
(
host
,
port
)):
return
self
.
ikapPacketReceived
(
data
,
(
host
,
int
(
self
.
core
.
configGet
(
'ikap
server
'
,
'port'
))),
'UDP4'
)
return
self
.
ikapPacketReceived
(
data
,
(
host
,
int
(
self
.
core
.
configGet
(
'ikap'
,
'port'
))),
'UDP4'
)
...
...
@@ -420,6 +420,6 @@ class DomIkaServerFactory(ServerFactory):
if
__name__
==
'__main__'
:
from
twisted.internet
import
reactor
reactor
.
listenUDP
(
6654
,
DomIkaUDP
(),
self
.
core
.
configGet
(
'ikap
server
'
,
'interface'
))
reactor
.
listenUDP
(
6654
,
DomIkaUDP
(),
self
.
core
.
configGet
(
'ikap'
,
'interface'
))
reactor
.
run
()
penguidom/penguidom.py
View file @
cc1d3454
...
...
@@ -83,8 +83,11 @@ class penguidomService(service.Service):
to the instance of the higher level object initialization or by
setting it using the abstraction of the ConvenienceCaller metaclass
"""
try
:
try
:
f
=
getattr
(
self
,
who
+
'_on_'
+
cmd
)
except
:
f
=
getattr
(
self
,
'on_'
+
cmd
)
if
f
and
callable
(
f
):
return
f
except
:
...
...
@@ -110,5 +113,6 @@ class penguidomService(service.Service):
self
.
tcp
=
ikap
.
DomIkaServerFactory
(
caller
)
return
self
.
tcp
def
on_configGet
(
self
,
section
,
var
):
return
self
.
config
.
get
(
section
,
var
)
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