package ssh import ( "io" "forge.cadoles.com/wpetit/rebound/stat" ) const ( StatTotalOpenedTunnels = "total_opened_tunnels" StatTotalTxBytes = "total_tx_bytes" StatTotalRxBytes = "total_rx_bytes" ) type instrumentedWriter struct { name string stats *stat.Store internal io.Writer } // Write implements io.Writer. func (w *instrumentedWriter) Write(p []byte) (n int, err error) { n, err = w.internal.Write(p) w.stats.Add(w.name, float64(n), 0) return n, err } var _ io.Writer = &instrumentedWriter{} type instrumentedReader struct { name string stats *stat.Store internal io.Reader } // Read implements io.Reader. func (w *instrumentedReader) Read(p []byte) (n int, err error) { n, err = w.internal.Read(p) w.stats.Add(w.name, float64(n), 0) return n, err } var _ io.Reader = &instrumentedReader{}