From 386522ba22b83537ab547a1dcb8f76a98a28293f Mon Sep 17 00:00:00 2001 From: 9seconds Date: Fri, 13 Sep 2019 10:15:00 +0300 Subject: [PATCH] Correct printable configuration --- cli/proxy.go | 2 +- config/config.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/cli/proxy.go b/cli/proxy.go index bd78832..e8add55 100644 --- a/cli/proxy.go +++ b/cli/proxy.go @@ -42,7 +42,7 @@ func Proxy() error { if err := config.InitPublicAddress(ctx); err != nil { Fatal(err) } - zap.S().Debugw("Configuration", "config", config.C) + zap.S().Debugw("Configuration", "config", config.C.Printable()) if len(config.C.AdTag) > 0 { zap.S().Infow("Use middle proxy connection to Telegram") diff --git a/config/config.go b/config/config.go index d729e8f..f272660 100644 --- a/config/config.go +++ b/config/config.go @@ -137,6 +137,20 @@ type Config struct { AdTag []byte `json:"adtag"` } +func (c Config) Printable() interface{} { + data, err := json.Marshal(c) + if err != nil { + panic(err) + } + + rv := map[string]interface{}{} + if err := json.Unmarshal(data, &rv); err != nil { + panic(err) + } + + return rv +} + func (c Config) String() string { data, _ := json.Marshal(c) return string(data)