1
0
mirror of https://github.com/fumiama/terasu.git synced 2026-06-10 21:24:46 +08:00

feat: new implementations

This commit is contained in:
源文雨
2024-04-19 00:12:45 +09:00
parent b7e45bc58e
commit 719e0c1683
15 changed files with 682 additions and 162 deletions

28
ip/ipv6.go Normal file
View File

@@ -0,0 +1,28 @@
package ip
import (
"context"
"net/http"
"time"
"github.com/RomiChan/syncx"
)
var IsIPv6Available = syncx.Lazy[bool]{Init: func() bool {
ctx, cancel := context.WithTimeout(context.Background(), 4*time.Second)
defer cancel()
req, err := http.NewRequestWithContext(ctx, "GET", "http://v6.ipv6-test.com/json/widgetdata.php?callback=?", nil)
if err != nil {
return false
}
resp, err := http.DefaultClient.Do(req)
if err != nil {
return false
}
_ = resp.Body.Close()
return true
}}
func init() {
go IsIPv6Available.Get()
}