From f27a381fe894eedffd93de25ec18f014ad01a1a2 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Wed, 8 Aug 2018 10:22:59 +0200 Subject: [PATCH] restrict multi-writer to syscall.conn only --- common/buf/io.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/common/buf/io.go b/common/buf/io.go index 0b801449..71794b69 100644 --- a/common/buf/io.go +++ b/common/buf/io.go @@ -79,6 +79,13 @@ func NewWriter(writer io.Writer) Writer { return mw } + if _, ok := writer.(syscall.Conn); !ok { + // If the writer doesn't implement syscall.Conn, it is probably not a TCP connection. + return &SequentialWriter{ + Writer: writer, + } + } + return &BufferToBytesWriter{ Writer: writer, }