ignore DNS error when doing migration allow/block check (#19567)
Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
parent
f4729e2418
commit
35a7db49b4
2 changed files with 3 additions and 8 deletions
|
@ -332,7 +332,6 @@ type ErrInvalidCloneAddr struct {
|
||||||
IsProtocolInvalid bool
|
IsProtocolInvalid bool
|
||||||
IsPermissionDenied bool
|
IsPermissionDenied bool
|
||||||
LocalPath bool
|
LocalPath bool
|
||||||
NotResolvedIP bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsErrInvalidCloneAddr checks if an error is a ErrInvalidCloneAddr.
|
// IsErrInvalidCloneAddr checks if an error is a ErrInvalidCloneAddr.
|
||||||
|
@ -342,9 +341,6 @@ func IsErrInvalidCloneAddr(err error) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (err *ErrInvalidCloneAddr) Error() string {
|
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 {
|
if err.IsInvalidPath {
|
||||||
return fmt.Sprintf("migration/cloning from '%s' is not allowed: the provided path is invalid", err.Host)
|
return fmt.Sprintf("migration/cloning from '%s' is not allowed: the provided path is invalid", err.Host)
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,10 +81,9 @@ func IsMigrateURLAllowed(remoteURL string, doer *user_model.User) error {
|
||||||
err = nil //nolint
|
err = nil //nolint
|
||||||
hostName = u.Host
|
hostName = u.Host
|
||||||
}
|
}
|
||||||
addrList, err := net.LookupIP(hostName)
|
|
||||||
if err != nil {
|
// some users only use proxy, there is no DNS resolver. it's safe to ignore the LookupIP error
|
||||||
return &models.ErrInvalidCloneAddr{Host: u.Host, NotResolvedIP: true}
|
addrList, _ := net.LookupIP(hostName)
|
||||||
}
|
|
||||||
|
|
||||||
var ipAllowed bool
|
var ipAllowed bool
|
||||||
var ipBlocked bool
|
var ipBlocked bool
|
||||||
|
|
Loading…
Reference in a new issue