proxy: use wherever http.Client is, update mautrix

Added a new common.ConfigurableTransport interface which mediabrowser,
ombi, jellyseer, discord, telegram and matrix (i.e.
ThirdPartService/ContactMethodLinker) now all implement. proxies are
bound to them in main.go, Email is still a special case (but from the
previous commit, mailgun does use the proxy).

mautrix/go has been updated, and context.TODO()s stuck everywhere since
I still don't really comprehend why I should use them (FIXME literally).
This commit is contained in:
Harvey Tindall
2024-08-09 21:40:03 +01:00
parent a52dd26ec6
commit 86c7551ff8
15 changed files with 281 additions and 263 deletions
+12 -4
View File
@@ -426,10 +426,6 @@ func start(asDaemon, firstCall bool) {
app.jf.Verbose = true
}
if app.proxyEnabled {
app.jf.SetTransport(app.proxyTransport)
}
var status int
retryOpts := mediabrowser.MustAuthenticateOptions{
RetryCount: app.config.Section("advanced").Key("auth_retry_count").MustInt(6),
@@ -463,6 +459,7 @@ func start(asDaemon, firstCall bool) {
}
// Since email depends on language, the email reload in loadConfig won't work first time.
// Email also handles its own proxying, as (SMTP atleast) doesn't use a HTTP transport.
app.email = NewEmailer(app)
app.loadStrftime()
@@ -520,6 +517,7 @@ func start(asDaemon, firstCall bool) {
// NOTE: The order in which these are placed in app.contactMethods matters.
// Add new ones to the end.
// FIXME: Add proxies.
if discordEnabled {
app.discord, err = newDiscordDaemon(app)
if err != nil {
@@ -556,6 +554,16 @@ func start(asDaemon, firstCall bool) {
app.contactMethods = append(app.contactMethods, app.matrix)
}
}
if app.proxyEnabled {
app.jf.SetTransport(app.proxyTransport)
for _, c := range app.thirdPartyServices {
c.SetTransport(app.proxyTransport)
}
for _, c := range app.contactMethods {
c.SetTransport(app.proxyTransport)
}
}
} else {
debugMode = false
if *PORT != app.port && *PORT > 0 {