feat: self-updating using gitee (#39)

* feat: self-updating using gitee

* chore: rename

---------

Co-authored-by: naiba <[email protected]>
This commit is contained in:
UUBulb
2024-07-14 11:19:59 +08:00
committed by GitHub
co-authored by naiba
parent f02d1ee04e
commit 1344fc3dd8
5 changed files with 38 additions and 9 deletions
+1 -1
View File
@@ -154,7 +154,7 @@ func GetHost() *model.Host {
cachedBootTime = time.Unix(int64(hi.BootTime), 0)
ret.IP = CachedIP
ret.CountryCode = strings.ToLower(cachedCountry)
ret.CountryCode = strings.ToLower(CachedCountry)
ret.Version = Version
return &ret
+10 -3
View File
@@ -48,7 +48,8 @@ var (
// "https://ip.seeip.org/geoip", // 不精确
// "https://freegeoip.app/json/", // 需要 Key
}
CachedIP, cachedCountry string
CachedIP, CachedCountry string
Sync = make(chan bool)
httpClientV4 = util.NewSingleStackHTTPClient(time.Second*20, time.Second*5, time.Second*10, false)
httpClientV6 = util.NewSingleStackHTTPClient(time.Second*20, time.Second*5, time.Second*10, true)
)
@@ -81,10 +82,16 @@ func UpdateIP(logging bool, useIPv6CountryCode bool, period uint32) {
}
if primaryIP.CountryCode != "" {
cachedCountry = primaryIP.CountryCode
CachedCountry = primaryIP.CountryCode
} else if secondaryIP.CountryCode != "" {
cachedCountry = secondaryIP.CountryCode
CachedCountry = secondaryIP.CountryCode
}
select {
case Sync <- true:
default:
}
time.Sleep(time.Second * time.Duration(period))
}
}