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

feat: integrate findlinx with the find command #61

Merged
merged 2 commits into from
Aug 2, 2024

Conversation

damienbutt
Copy link
Contributor

@damienbutt damienbutt commented Aug 2, 2024

Summary by Sourcery

Integrate a new 'find' command to discover NetLinx devices on a local broadcast subnet, update dependencies, and enhance documentation.

New Features:

  • Introduce a new 'find' command to discover NetLinx devices on a local broadcast subnet.

Enhancements:

  • Add 'console-table-printer' and '@commander-js/extra-typings' as new dependencies.
  • Update '@types/node' to version 22.1.0 and 'undici-types' to version 6.13.0.

Documentation:

  • Update README.md and genlinx.1 documentation to include the new 'find' command.

Copy link

sourcery-ai bot commented Aug 2, 2024

Reviewer's Guide by Sourcery

This pull request integrates the 'find' command into the CLI tool, allowing users to discover NetLinx devices on a local broadcast subnet. The implementation includes new classes and types to support this functionality, as well as updates to the documentation and dependencies.

File-Level Changes

Files Changes
lib/Packet.ts
src/actions/find.ts
lib/Device.ts
src/commands/find.ts
lib/@types/Date.ts
lib/@types/FindCliArgs.ts
Implemented the 'find' command and its supporting classes and types for discovering NetLinx devices.
README.md
docs/genlinx.1
docs/genlinx.1.md
Updated documentation to include the new 'find' command.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @damienbutt - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 3 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

});

return new Promise((resolve) => {
setTimeout(() => {
Copy link

Choose a reason for hiding this comment

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

suggestion: Consider making the discovery timeout configurable

The current 6-second timeout might not be sufficient in all network conditions. Consider making this a configurable option, perhaps with a default value of 6 seconds.

setTimeout(() => {
    socket.close();
}, this.config.discoveryTimeout || 6000);

export async function discover(): Promise<Array<Device>> {
const devices: Array<Device> = [];

const socket = dgram.createSocket("udp4");
Copy link

Choose a reason for hiding this comment

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

suggestion: Add error handling for socket operations

Consider adding error handling for socket operations. For example, you could add event listeners for 'error' and 'close' events to handle potential issues gracefully.

Suggested change
const socket = dgram.createSocket("udp4");
const socket = dgram.createSocket("udp4");
socket.on('error', (err) => {
console.error('Socket error:', err);
socket.close();
});
socket.on('close', () => {
console.log('Socket closed');
});


const ICSP_PORT = 1319;

export async function discover(): Promise<Array<Device>> {
Copy link

Choose a reason for hiding this comment

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

suggestion: Consider adding a fallback mechanism for device discovery

The current implementation uses UDP broadcast, which might not work in all network configurations. Consider adding a fallback mechanism or a way to specify IP ranges for more flexible device discovery.

export async function discover(options?: DiscoveryOptions): Promise<Array<Device>> {
    const devices: Array<Device> = [];
    const { useUdp = true, ipRanges = [] } = options || {};

    if (useUdp) {
        devices.push(...await discoverViaUdp());
    }

    for (const range of ipRanges) {
        devices.push(...await discoverViaIpRange(range));
    }

@damienbutt damienbutt merged commit dcbb503 into master Aug 2, 2024
6 checks passed
@damienbutt damienbutt deleted the feature/integrate-findlinx branch August 2, 2024 13:30
Copy link

github-actions bot commented Aug 2, 2024

🎉 This PR is included in version 2.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

1 participant