GODT-1816: Connect Gluon Logs to bridge Logs

Ensure the IMAP commands and SMTP commands are logged to trace channels
with an entry so they are recognizable as before.
This commit is contained in:
Leander Beernaert
2022-10-11 16:03:28 +02:00
committed by James Houlahan
parent 03e14154a6
commit f01c70e506
10 changed files with 136 additions and 19 deletions

View File

@ -32,6 +32,9 @@ const (
flagNoWindow = "no-window"
flagNonInteractive = "non-interactive"
flagLogIMAP = "log-imap"
flagLogSMTP = "log-smtp"
)
const (
@ -69,6 +72,14 @@ func New() *cli.App {
Usage: "Don't show window after start",
Hidden: true,
},
&cli.StringFlag{
Name: flagLogIMAP,
Usage: "Enable logging of IMAP communications (all|client|server) (may contain decrypted data!)",
},
&cli.BoolFlag{
Name: flagLogSMTP,
Usage: "Enable logging of SMTP communications (may contain decrypted data!)",
},
}
app.Action = run
@ -124,7 +135,7 @@ func run(c *cli.Context) error {
}
// Create the bridge.
bridge, err := newBridge(locations, identifier)
bridge, err := newBridge(c, locations, identifier)
if err != nil {
return fmt.Errorf("could not create bridge: %w", err)
}

View File

@ -3,6 +3,7 @@ package app
import (
"encoding/base64"
"fmt"
"github.com/urfave/cli/v2"
"os"
"runtime"
@ -25,7 +26,7 @@ import (
const vaultSecretName = "bridge-vault-key"
func newBridge(locations *locations.Locations, identifier *useragent.UserAgent) (*bridge.Bridge, error) {
func newBridge(c *cli.Context, locations *locations.Locations, identifier *useragent.UserAgent) (*bridge.Bridge, error) {
// Create the underlying dialer used by the bridge.
// It only connects to trusted servers and reports any untrusted servers it finds.
pinningDialer := dialer.NewPinningTLSDialer(
@ -92,6 +93,9 @@ func newBridge(locations *locations.Locations, identifier *useragent.UserAgent)
autostarter,
updater,
version,
c.String(flagLogIMAP) == "client" || c.String(flagLogIMAP) == "all",
c.String(flagLogIMAP) == "server" || c.String(flagLogIMAP) == "all",
c.Bool(flagLogSMTP),
)
if err != nil {
return nil, fmt.Errorf("could not create bridge: %w", err)