Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
bf2c5aee
Commit
bf2c5aee
authored
Mar 20, 2012
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not notify about malformed packet in order to avoid bounces
parent
4f1b6c28
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
20 deletions
+16
-20
neo/lib/connection.py
neo/lib/connection.py
+6
-7
neo/lib/handler.py
neo/lib/handler.py
+4
-6
neo/tests/testConnection.py
neo/tests/testConnection.py
+5
-5
neo/tests/testHandler.py
neo/tests/testHandler.py
+1
-2
No files found.
neo/lib/connection.py
View file @
bf2c5aee
...
@@ -499,16 +499,15 @@ class Connection(BaseConnection):
...
@@ -499,16 +499,15 @@ class Connection(BaseConnection):
def
analyse
(
self
):
def
analyse
(
self
):
"""Analyse received data."""
"""Analyse received data."""
while
True
:
# parse a packet
try
:
try
:
while
True
:
packet
=
Packets
.
parse
(
self
.
read_buf
,
self
.
_parser_state
)
packet
=
Packets
.
parse
(
self
.
read_buf
,
self
.
_parser_state
)
if
packet
is
None
:
if
packet
is
None
:
break
break
except
PacketMalformedError
,
msg
:
self
.
getHandler
().
_packetMalformed
(
self
,
msg
)
return
self
.
_queue
.
append
(
packet
)
self
.
_queue
.
append
(
packet
)
except
PacketMalformedError
,
e
:
logging
.
error
(
'malformed packet from %r: %s'
,
self
,
e
)
self
.
_closure
()
def
hasPendingMessages
(
self
):
def
hasPendingMessages
(
self
):
"""
"""
...
...
neo/lib/handler.py
View file @
bf2c5aee
...
@@ -56,11 +56,9 @@ class EventHandler(object):
...
@@ -56,11 +56,9 @@ class EventHandler(object):
except
UnexpectedPacketError
,
e
:
except
UnexpectedPacketError
,
e
:
if
not
conn
.
isClosed
():
if
not
conn
.
isClosed
():
self
.
__unexpectedPacket
(
conn
,
packet
,
*
e
.
args
)
self
.
__unexpectedPacket
(
conn
,
packet
,
*
e
.
args
)
except
PacketMalformedError
:
except
PacketMalformedError
,
e
:
if
not
conn
.
isClosed
():
logging
.
error
(
'malformed packet from %r: %s'
,
conn
,
e
)
logging
.
error
(
'malformed packet from %r'
,
conn
)
conn
.
close
()
conn
.
notify
(
Packets
.
Notify
(
'Malformed packet: %r'
%
(
packet
,
)))
conn
.
abort
()
# self.peerBroken(conn)
# self.peerBroken(conn)
except
BrokenNodeDisallowedError
:
except
BrokenNodeDisallowedError
:
if
not
conn
.
isClosed
():
if
not
conn
.
isClosed
():
...
...
neo/tests/testConnection.py
View file @
bf2c5aee
...
@@ -477,12 +477,12 @@ class ConnectionTests(NeoUnitTestBase):
...
@@ -477,12 +477,12 @@ class ConnectionTests(NeoUnitTestBase):
def
test_Connection_analyse3
(
self
):
def
test_Connection_analyse3
(
self
):
# give a bad packet, won't be decoded
# give a bad packet, won't be decoded
bc
=
self
.
_makeConnection
()
bc
=
self
.
_makeConnection
()
bc
.
_queue
=
Mock
()
p
=
Packets
.
Ping
()
self
.
_appendToReadBuf
(
bc
,
'datadatadatadata'
)
p
.
setId
(
1
)
self
.
_appendToReadBuf
(
bc
,
'%s%sdatadatadatadata'
%
p
.
encode
())
bc
.
analyse
()
bc
.
analyse
()
self
.
assertEqual
(
len
(
bc
.
_queue
.
mockGetNamedCalls
(
"append"
)),
0
)
self
.
_checkPacketReceived
(
1
)
# ping packet
self
.
assertEqual
(
self
.
_checkClose
(
1
)
# malformed packet
len
(
self
.
handler
.
mockGetNamedCalls
(
"_packetMalformed"
)),
1
)
def
test_Connection_analyse4
(
self
):
def
test_Connection_analyse4
(
self
):
# give an expected packet
# give an expected packet
...
...
neo/tests/testHandler.py
View file @
bf2c5aee
...
@@ -59,8 +59,7 @@ class HandlerTests(NeoUnitTestBase):
...
@@ -59,8 +59,7 @@ class HandlerTests(NeoUnitTestBase):
raise
PacketMalformedError
(
'message'
)
raise
PacketMalformedError
(
'message'
)
self
.
setFakeMethod
(
fake
)
self
.
setFakeMethod
(
fake
)
self
.
handler
.
dispatch
(
conn
,
packet
)
self
.
handler
.
dispatch
(
conn
,
packet
)
self
.
checkNotify
(
conn
)
self
.
checkClosed
(
conn
)
self
.
checkAborted
(
conn
)
# raise BrokenNodeDisallowedError
# raise BrokenNodeDisallowedError
conn
.
mockCalledMethods
=
{}
conn
.
mockCalledMethods
=
{}
def
fake
(
c
):
def
fake
(
c
):
...
...
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