Uninett / zino

Zino 2.0 - Network state monitor for research networks
Apache License 2.0
3 stars 5 forks source link

Implement line buffering in data_received() #164

Closed lunkwill42 closed 8 months ago

lunkwill42 commented 8 months ago

While manually testing the protocol implementation using simple tools like telnet or netcat, data_received() will usually receive full text lines from the transport, as these tools typically send a packet once Enter is pressed.

However, Protocol.data_received() will in fact receive any old piece of binary data, which can potentially come in arbitrarily sized packets, depending on the client. As demonstrated by the legacy cuRitz client, which will for example dispatch the text data associated with a ADDHIST command as one large, multiline packet: This causes the naive implementation of data_received() to fail and hang forever, as the multiline input mode will be waiting for a single packet containing b'.\r\n' before it's satisfied that input has ended.

This reworks data_received() to employ a simple bytearray buffer of incoming data, and moves most of the message parsing logic to a new method message_received(). The latter will only receive single, full lines of protocol data as string objects, with newlines and carriage returns stripped.

github-actions[bot] commented 8 months ago

Test results

    3 files      3 suites   25s :stopwatch: 249 tests 249 :heavy_check_mark: 0 :zzz: 0 :x: 747 runs  745 :heavy_check_mark: 2 :zzz: 0 :x:

Results for commit ca9d2939.

:recycle: This comment has been updated with latest results.

sonarcloud[bot] commented 8 months ago

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud