Quellcode durchsuchen

restrict multi-writer to syscall.conn only

Darien Raymond vor 7 Jahren
Ursprung
Commit
f27a381fe8
1 geänderte Dateien mit 7 neuen und 0 gelöschten Zeilen
  1. 7 0
      common/buf/io.go

+ 7 - 0
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,
 	}