Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Update discover single to handle hostnames#539

Merged
rytilahti merged 1 commit into
python-kasa:masterpython-kasa/python-kasa:masterfrom
sdb9696:do_discover_single_dnssdb9696/python-kasa:do_discover_single_dnsCopy head branch name to clipboard
Nov 7, 2023
Merged

Update discover single to handle hostnames#539
rytilahti merged 1 commit into
python-kasa:masterpython-kasa/python-kasa:masterfrom
sdb9696:do_discover_single_dnssdb9696/python-kasa:do_discover_single_dnsCopy head branch name to clipboard

Conversation

@sdb9696
Copy link
Copy Markdown
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
Copy Markdown

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!.

Comment thread kasa/discover.py Outdated
@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
Copy Markdown
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) 馃憤

Comment thread kasa/discover.py Outdated
Comment thread kasa/discover.py Outdated
Comment thread kasa/discover.py
Comment thread kasa/discover.py
@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
Copy Markdown
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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.