Add detection for Alibaba Cloud

This commit is contained in:
Nikhil Prabhu
2023-07-16 20:19:50 +05:30
parent 50bebf7387
commit 7ebfab2ae4
2 changed files with 30 additions and 9 deletions
+13
View File
@@ -0,0 +1,13 @@
package libdetectcloud
import (
"net/http"
)
func detectAlibabaCloud() string {
resp, err := hc.Get("http://100.100.100.200/latest/")
if err == nil && resp.StatusCode == http.StatusOK {
return "Alibaba Cloud"
}
return ""
}
+17 -9
View File
@@ -11,14 +11,15 @@ var hc = &http.Client{Timeout: 300 * time.Millisecond}
// Clouds type
type Clouds struct {
Aws string
Azure string
Do string
Gce string
Ost string
Sl string
Vr string
Container string
AlibabaCloud string
Aws string
Azure string
Do string
Gce string
Ost string
Sl string
Vr string
Container string
}
// Detect function
@@ -26,7 +27,11 @@ func Detect() string {
if runtime.GOOS != "darwin" {
var c Clouds
var wg sync.WaitGroup
wg.Add(8)
wg.Add(9)
go func() {
defer wg.Done()
c.AlibabaCloud = detectAlibabaCloud()
}()
go func() {
defer wg.Done()
c.Aws = detectAWS()
@@ -61,6 +66,9 @@ func Detect() string {
}()
wg.Wait()
if c.AlibabaCloud != "" {
return c.AlibabaCloud
}
if c.Aws != "" {
return c.Aws
}