Skip to content

Conversation

@sdb9696
Copy link
Collaborator

@sdb9696 sdb9696 commented Nov 1, 2023

While looking at merged PR #528 I noticed some users were using hostnames to add their devices and the current discover_single will not work with hostnames. This PR does a simple DNS lookup using getaddrinfo if a hostname is used so that it can match to the datagram response ip.

According to the getaddrinfo docs dns lookup only happens if node parameter is a hostname:

node specifies either a
numerical network address (for IPv4, numbers-and-dots notation as
supported by inet_aton(3); for IPv6, hexadecimal string format as
supported by inet_pton(3)), or a network hostname, whose network
addresses are looked up and resolved

@codecov
Copy link

codecov bot commented Nov 1, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Files Coverage Δ
kasa/discover.py 86.06% <93.75%> (+0.99%) ⬆️

📢 Thoughts on this report? Let us know!.

@sdb9696 sdb9696 force-pushed the do_discover_single_dns branch 2 times, most recently from ec98015 to 15b5c85 Compare November 1, 2023 16:36
@sdb9696 sdb9696 requested a review from bdraco November 1, 2023 17:27
Copy link
Member

@rytilahti rytilahti left a comment

Choose a reason for hiding this comment

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

Never realized that this wasn't already working as initializing device instances manually just worked(tm) 👍

@sdb9696 sdb9696 force-pushed the do_discover_single_dns branch from 15b5c85 to 9cf2e81 Compare November 6, 2023 13:28
@sdb9696 sdb9696 requested a review from rytilahti November 6, 2023 13:35
Copy link
Member

@rytilahti rytilahti left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! 🥇

@rytilahti rytilahti added the enhancement New feature or request label Nov 7, 2023
@rytilahti rytilahti merged commit 2650298 into python-kasa:master Nov 7, 2023
@sdb9696 sdb9696 deleted the do_discover_single_dns branch December 6, 2023 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants