Skip to content

Commit 125679f

Browse files
authored
Support allowed hosts for migrations to work with proxy (#32025)
1 parent def1c96 commit 125679f

File tree

4 files changed

+3
-11
lines changed

4 files changed

+3
-11
lines changed

modules/hostmatcher/http.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ import (
1313
)
1414

1515
// NewDialContext returns a DialContext for Transport, the DialContext will do allow/block list check
16-
func NewDialContext(usage string, allowList, blockList *HostMatchList) func(ctx context.Context, network, addr string) (net.Conn, error) {
17-
return NewDialContextWithProxy(usage, allowList, blockList, nil)
18-
}
19-
20-
func NewDialContextWithProxy(usage string, allowList, blockList *HostMatchList, proxy *url.URL) func(ctx context.Context, network, addr string) (net.Conn, error) {
16+
func NewDialContext(usage string, allowList, blockList *HostMatchList, proxy *url.URL) func(ctx context.Context, network, addr string) (net.Conn, error) {
2117
// How Go HTTP Client works with redirection:
2218
// transport.RoundTrip URL=http://domain.com, Host=domain.com
2319
// transport.DialContext addrOrHost=domain.com:80

services/migrations/http_client.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ func NewMigrationHTTPTransport() *http.Transport {
2424
return &http.Transport{
2525
TLSClientConfig: &tls.Config{InsecureSkipVerify: setting.Migrations.SkipTLSVerify},
2626
Proxy: proxy.Proxy(),
27-
DialContext: hostmatcher.NewDialContext("migration", allowList, blockList),
27+
DialContext: hostmatcher.NewDialContext("migration", allowList, blockList, setting.Proxy.ProxyURLFixed),
2828
}
2929
}

services/migrations/migrate.go

-4
Original file line numberDiff line numberDiff line change
@@ -499,9 +499,5 @@ func Init() error {
499499
// TODO: at the moment, if ALLOW_LOCALNETWORKS=false, ALLOWED_DOMAINS=domain.com, and domain.com has IP 127.0.0.1, then it's still allowed.
500500
// if we want to block such case, the private&loopback should be added to the blockList when ALLOW_LOCALNETWORKS=false
501501

502-
if setting.Proxy.Enabled && setting.Proxy.ProxyURLFixed != nil {
503-
allowList.AppendPattern(setting.Proxy.ProxyURLFixed.Host)
504-
}
505-
506502
return nil
507503
}

services/webhook/deliver.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ func Init() error {
303303
Transport: &http.Transport{
304304
TLSClientConfig: &tls.Config{InsecureSkipVerify: setting.Webhook.SkipTLSVerify},
305305
Proxy: webhookProxy(allowedHostMatcher),
306-
DialContext: hostmatcher.NewDialContextWithProxy("webhook", allowedHostMatcher, nil, setting.Webhook.ProxyURLFixed),
306+
DialContext: hostmatcher.NewDialContext("webhook", allowedHostMatcher, nil, setting.Webhook.ProxyURLFixed),
307307
},
308308
}
309309

0 commit comments

Comments
 (0)