Skip to content

Commit

Permalink
fix(): 解决docker检测网络问题
Browse files Browse the repository at this point in the history
  • Loading branch information
onlyLTY committed Oct 30, 2024
1 parent 2ec04b7 commit 644a274
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/module/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const ChallengeHeader = "WWW-Authenticate"
const (
DefaultRegistryDomain = "docker.io"
DefaultRegistryHost = "index.docker.io"
DefaultAcceleratorHost = "qazxsw.msaber.fun"
DefaultAcceleratorHost = "docker.ketches.cn"
)

func GetToken(image types.Image, registryAuth string) (string, error) {
Expand Down Expand Up @@ -172,7 +172,7 @@ func GetRegistryAddress(imageRef string) (string, error) {
}

func checkHost(host string) bool {
URL := "https://" + host
URL := "https://" + host + "/v2/"
// 创建带有超时设置的 http.Client
client := http.Client{
Timeout: 5 * time.Second,
Expand All @@ -191,7 +191,7 @@ func checkHost(host string) bool {
}(resp.Body)

// 检查 HTTP 响应状态码
if resp.StatusCode == http.StatusOK {
if resp.StatusCode == http.StatusOK || resp.StatusCode == http.StatusUnauthorized {
return true
}

Expand Down

0 comments on commit 644a274

Please sign in to comment.