From 03f9f81cb5f71b07f314d8c860bb485c7193adc4 Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Mon, 3 Sep 2018 13:17:53 -0700 Subject: [PATCH] fixup 3d8e552c6aa5b134932c1839f812571a96c6870f: validate streamrpc config in factory constructors --- daemon/connecter/connecter.go | 6 +++++- daemon/streamrpcconfig/streamrpcconfig.go | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/daemon/connecter/connecter.go b/daemon/connecter/connecter.go index e6803ce..c26d1de 100644 --- a/daemon/connecter/connecter.go +++ b/daemon/connecter/connecter.go @@ -34,7 +34,11 @@ func FromConfig(g *config.Global, in config.ConnectEnum) (*ClientFactory, error) return nil, errRPC } - return &ClientFactory{connecter: connecter, config: &streamrpc.ClientConfig{connConf}}, nil + config := streamrpc.ClientConfig{connConf} + if err := config.Validate(); err != nil { + return nil, err + } + return &ClientFactory{connecter: connecter, config: &config}, nil } type ClientFactory struct { diff --git a/daemon/streamrpcconfig/streamrpcconfig.go b/daemon/streamrpcconfig/streamrpcconfig.go index 3292577..8dc64f6 100644 --- a/daemon/streamrpcconfig/streamrpcconfig.go +++ b/daemon/streamrpcconfig/streamrpcconfig.go @@ -10,7 +10,7 @@ func FromDaemonConfig(g *config.Global, in *config.RPCConfig) (*streamrpc.ConnCo if conf == nil { conf = g.RPC } - return &streamrpc.ConnConfig{ + srpcConf := &streamrpc.ConnConfig{ RxHeaderMaxLen: conf.RxHeaderMaxLen, RxStructuredMaxLen: conf.RxStructuredMaxLen, RxStreamMaxChunkSize: conf.RxStreamChunkMaxLen, @@ -18,5 +18,9 @@ func FromDaemonConfig(g *config.Global, in *config.RPCConfig) (*streamrpc.ConnCo Timeout: streamrpc.Timeout{ Progress: conf.Timeout, }, - }, nil + } + if err := srpcConf.Validate(); err != nil { + return nil, err + } + return srpcConf, nil }