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

Replace hostname() function in favor of dns_lookup::lookup_host() #6531

Open
afiune opened this issue May 9, 2019 · 2 comments
Open

Replace hostname() function in favor of dns_lookup::lookup_host() #6531

afiune opened this issue May 9, 2019 · 2 comments
Labels
Focus:Supervisor Related to the Habitat Supervisor (core/hab-sup) component Stale Status:Help Wanted Type:Feature PRs that add a new feature Type: Feature Issues that describe a new desired feature

Comments

@afiune
Copy link

afiune commented May 9, 2019

Habitat already have a function that returns the hostname of the
machine called hostname(), we could explore the possibility of
refactoring that function and replace it for dns_lookup::lookup_host()

afiune pushed a commit that referenced this issue May 15, 2019
From the [`hostname` man page](https://www.systutorials.com/docs/linux/man/1-hostname/):
>The FQDN (Fully Qualified Domain Name) of the system is the
name that the resolver(3) returns for the host name, such as,
**ursula.example.com**.  It is usually the hostname followed by the
DNS domain name (the part  after the first dot).  You can check
the FQDN using `hostname --fqdn` or the domain name using
`dnsdomainname`.

As the man page says it, the FQDN is the combination of the
Hostname and the Domain Name. But technically speaking:
>The FQDN is the name getaddrinfo(3) returns for the
host name returned by gethostname(2). The DNS domain name
is the part after the first dot.

This change is adding two new `core::os::net` functions:
- `lookup_fqdn(hostname)`: returns a vector of fqdn that resolves
the provided hostname.
- `fqdn()`: returns the FQDN (fully qualified domain name) of the
running machine.

These functions are leveraging the [dns-lookup crate](https://docs.rs/dns-lookup/1.0.0/dns_lookup/index.html) that implements
the C function called `getaddrinfo()` that we technically need to get
FQDN of the running machine. 

Habitat already have a function that returns the hostname of the
machine[ called `hostname()`](https://github.com/habitat-sh/habitat/blob/master/components/core/src/os/net/windows.rs#L22), we are leveraging that function inside
the new `fqdn()` one.

I have created an issue #6531 to explore the possibility of refactoring the
existing `hostname()` function in favor of `dns_lookup::lookup_host()`

Signed-off-by: Salim Afiune <afiune@chef.io>
afiune pushed a commit that referenced this issue May 15, 2019
From the [`hostname` man page](https://www.systutorials.com/docs/linux/man/1-hostname/):
>The FQDN (Fully Qualified Domain Name) of the system is the
name that the resolver(3) returns for the host name, such as,
**ursula.example.com**.  It is usually the hostname followed by the
DNS domain name (the part  after the first dot).  You can check
the FQDN using `hostname --fqdn` or the domain name using
`dnsdomainname`.

As the man page says it, the FQDN is the combination of the
Hostname and the Domain Name. But technically speaking:
>The FQDN is the name getaddrinfo(3) returns for the
host name returned by gethostname(2). The DNS domain name
is the part after the first dot.

This change is adding two new `core::os::net` functions:
- `lookup_fqdn(hostname)`: returns a vector of fqdn that resolves
the provided hostname.
- `fqdn()`: returns the FQDN (fully qualified domain name) of the
running machine.

These functions are leveraging the [dns-lookup crate](https://docs.rs/dns-lookup/1.0.0/dns_lookup/index.html) that implements
the C function called `getaddrinfo()` that we technically need to get
FQDN of the running machine.

Habitat already have a function that returns the hostname of the
machine[ called `hostname()`](https://github.com/habitat-sh/habitat/blob/master/components/core/src/os/net/windows.rs#L22), we are leveraging that function inside
the new `fqdn()` one.

I have created an issue #6531 to explore the possibility of refactoring the
existing `hostname()` function in favor of `dns_lookup::lookup_host()`

Signed-off-by: Salim Afiune <afiune@chef.io>
christophermaier pushed a commit that referenced this issue May 17, 2019
From the [`hostname` man page](https://www.systutorials.com/docs/linux/man/1-hostname/):
>The FQDN (Fully Qualified Domain Name) of the system is the
name that the resolver(3) returns for the host name, such as,
**ursula.example.com**.  It is usually the hostname followed by the
DNS domain name (the part  after the first dot).  You can check
the FQDN using `hostname --fqdn` or the domain name using
`dnsdomainname`.

As the man page says it, the FQDN is the combination of the
Hostname and the Domain Name. But technically speaking:
>The FQDN is the name getaddrinfo(3) returns for the
host name returned by gethostname(2). The DNS domain name
is the part after the first dot.

This change is adding two new `core::os::net` functions:
- `lookup_fqdn(hostname)`: returns a vector of fqdn that resolves
the provided hostname.
- `fqdn()`: returns the FQDN (fully qualified domain name) of the
running machine.

These functions are leveraging the [dns-lookup crate](https://docs.rs/dns-lookup/1.0.0/dns_lookup/index.html) that implements
the C function called `getaddrinfo()` that we technically need to get
FQDN of the running machine.

Habitat already have a function that returns the hostname of the
machine[ called `hostname()`](https://github.com/habitat-sh/habitat/blob/master/components/core/src/os/net/windows.rs#L22), we are leveraging that function inside
the new `fqdn()` one.

I have created an issue #6531 to explore the possibility of refactoring the
existing `hostname()` function in favor of `dns_lookup::lookup_host()`

Signed-off-by: Salim Afiune <afiune@chef.io>
@stale
Copy link

stale bot commented May 13, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We value your input and contribution. Please leave a comment if this issue still affects you.

@stale stale bot added the Stale label May 13, 2020
@christophermaier christophermaier added Type:Feature PRs that add a new feature and removed X-feature labels Jul 24, 2020
@stale stale bot removed the Stale label Jul 24, 2020
@christophermaier christophermaier added Focus:Supervisor Related to the Habitat Supervisor (core/hab-sup) component Type: Feature Issues that describe a new desired feature and removed A-supervisor labels Jul 24, 2020
@stale
Copy link

stale bot commented Jul 31, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We value your input and contribution. Please leave a comment if this issue still affects you.

@stale stale bot added the Stale label Jul 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Focus:Supervisor Related to the Habitat Supervisor (core/hab-sup) component Stale Status:Help Wanted Type:Feature PRs that add a new feature Type: Feature Issues that describe a new desired feature
Projects
None yet
Development

No branches or pull requests

5 participants