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

Changed detection of running processes. #8785

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

barankyle
Copy link
Member

@barankyle barankyle commented Sep 14, 2023

Summary

detect-port does not detect UDP processes running on a port. Switched to running lsof and searching through its outputs to determine if a port is in use.

References

closes #8464

Checklist

  • If this PR is still a WIP, convert to a draft
  • When this PR is ready, mark it as "Ready for review"
  • ensure all checks pass
  • Changes have been manually QA'd
  • Changes reviewed by at least 2 approved reviewer

QA Steps

List any additional steps required to QA the changes of this PR, as well as any supplemental images or videos.

🤖 Generated by Copilot at 88e303b

Summary

🗑️🔧🔄

Removed the detect-port dependency and used the lsof command instead for port checking in the instance server. Fixed a typo in the WebRTCFunctions.ts file.

No more detect-port
lsof checks ports for WebRTC
A winter cleanup

Walkthrough

  • Removed detect-port dependency from instanceserver package (link)
  • Replaced detect import with exec import from child_process module in WebRTCFunctions.ts (link)
  • Added promisify import from util module in WebRTCFunctions.ts to convert exec to a promise-based function (link)
  • Modified getNewOffset function in WebRTCFunctions.ts to take lsofResult as an additional parameter and search for port number in it instead of using detect (link)
  • Declared and assigned lsofResult variable in WebRTCFunctions.ts to store the output of execAsync function that runs lsof command to list open ports (link)
  • Updated webRtcServerOptions object in WebRTCFunctions.ts to use ip property instead of ipAddress and pass lsofResult.stdout to getNewOffset function calls (link)

detect-port does not detect UDP processes running on a port. Switched
to running lsof and searching through its outputs to determine if a
port is in use.
return getNewOffset(ipAddress, startPort, i, offset + 1)
const execAsync = promisify(exec)

const getNewOffset = async (ipAddress, startPort, i, offset, lsofResult) => {
Copy link
Member

Choose a reason for hiding this comment

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

function is now synchronous so should be specified as such

@@ -93,6 +95,7 @@ export async function startWebRTC() {
const workers = [] as Worker[]
//This is used in case ports in the range to use are in use by something else
let offset = 0
const lsofResult = await execAsync(`lsof -i -P -n | cat`)
Copy link
Member

Choose a reason for hiding this comment

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

will this work on windows and mac?

Copy link
Member Author

Choose a reason for hiding this comment

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

That is a very good point 🧐

@HexaField HexaField marked this pull request as draft October 17, 2023 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: detect-port does not detect if a UDP service is running on the port
2 participants