Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore DNS error when doing migration allow/block check (#19566) #19567

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions models/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ type ErrInvalidCloneAddr struct {
IsProtocolInvalid bool
IsPermissionDenied bool
LocalPath bool
NotResolvedIP bool
}

// IsErrInvalidCloneAddr checks if an error is a ErrInvalidCloneAddr.
Expand All @@ -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)
}
Expand Down
7 changes: 3 additions & 4 deletions services/migrations/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down