Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Remote Command Over WiFi #255

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Conversation

nekomona
Copy link
Contributor

This PR add a remote command server running in parallel with the serial command, sharing the same command buffer, command lists, and logger outputs. All the data printed through Logger will be forked to the remote when connected, while the ones using Serial won't be forked.

The remote command server could be accessed through telnet clients. Would be easy to integrate into server since it use a simple TCP socket to transmit the same data as serial commands do.

Currently this remote command mostly benefits for checking TCAL status remotely, as other commands are mostly for debugging instead of functions. This could be used for future function commands which are too minor to occupy a packet type or doesn't fit well in a UDP packet like largely varying data length.

Copy link
Member

@TheDevMinerTV TheDevMinerTV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, more network stuff for me to refactor in impl/feature-retrieval

LGTM

src/logging/Logger.h Outdated Show resolved Hide resolved
@TheDevMinerTV
Copy link
Member

It'd be cool if you could rebase this onto #256

@nekomona
Copy link
Contributor Author

nekomona commented Jul 2, 2023

pain^2

Copy link
Member

@TheDevMinerTV TheDevMinerTV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, would be nice if it were rebased against the network rewrite stuff tho

@nekomona nekomona force-pushed the rcmd_merge branch 2 times, most recently from e3d2e80 to 758f8a1 Compare July 4, 2023 02:50
@ImUrX ImUrX self-requested a review July 4, 2023 08:20
src/logging/RemoteLogHelper.h Outdated Show resolved Hide resolved
src/logging/RemoteLogHelper.cpp Outdated Show resolved Hide resolved
src/network/remotecmd.h Outdated Show resolved Hide resolved
src/network/remotecmd.cpp Outdated Show resolved Hide resolved
@nekomona
Copy link
Contributor Author

IP check is added, so that remote command would only accept connection from the IP of connected SlimeVR Server. When the server is not connected, any IP could connect to the remote command, but will not receive any response, and only accept the SET WIFI command for future SoftAP-based provisioning.

@ImUrX
Copy link
Member

ImUrX commented Jul 30, 2023

commit history is a little broken on this and #262 😓

@Eirenliel
Copy link
Member

We squash it so it doesn't matter..

@nekomona
Copy link
Contributor Author

Rebased to main after v0.4.0 and tested on ESP32-S3, remote commands and server IP checks are looking good.

src/serial/serialcommands.cpp Outdated Show resolved Hide resolved
@@ -73,8 +74,8 @@ class FirmwareFeatures {
public:
enum EFirmwareFeatureFlags: uint32_t {
// EXAMPLE_FEATURE,
REMOTE_COMMAND = 0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this really be 0? Is there a reason we started at 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just from that the first version of remote command is written before WiFi scanning

Comment on lines +151 to +153
#if USE_REMOTE_COMMAND && ALLOW_REMOTE_WIFI_PROV
if (cmdFromRemote && !networkConnection.isConnected()) return;
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used multiple times throughout this file, but it's not applied to every command? Why not just put it at the parser before the command functions are called? Also why is it on get and such? Isn't WiFi prov just for setting the WiFi?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea here is to only allow SET and block other commands in the provisioning phase, before connected to a slime server. The repetition is from that the command is only known to be a SET after parsing, which is processed inside cmdParser.

@loucass003
Copy link
Member

As much as i would love this feature. There might be security concerns to think about. As sending commands over wifi would allow the usage of the reboot command remotely.

Rebooting will make the OTA reset and allow for flashing new firmwares without the user interaction.

As is, this PR is dangerous.

If we could find a way to secure the connection when sending those commands it would be a super cool feature

Copy link
Member

@loucass003 loucass003 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too dangerous as is

@ButterscotchV
Copy link
Member

Can we just cut out the sending commands part and focus on the receiving bit for now instead? I think it would be interesting to handle sending but there are definitely considerations to be made about security there

Co-authored-by: Butterscotch! <bscotchvanilla@gmail.com>
@nekomona
Copy link
Contributor Author

nekomona commented Oct 4, 2024

Can we just cut out the sending commands part and focus on the receiving bit for now instead? I think it would be interesting to handle sending but there are definitely considerations to be made about security there

I think we could let the command part to be an define option disabled by default, and probably reject REBOOT and FACTORY RESET from remote completely.

@ImUrX
Copy link
Member

ImUrX commented Oct 30, 2024

I think we could let the command part to be an define option disabled by default, and probably reject REBOOT and FACTORY RESET from remote completely.

sounds good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants