From 9d812ab865bd246fa967efaa35707e8b51f5199a Mon Sep 17 00:00:00 2001 From: Roy Lee Date: Mon, 11 Jul 2022 16:22:35 -0700 Subject: [PATCH] [lbry] config: allow non-localhost connections with TLS disabled --- config.go | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/config.go b/config.go index a092f4b..1199360 100644 --- a/config.go +++ b/config.go @@ -568,17 +568,7 @@ func loadConfig() (*config, []string, error) { if err != nil { return nil, nil, err } - if cfg.DisableClientTLS { - if _, ok := localhostListeners[RPCHost]; !ok { - str := "%s: the --noclienttls option may not be used " + - "when connecting RPC to non localhost " + - "addresses: %s" - err := fmt.Errorf(str, funcName, cfg.RPCConnect) - fmt.Fprintln(os.Stderr, err) - fmt.Fprintln(os.Stderr, usageMessage) - return nil, nil, err - } - } else { + if !cfg.DisableClientTLS { // If CAFile is unset, choose either the copy or local lbcd cert. if !cfg.CAFile.ExplicitlySet() { cfg.CAFile.Value = filepath.Join(cfg.AppDataDir.Value, defaultCAFilename) @@ -664,7 +654,7 @@ func loadConfig() (*config, []string, error) { allListeners := append(cfg.LegacyRPCListeners, cfg.ExperimentalRPCListeners...) for _, addr := range allListeners { - host, _, err := net.SplitHostPort(addr) + _, _, err := net.SplitHostPort(addr) if err != nil { str := "%s: RPC listen interface '%s' is " + "invalid: %v" @@ -673,15 +663,6 @@ func loadConfig() (*config, []string, error) { fmt.Fprintln(os.Stderr, usageMessage) return nil, nil, err } - if _, ok := localhostListeners[host]; !ok { - str := "%s: the --noservertls option may not be used " + - "when binding RPC to non localhost " + - "addresses: %s" - err := fmt.Errorf(str, funcName, addr) - fmt.Fprintln(os.Stderr, err) - fmt.Fprintln(os.Stderr, usageMessage) - return nil, nil, err - } } }