olijeffers0n / rustplus

Rust+ API Wrapper Written in Python for the Game: Rust
https://rplus.ollieee.xyz/
MIT License
108 stars 28 forks source link

Connection is allowed with invalid STEAMID or PLAYER_TOKEN #50

Closed ITz-Viks closed 1 year ago

ITz-Viks commented 1 year ago

Creating a RustSocket object with the correct server ip and port and wrong steamid and/or player_token will still successfully connect and create a RustSocket object but attempting to run socket commands such as get_info will result in a not_found error. The issue is that this is not caught by the on_failure specified in socket.connect()

Error:

Traceback (most recent call last):
  File "C:\Users\Vik\OneDrive\rustplus\main.py", line 44, in <module>
    asyncio.run(main())
  File "C:\Users\Vik\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\Vik\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vik\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\Vik\OneDrive\rustplus\main.py", line 39, in main
    await test_time(socket)
  File "C:\Users\Vik\OneDrive\rustplus\main.py", line 21, in test_time
    info = await socket.get_info()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vik\OneDrive\rustplus\venv\Lib\site-packages\rustplus\api\rust_api.py", line 109, in get_info
    response = await self.remote.get_response(app_request.seq, app_request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vik\OneDrive\rustplus\venv\Lib\site-packages\rustplus\api\remote\rust_remote_interface.py", line 166, in get_response
    raise RequestError(response.response.error.error)
rustplus.exceptions.exceptions.RequestError: not_found

Process finished with exit code 1

Note that C:\Users\Vik\OneDrive\rustplus is the directory of my project and not the lib(it is located in a venv)

olijeffers0n commented 1 year ago

This error is only sent from the server when you request data, so isn't available upon construction or connection. I could send a ping on Connect, but I don't see the point in this.

Player Credentials are only sent when you request data, hence this behaviour

ITz-Viks commented 1 year ago

That's true. It'd be very rare to naturally encounter this issue, I just wanted to let this be known.