Skip to content

On windows, in some cases, NetworkParams.getHostName() return localhost #1006

Closed
@jflefebvre06

Description

@jflefebvre06

On windows, getHostName() should use Kernel32Util.getComputerName().

See https://github.com/mattsheppard/gethostname4j

Activity

added
compatibilityExtending OSHI compatibility to OSs or versions
good first issueGood issues for new contributors to work on
on Oct 3, 2019
dbwiddis

dbwiddis commented on Oct 4, 2019

@dbwiddis
Member

I'm marking this issue for first-timers-only. That means that I will only accept a PR for this one from someone who's never contributed to open source before. This one is easy (but don't make that statement make you feel bad if you have a hard time with it, there's more to contributing to open source than changing lines of code, especially if it's your first time). I'll hold your hand through this if you need me to. :-)

Per the report above, the WindowsNetworkParams implementation should return the (unambiguous) Windows computer name rather than the result of InetAddress.getLocalHost().getHostName().

Here are the steps to get a PR merged here.

  • Read the CONTRIBUTING file for reference. I'll walk you through anything you don't understand.
  • Fork the project to your own GitHub account, make a local clone, and create a branch for your submission.
  • In the WindowsNetworkParams class, override the getHostName() method and return the value from Kernel32Util.getComputerName().
  • Optionally, override the Mac, Linux, Solaris, and BSD versions of the method to return the result from the respective platform's LibC class (eventually inheriting from JNA's LibCAPI) method getHostName().
  • Commit your changes, push to to your GitHub fork, and create a Pull Request
  • Respond to the usually minor comments on code review
  • Celebrate! 🎉
2kindsofcs

2kindsofcs commented on Oct 5, 2019

@2kindsofcs
Contributor

I'd like to take this issue. thanks for kind, well-described comment.

dbwiddis

dbwiddis commented on Oct 5, 2019

@dbwiddis
Member

It's yours! Let me know if you need any help.

changed the title On windows, in some case, new SystemInfo().getOperatingSystem().getNetworkParams().getHostName() return localhost On windows, in some cases, NetworkParams.getHostName() return localhost on Oct 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

compatibilityExtending OSHI compatibility to OSs or versionsfirst-timers-onlyIssues reserved for brand new GitHub usersgood first issueGood issues for new contributors to work on

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    On windows, in some cases, NetworkParams.getHostName() return localhost · Issue #1006 · oshi/oshi