conqp / rcon

Python RCON client library
GNU General Public License v3.0
83 stars 15 forks source link

ValueError while reading a packet received from Half Life Alyx rcon #35

Open morgancasale opened 3 days ago

morgancasale commented 3 days ago

Hi, I' trying to connect to the rcon of Half Life alyx using a simple test code:

from rcon.source import Client

with Client('Localhost', 29000, passwd='password') as client:
    response = client.run('echo', 'Hi!')

print(response)

Anytime I try to run it I get the same error ValueError('64768 is not a valid Type')

The error seems to be generated by the function Type.read in proto.py

I'll attach the entire error traceback:

File "c:\Users\Morgan\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\Users\Morgan\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "c:\Users\Morgan\.vscode\extensions\ms-python.debugpy-2024.12.0-win32-x64\bundled\libs\debugpy\__main__.py", line 71, in <module>
    cli.main()
  File "c:\Users\Morgan\.vscode\extensions\ms-python.debugpy-2024.12.0-win32-x64\bundled\libs\debugpy/..\debugpy\server\cli.py", line 501, in main
    run()
  File "c:\Users\Morgan\.vscode\extensions\ms-python.debugpy-2024.12.0-win32-x64\bundled\libs\debugpy/..\debugpy\server\cli.py", line 351, in run_file
    runpy.run_path(target, run_name="__main__")
  File "c:\Users\Morgan\.vscode\extensions\ms-python.debugpy-2024.12.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 310, in run_path
    return _run_module_code(code, init_globals, run_name, pkg_name=pkg_name, script_name=fname)
  File "c:\Users\Morgan\.vscode\extensions\ms-python.debugpy-2024.12.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 127, in _run_module_code
    _run_code(code, mod_globals, init_globals, mod_name, mod_spec, pkg_name, script_name)
  File "c:\Users\Morgan\.vscode\extensions\ms-python.debugpy-2024.12.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 118, in _run_code
    exec(code, run_globals)
  File "D:\Program Files\Steam\steamapps\common\Half-Life Alyx\game\hlvr\scripts\vscripts\rcon_test.py", line 3, in <module>
  File "c:\Users\Morgan\AppData\Local\Programs\Python\Python310\lib\site-packages\rcon\client.py", line 34, in __enter__
    self.login(self.passwd)
login
    while (response := self.read()).type != Type.SERVERDATA_AUTH_RESPONSE:
    response = Packet.read(file)
read
    type_ = Type.read(file, prefix="  ")
    return cls(value)
  File "c:\Users\Morgan\AppData\Local\Programs\Python\Python310\lib\enum.py", line 385, in __call__
    return cls.__new__(cls, value)
  File "c:\Users\Morgan\AppData\Local\Programs\Python\Python310\lib\enum.py", line 710, in __new__
    raise ve_exc
ValueError: 64768 is not a valid Type
conqp commented 3 days ago

Hm, that's weird. It appears that the server sends back a response with type 64768, which is not a valid type for Source RCON. In Little Endian, from which we read that, the server must be sending [0x00, 0xFD, 0x00, 0x00] at this field. Can you please dump the raw payload, e.g. by print debugging, which the server sends?

morgancasale commented 3 days ago

image I think the server response is saved in this file variable, tell me if you need me to processes it in some way to extract the info you need. As it is, it doesn't seem to rely any useful information😂