diff --git a/client.go b/client.go index df2fd22..a67b332 100644 --- a/client.go +++ b/client.go @@ -227,6 +227,10 @@ type ClientConfig struct { // If this is 0, then the default of 64KB is used. PluginLogBufferSize int + // ClientScanerBufferSize is the buffer size(bytes) to read from stderr for plugin log lines. + // If this is 0, then the default of 64KB is used. + ClientScanerBufferSize int + // AutoMTLS has the client and server automatically negotiate mTLS for // transport authentication. This ensures that only the original client will // be allowed to connect to the server, and all other connections will be @@ -427,6 +431,10 @@ func NewClient(config *ClientConfig) (c *Client) { config.PluginLogBufferSize = defaultPluginLogBufferSize } + if config.ClientScanerBufferSize == 0 { + config.ClientScanerBufferSize = bufio.MaxScanTokenSize + } + c = &Client{ config: config, logger: config.Logger, @@ -799,6 +807,9 @@ func (c *Client) Start() (addr net.Addr, err error) { defer close(linesCh) scanner := bufio.NewScanner(runner.Stdout()) + buf := make([]byte, c.config.ClientScanerBufferSize) + scanner.Buffer(buf, c.config.ClientScanerBufferSize) + for scanner.Scan() { linesCh <- scanner.Text() } diff --git a/internal/cmdrunner/testdata/go.mod b/internal/cmdrunner/testdata/go.mod index 2c3817c..b7d368f 100644 --- a/internal/cmdrunner/testdata/go.mod +++ b/internal/cmdrunner/testdata/go.mod @@ -14,7 +14,7 @@ require ( github.com/hashicorp/go-hclog v0.14.1 // indirect github.com/hashicorp/yamux v0.1.1 // indirect github.com/mattn/go-colorable v0.1.4 // indirect - github.com/mattn/go-isatty v0.0.10 // indirect + github.com/mattn/go-isatty v0.0.17 // indirect github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 // indirect github.com/oklog/run v1.0.0 // indirect golang.org/x/net v0.17.0 // indirect diff --git a/internal/cmdrunner/testdata/go.sum b/internal/cmdrunner/testdata/go.sum index caf62e6..ce255ac 100644 --- a/internal/cmdrunner/testdata/go.sum +++ b/internal/cmdrunner/testdata/go.sum @@ -18,6 +18,7 @@ github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVc github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10= github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= +github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 h1:7GoSOOW2jpsfkntVKaS2rAr1TJqfcxotyaUcuxoZSzg= github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= @@ -30,6 +31,7 @@ golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=