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

Host Wake-On-LAN #126

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft

Host Wake-On-LAN #126

wants to merge 6 commits into from

Conversation

sixk32
Copy link

@sixk32 sixk32 commented Apr 10, 2024

Add an option to wake host by sending a magic packet to its last known IP and the usual broadcast IPs.

I had to retrieve the MacAddress from the server info, so this will only work after the host / client have been connected since this update. Warnings and errors are just sent to logging, wasn't sure if we should pop an error message or if we should hide the button if the host is connected / reachable.

Magic packet is constructed with 6 0xFF chars followed by 16 mac addresses (in base 16 decimal). This can't be tested using a local machine as the server info doesn't retrieve the mac address, but tested using my laptop fine.

Feel free to edit and thanks for creating this project.

if (host == nullptr || host->Connected) return;

if (host->MacAddress == nullptr || host->MacAddress == "00:00:00:00:00:00") {
Utils::Log("No recorded Mac address, the client and host must be connected at least once.\n");
Copy link
Owner

Choose a reason for hiding this comment

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

Must be paired, not just connected once.

You can check https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.contentdialog?view=windows-app-sdk-1.5 if you want a more interactive option

Copy link
Author

Choose a reason for hiding this comment

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

I'll update the message for now, doesn't feel right opening a dialog box from the state, might have a rethink

Copy link
Owner

@TheElixZammuto TheElixZammuto left a comment

Choose a reason for hiding this comment

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

Some blocking changes before testing

State/ApplicationState.cpp Outdated Show resolved Hide resolved
State/ApplicationState.cpp Outdated Show resolved Hide resolved
return;
}

std::string hostIP = Utils::PlatformStringToStdString(host->LastHostname).substr(0, 14);
Copy link
Owner

Choose a reason for hiding this comment

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

We might not be sure that LastHostname is a correct IP address. It might be a domain name or the local computer name. Only mDNS adds the machine via the IP address

}

std::string hostIP = Utils::PlatformStringToStdString(host->LastHostname).substr(0, 14);
std::string broadcastIP = (hostIP.substr(0, hostIP.length() - 3) + "255");
Copy link
Owner

Choose a reason for hiding this comment

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

This logic for handling the broadcast IP is wrong. I think you might want to check https://github.com/moonlight-stream/moonlight-qt/blob/ebe270bec5820b956f4c511fd31097a0c1d1a7c3/app/backend/nvcomputer.cpp#L216 to handle it better

Copy link
Owner

Choose a reason for hiding this comment

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

sixk32 and others added 2 commits April 18, 2024 15:06
Co-authored-by: TheElixZammuto <theelixzammuto@gmail.com>
Co-authored-by: TheElixZammuto <theelixzammuto@gmail.com>
Copy link

sonarcloud bot commented May 21, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@FelixLisczyk
Copy link

Are there any updates on this PR? I would love to use Wake-on-LAN from Moonlight on my Xbox. 😊

@TheElixZammuto TheElixZammuto marked this pull request as draft August 16, 2024 12:45
@truaswild
Copy link

any updates? thanks for helping..

@mpotrykus
Copy link

Any updates? Happy to jump in and take over if there are blocking changes that are not being addressed.

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.

5 participants