-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #380 from projectdiscovery/update-os-pdtm-param
add os vendor support for linux
- Loading branch information
Showing
6 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//go:build !linux | ||
// +build !linux | ||
|
||
package updateutils | ||
|
||
import ( | ||
"encoding/base64" | ||
"runtime" | ||
"strings" | ||
) | ||
|
||
// Get OS Vendor returns the linux distribution vendor | ||
// if not linux then returns runtime.GOOS | ||
func GetOSVendor() string { | ||
return runtime.GOOS | ||
} | ||
|
||
// returns platform metadata | ||
func getPlatformMetadata() string { | ||
tmp := runtime.GOOS + "|" + runtime.GOARCH | ||
return strings.TrimSuffix(base64.StdEncoding.EncodeToString([]byte(tmp)), "==") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//go:build linux | ||
// +build linux | ||
|
||
package updateutils | ||
|
||
import ( | ||
"encoding/base64" | ||
"runtime" | ||
"strings" | ||
|
||
"github.com/zcalusic/sysinfo" | ||
) | ||
|
||
// Get OS Vendor returns the linux distribution vendor | ||
// if not linux then returns runtime.GOOS | ||
func GetOSVendor() string { | ||
var si sysinfo.SysInfo | ||
si.GetSysInfo() | ||
return si.OS.Vendor | ||
} | ||
|
||
// returns platform metadata | ||
func getPlatformMetadata() string { | ||
var si sysinfo.SysInfo | ||
si.GetSysInfo() | ||
tmp := strings.ReplaceAll(si.Board.Vendor, " ", "_") + "|" + strings.ReplaceAll(si.Board.Name, " ", "_") | ||
if tmp == "|" { | ||
// instead of just empty string return os for more context | ||
tmp = runtime.GOOS + "|" + runtime.GOARCH | ||
} | ||
return strings.TrimSuffix(base64.StdEncoding.EncodeToString([]byte(tmp)), "==") | ||
} |