FAForever / FAForever/server

Better logging for malformed messages

オープン
#661 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
good first issue
主要言語
Python
スター
72
フォーク
84
平均マージ
5時間 11分
マージ済み PR(30日)
1

説明

There are a number of mysterious errors which indicate that sometimes clients are sending malformed protocol messages:

```
ERROR Sep 03 21:05:08 ServerContext Invalid control character at: line 1 column 728 (char 727)
Traceback (most recent call last):
File "/code/server/servercontext.py", line 80, in client_connected
message = await protocol.read_message()
File "/code/server/protocol/qdatastreamprotocol.py", line 119, in read_message
message = json.loads(action)
File "/usr/local/lib/python3.7/json/__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.7/json/decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Invalid control character at: line 1 column 728 (char 727)
```

```
ERROR Sep 02 20:31:37 ServerContext Expecting ',' delimiter: line 1 column 10652 (char 10651)
Traceback (most recent call last):
File "/code/server/servercontext.py", line 80, in client_connected
message = await protocol.read_message()
File "/code/server/protocol/qdatastreamprotocol.py", line 119, in read_message
message = json.loads(action)
File "/usr/local/lib/python3.7/json/__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.7/json/decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 1 column 10652 (char 10651)
```

We should probably have some explicit error handling that expects these sorts of errors and logs the entire message. These could easily be caused by non FAF traffic like automated portscans or something, but if they are legitimate messages, then maybe there is a bug in the client somewhere.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。