mirror of
https://github.com/netbirdio/netbird.git
synced 2025-03-04 18:01:13 +01:00
26 lines
443 B
Go
26 lines
443 B
Go
|
package detect_cloud
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"net/http"
|
||
|
)
|
||
|
|
||
|
func detectGCP(ctx context.Context) string {
|
||
|
req, err := http.NewRequestWithContext(ctx, "GET", "http://metadata.google.internal", nil)
|
||
|
if err != nil {
|
||
|
return ""
|
||
|
}
|
||
|
req.Header.Add("Metadata-Flavor", "Google")
|
||
|
|
||
|
resp, err := hc.Do(req)
|
||
|
if err != nil {
|
||
|
return ""
|
||
|
}
|
||
|
defer resp.Body.Close()
|
||
|
|
||
|
if resp.StatusCode == http.StatusOK {
|
||
|
return "Google Cloud Platform"
|
||
|
}
|
||
|
return ""
|
||
|
}
|