aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2022-05-02 13:11:45 +0800
committerGitHub <noreply@github.com>2022-05-02 08:11:45 +0300
commit35a7db49b49b748496993bd7dc142c63cf573d10 (patch)
tree67e62dc1ce2206983c6731bc243aca4f9805b91a
parentf4729e241827574ba7ccedc48729487a527ddbae (diff)
downloadgitea-35a7db49b49b748496993bd7dc142c63cf573d10.tar.gz
gitea-35a7db49b49b748496993bd7dc142c63cf573d10.zip
ignore DNS error when doing migration allow/block check (#19567)
Co-authored-by: Lauris BH <lauris@nix.lv>
-rw-r--r--models/error.go4
-rw-r--r--services/migrations/migrate.go7
2 files changed, 3 insertions, 8 deletions
diff --git a/models/error.go b/models/error.go
index f0e8751d75..1d0f658eb8 100644
--- a/models/error.go
+++ b/models/error.go
@@ -332,7 +332,6 @@ type ErrInvalidCloneAddr struct {
IsProtocolInvalid bool
IsPermissionDenied bool
LocalPath bool
- NotResolvedIP bool
}
// IsErrInvalidCloneAddr checks if an error is a ErrInvalidCloneAddr.
@@ -342,9 +341,6 @@ func IsErrInvalidCloneAddr(err error) bool {
}
func (err *ErrInvalidCloneAddr) Error() string {
- if err.NotResolvedIP {
- return fmt.Sprintf("migration/cloning from '%s' is not allowed: unknown hostname", err.Host)
- }
if err.IsInvalidPath {
return fmt.Sprintf("migration/cloning from '%s' is not allowed: the provided path is invalid", err.Host)
}
diff --git a/services/migrations/migrate.go b/services/migrations/migrate.go
index 65ecceddbe..c07edfb8c0 100644
--- a/services/migrations/migrate.go
+++ b/services/migrations/migrate.go
@@ -81,10 +81,9 @@ func IsMigrateURLAllowed(remoteURL string, doer *user_model.User) error {
err = nil //nolint
hostName = u.Host
}
- addrList, err := net.LookupIP(hostName)
- if err != nil {
- return &models.ErrInvalidCloneAddr{Host: u.Host, NotResolvedIP: true}
- }
+
+ // some users only use proxy, there is no DNS resolver. it's safe to ignore the LookupIP error
+ addrList, _ := net.LookupIP(hostName)
var ipAllowed bool
var ipBlocked bool