Skip to content

Commit 71bafa0

Browse files
wxiaoguang6543
andauthored
ignore DNS error when doing migration allow/block check (#19566)
Co-authored-by: 6543 <[email protected]>
1 parent 05234ad commit 71bafa0

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

models/error.go

-4
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,6 @@ type ErrInvalidCloneAddr struct {
296296
IsProtocolInvalid bool
297297
IsPermissionDenied bool
298298
LocalPath bool
299-
NotResolvedIP bool
300299
}
301300

302301
// IsErrInvalidCloneAddr checks if an error is a ErrInvalidCloneAddr.
@@ -306,9 +305,6 @@ func IsErrInvalidCloneAddr(err error) bool {
306305
}
307306

308307
func (err *ErrInvalidCloneAddr) Error() string {
309-
if err.NotResolvedIP {
310-
return fmt.Sprintf("migration/cloning from '%s' is not allowed: unknown hostname", err.Host)
311-
}
312308
if err.IsInvalidPath {
313309
return fmt.Sprintf("migration/cloning from '%s' is not allowed: the provided path is invalid", err.Host)
314310
}

services/migrations/migrate.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,9 @@ func IsMigrateURLAllowed(remoteURL string, doer *user_model.User) error {
8181
err = nil //nolint
8282
hostName = u.Host
8383
}
84-
addrList, err := net.LookupIP(hostName)
85-
if err != nil {
86-
return &models.ErrInvalidCloneAddr{Host: u.Host, NotResolvedIP: true}
87-
}
84+
85+
// some users only use proxy, there is no DNS resolver. it's safe to ignore the LookupIP error
86+
addrList, _ := net.LookupIP(hostName)
8887

8988
var ipAllowed bool
9089
var ipBlocked bool

0 commit comments

Comments
 (0)