-
Notifications
You must be signed in to change notification settings - Fork 136
Fix socket.gethostbyaddr(ip) error when no reverse DNS available. #4094
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
base: main
Are you sure you want to change the base?
Conversation
For ip addresses without reverse DNS, socket.gethostbyaddr(ip) will fail. We can simply use ip address for hostname display.
Thanks for opening a Pull Request. If you want to perform a review write a comment saying: @ansys-reviewer-bot review |
Reviewer's GuideRevises the hostname resolution logic to avoid socket.gethostbyaddr failures by using the IP address directly when no reverse DNS is available. Class diagram for updated hostname resolution in mapdl_grpc.pyclassDiagram
class MapdlGrpc {
- _hostname
__init__(ip)
}
MapdlGrpc : __init__() sets _hostname to "localhost" if ip in ["127.0.0.1", "127.0.1.1", "localhost"]
MapdlGrpc : __init__() sets _hostname to ip otherwise
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @yeguang-xue - I've reviewed your changes - here's some feedback:
- Consider wrapping socket.gethostbyaddr in a try/except so you still attempt reverse DNS and only fall back to the raw IP when lookup fails.
- It might be helpful to emit a warning or log entry when DNS resolution fails, so users can more easily diagnose hostname lookup issues.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider wrapping socket.gethostbyaddr in a try/except so you still attempt reverse DNS and only fall back to the raw IP when lookup fails.
- It might be helpful to emit a warning or log entry when DNS resolution fails, so users can more easily diagnose hostname lookup issues.
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
for more information, see https://pre-commit.ci
Description
For ip addresses without reverse DNS, socket.gethostbyaddr(ip) will fail. We can simply use ip address for hostname display.
Issue linked
Please mention the issue number or describe the problem this pull request addresses.
Checklist
draft
if it is not ready to be reviewed yet.feat: adding new MAPDL command
)Summary by Sourcery
Bug Fixes: