CreateClient creates a new client (normally used for media fetch requests). Should only be called once per component.
()
| 329 | // CreateClient creates a new client (normally used for media fetch requests). |
| 330 | // Should only be called once per component. |
| 331 | func (b *BaseDendrite) CreateClient() *gomatrixserverlib.Client { |
| 332 | if b.Cfg.Global.DisableFederation { |
| 333 | return gomatrixserverlib.NewClient( |
| 334 | gomatrixserverlib.WithTransport(noOpHTTPTransport), |
| 335 | ) |
| 336 | } |
| 337 | opts := []gomatrixserverlib.ClientOption{ |
| 338 | gomatrixserverlib.WithSkipVerify(b.Cfg.FederationAPI.DisableTLSValidation), |
| 339 | gomatrixserverlib.WithWellKnownSRVLookups(false), |
| 340 | } |
| 341 | if b.Cfg.Global.DNSCache.Enabled { |
| 342 | opts = append(opts, gomatrixserverlib.WithDNSCache(b.DNSCache)) |
| 343 | } |
| 344 | client := gomatrixserverlib.NewClient(opts...) |
| 345 | client.SetUserAgent(fmt.Sprintf("Dendrite/%s", internal.VersionString())) |
| 346 | return client |
| 347 | } |
| 348 | |
| 349 | // CreateFederationClient creates a new federation client. Should only be called |
| 350 | // once per component. |