mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-20 05:13:11 -06:00
adds support for defining an proxy for the http client within the config
This commit is contained in:
parent
f223da2f35
commit
d0533c45b4
|
|
@ -20,6 +20,7 @@ import (
|
|||
"net/http"
|
||||
"net/url"
|
||||
"time"
|
||||
"fmt"
|
||||
|
||||
"golang.org/x/crypto/ed25519"
|
||||
|
||||
|
|
@ -95,6 +96,14 @@ func NewBaseDendrite(cfg *config.Dendrite, componentName string, enableHTTPAPIs
|
|||
logrus.WithError(err).Warnf("Failed to create cache")
|
||||
}
|
||||
|
||||
client := http.Client{Timeout: HTTPClientTimeout}
|
||||
if cfg.Proxy != nil {
|
||||
client.Transport = &http.Transport{Proxy: http.ProxyURL(&url.URL {
|
||||
Scheme: cfg.Proxy.Protocol,
|
||||
Host: fmt.Sprintf("%s:%d", cfg.Proxy.Host, cfg.Proxy.Port),
|
||||
})}
|
||||
}
|
||||
|
||||
return &BaseDendrite{
|
||||
componentName: componentName,
|
||||
EnableHTTPAPIs: enableHTTPAPIs,
|
||||
|
|
@ -102,7 +111,7 @@ func NewBaseDendrite(cfg *config.Dendrite, componentName string, enableHTTPAPIs
|
|||
Cfg: cfg,
|
||||
ImmutableCache: cache,
|
||||
APIMux: mux.NewRouter().UseEncodedPath(),
|
||||
httpClient: &http.Client{Timeout: HTTPClientTimeout},
|
||||
httpClient: &client,
|
||||
KafkaConsumer: kafkaConsumer,
|
||||
KafkaProducer: kafkaProducer,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -264,6 +264,12 @@ type Dendrite struct {
|
|||
// The config for logging informations. Each hook will be added to logrus.
|
||||
Logging []LogrusHook `yaml:"logging"`
|
||||
|
||||
Proxy *struct {
|
||||
Protocol string `yaml:"protocol"`
|
||||
Host string `yaml:"host"`
|
||||
Port uint16 `yaml:"port"`
|
||||
} `yaml:"proxy"`
|
||||
|
||||
// Any information derived from the configuration options for later use.
|
||||
Derived struct {
|
||||
Registration struct {
|
||||
|
|
|
|||
Loading…
Reference in a new issue