BOSWatch/BW3-Core

client isConnected [possible BUG]

Schrolli91 opened this issue · 1 comments

The client will check his connect status by send a packet with <keep-alive>.
But its possible that the client will spam this packet to the server instance.
We should take a network record (wireshark) and check how many packets are sent by this mechanism.

There is also a problem with the error handling if received data are broken:

20.09.2020 21:25:01,286 - Thread-6        server          handle             [DEBUG   ] Thread-6 192.168.192.### recv header: '12        '
20.09.2020 21:25:01,287 - Thread-6        server          handle             [DEBUG   ] Thread-6 192.168.192.### recv 10 bytes:

<keep-aliv
20.09.2020 21:25:01,287 - Thread-6        server          handle             [DEBUG   ] Add data to queue
20.09.2020 21:25:01,288 - Thread-6        server          handle             [DEBUG   ] Thread-6 192.168.192.### send: [ack]
20.09.2020 21:25:01,290 - Thread-6        server          handle             [INFO    ] Client disconnected: 192.168.192.###
20.09.2020 21:25:01,367 - MainThread      bw_server       <module>           [INFO    ] get data from 192.168.192.### (waited in queue 0.079 sec.)
20.09.2020 21:25:01,368 - MainThread      bw_server       <module>           [DEBUG   ] 0 packet(s) still waiting in queue
20.09.2020 21:25:01,368 - MainThread      packet          init           [DEBUG   ] create bwPacket from string
20.09.2020 21:25:01,368 - MainThread      bw_server       <module>           [ERROR   ] BOSWatch interrupted by an error
Traceback (most recent call last):
  File "bw_server.py", line 101, in <module>
    bwPacket = Packet((data[1]))
  File "/opt/boswatch3/boswatch/packet.py", line 35, in init
    self._packet = eval(str(bwPacket.strip()))
  File "<string>", line 1
    <keep-aliv
    ^
SyntaxError: invalid syntax
20.09.2020 21:25:01,370 - MainThread      bw_server       <module>           [DEBUG   ] Starting shutdown routine
07.08.2021 14:19:42,851 - Thread-3        server          handle             [DEBUG   ] Thread-3 172.27.236.5 recv header: '12        '
07.08.2021 14:19:42,852 - Thread-3        server          handle             [DEBUG   ] Thread-3 172.27.236.5 recv 6 bytes:
<keep-
07.08.2021 14:19:42,852 - Thread-3        server          handle             [DEBUG   ] Add data to queue
07.08.2021 14:19:42,852 - Thread-3        server          handle             [DEBUG   ] Thread-3 172.27.236.5 send: [ack]
07.08.2021 14:19:42,887 - Thread-3        server          handle             [INFO    ] Client disconnected: 172.27.236.5
07.08.2021 14:19:42,949 - MainThread      bw_server       <module>           [INFO    ] get data from 172.27.236.5 (waited in queue 0.097 sec.)
07.08.2021 14:19:42,950 - MainThread      bw_server       <module>           [DEBUG   ] 0 packet(s) still waiting in queue
07.08.2021 14:19:42,950 - MainThread      packet          __init__           [DEBUG   ] create bwPacket from string
07.08.2021 14:19:42,950 - MainThread      bw_server       <module>           [ERROR   ] BOSWatch interrupted by an error
Traceback (most recent call last):
  File "bw_server.py", line 101, in <module>
    bwPacket = Packet((data[1]))
  File "/opt/boswatch3/boswatch/packet.py", line 35, in __init__
    self._packet = eval(str(bwPacket.strip()))
  File "<string>", line 1
    <keep-
    ^
SyntaxError: invalid syntax
07.08.2021 14:19:42,964 - MainThread      bw_server       <module>           [DEBUG   ] Starting shutdown routine
07.08.2021 14:19:42,964 - MainThread      routerManager   cleanup            [DEBUG   ] Start cleanup for RouterMainPOC
07.08.2021 14:19:42,965 - MainThread      moduleBase      _cleanup           [DEBUG   ] [module.filter.modeFilter] onUnload()
07.08.2021 14:19:42,965 - MainThread      moduleBase      _cleanup           [DEBUG   ] [module.filter.regexFilter] onUnload()
07.08.2021 14:19:42,965 - MainThread      moduleBase      _cleanup           [DEBUG   ] [module.filter.doubleFilter] onUnload()
07.08.2021 14:19:42,965 - MainThread      moduleBase      _cleanup           [DEBUG   ] [module.descriptor] onUnload()
07.08.2021 14:19:42,966 - MainThread      routerManager   cleanup            [DEBUG   ] Start cleanup for RouterAlarm
07.08.2021 14:19:42,966 - MainThread      moduleBase      _cleanup           [DEBUG   ] [module.filter.regexFilter] onUnload()
07.08.2021 14:19:42,966 - MainThread      pluginBase      _cleanup           [DEBUG   ] [plugin.fcmrts] onUnload()
07.08.2021 14:19:42,966 - MainThread      pluginBase      _cleanup           [DEBUG   ] [plugin.telegram] onUnload()
07.08.2021 14:19:42,966 - MainThread      routerManager   cleanup            [DEBUG   ] Start cleanup for RouterLog
07.08.2021 14:19:42,967 - MainThread      pluginBase      _cleanup           [DEBUG   ] [plugin.mysql] onUnload()
07.08.2021 14:19:43,260 - MainThread      server          stop               [DEBUG   ] TCPServer stopped
07.08.2021 14:19:43,260 - MainThread      broadcast       stop               [WARNING ] udp broadcast server always stopped
07.08.2021 14:19:43,260 - MainThread      bw_server       <module>           [DEBUG   ] BOSWatch server has stopped ...

Aug 07 14:19:43 openvpn-vm python3[26715]:   File "/opt/boswatch3/boswatch/network/server.py", line 53, in handle
Aug 07 14:19:43 openvpn-vm python3[26715]:     length = int(header.strip())
Aug 07 14:19:43 openvpn-vm python3[26715]: ValueError: invalid literal for int() with base 10: 'alive>12'