Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
D
domotikad
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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
domotika
domotikad
Commits
dedd3c95
Commit
dedd3c95
authored
Jan 04, 2014
by
nextime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Another optimization on invalid timecheck packets
parent
894ff02a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
ikapserver.py
domotika/ikapserver.py
+9
-5
No files found.
domotika/ikapserver.py
View file @
dedd3c95
...
...
@@ -81,6 +81,7 @@ TCPCLIENTREG=TCPClientRegistry.getInstance()
class
DomIkaBaseProtocol
(
object
):
debugmode
=
False
lastsettime
=
0
def
__init__
(
self
,
core
,
*
args
,
**
kwargs
):
self
.
core
=
core
...
...
@@ -357,7 +358,10 @@ class DomIkaBaseProtocol(object):
self
.
core
.
manageIncomingPacket
(
self
.
ikahdr
,
src
,
dst
,
arg
,
host
,
port
,
ptype
,
argdict
,
data
)
else
:
log
.
error
(
"INVALID PACKET TIME FROM "
+
str
(
host
)
+
" - packet time: "
+
str
(
self
.
ikahdr
.
epoch
)
+
" now: "
+
str
(
time
.
time
()))
# XXX Set a min time between resend the time broadcasting to avoid DoS?
now
=
int
(
time
.
time
())
if
now
-
self
.
lastsettime
>
10
:
self
.
core
.
broadcastTime
()
else
self
.
core
.
broadcastTime
(
host
)
self
.
invalidPacket
()
else
:
...
...
@@ -451,8 +455,8 @@ class DomIkaTCP(Int8StringReceiver, DomIkaBaseProtocol):
self
.
disconnected
=
False
self
.
sendCommand
(
"IOSTATUS.NOW"
,
arg
=
C
.
IKAP_BROADCAST
,
act
=
C
.
IKAP_ACT_BOARD
,
ctx
=
C
.
IKAP_CTX_SYSTEM
,
msgtype
=
C
.
IKAP_MSG_REQUESTCONF
)
#
self.sendCommand("SETTIME", arg=struct.pack("<L", int(time.time())), act=C.IKAP_ACT_BOARD, ctx=C.IKAP_CTX_SYSTEM, msgtype=C.IKAP_MSG_ACTION)
self
.
core
.
broadcastTime
()
self
.
sendCommand
(
"SETTIME"
,
arg
=
struct
.
pack
(
"<L"
,
int
(
time
.
time
())),
act
=
C
.
IKAP_ACT_BOARD
,
ctx
=
C
.
IKAP_CTX_SYSTEM
,
msgtype
=
C
.
IKAP_MSG_ACTION
)
#
self.core.broadcastTime()
def
invalidPacket
(
self
):
try
:
...
...
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