Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/step-security/hard…
Browse files Browse the repository at this point in the history
…en-runner-2.9.1
  • Loading branch information
madhavilosetty-intel authored Aug 6, 2024
2 parents c5e3eae + a94d96e commit 24548b0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [2.36.2](https://github.com/open-amt-cloud-toolkit/rpc-go/compare/v2.36.1...v2.36.2) (2024-08-06)


### Bug Fixes

* **cli:** Resolve FQDN on Linux machines with short hostnames ([#600](https://github.com/open-amt-cloud-toolkit/rpc-go/issues/600)) ([a2df614](https://github.com/open-amt-cloud-toolkit/rpc-go/commit/a2df61462461028ce32e0270029bb54a725f66af)), closes [#189](https://github.com/open-amt-cloud-toolkit/rpc-go/issues/189)

## [2.36.1](https://github.com/open-amt-cloud-toolkit/rpc-go/compare/v2.36.0...v2.36.1) (2024-07-17)


Expand Down
30 changes: 27 additions & 3 deletions internal/amt/linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,42 @@
package amt

import (
"net"
"os"
"strings"
)

func (amt AMTCommand) GetOSDNSSuffix() (string, error) {
hostname, err := os.Hostname()
fqdn, err := getFQDN()
if err != nil {
return "", err
}
splitName := strings.SplitAfterN(hostname, ".", 2)
splitName := strings.SplitAfterN(fqdn, ".", 2)
if len(splitName) == 2 {
return splitName[1], nil
}
return hostname, err
return fqdn, err
}

func getFQDN() (string, error) {
hostname, err := os.Hostname()
if err != nil {
return "", err
}

if strings.Contains(hostname, ".") {
return hostname, nil
}

addrs, err := net.LookupHost(hostname)
if err != nil {
return "", err
}

names, err := net.LookupAddr(addrs[0])
if err != nil {
return "", err
}

return strings.TrimSuffix(names[0], "."), nil
}

0 comments on commit 24548b0

Please sign in to comment.