masker

package
v0.29.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package masker provides a wrapper around an io.Writer that replaces sensitive values in its output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MaskedWriter

type MaskedWriter struct {
	// contains filtered or unexported fields
}

MaskedWriter wraps an io.Writer which masks all occurrences of masks by maskString. If no write is made for timeout on the io.Writer, any matches in progress are reset and the buffer is flushed. This is to ensure that the writer does not hang on partial matches.

func NewMaskedWriter

func NewMaskedWriter(w io.Writer, masks [][]byte, maskString string, timeout time.Duration) *MaskedWriter

NewMaskedWriter returns a new MaskedWriter that masks all occurrences of sequences in masks with maskString.

func (*MaskedWriter) Flush

func (mw *MaskedWriter) Flush() error

Flush is called to make sure that all output is written to the underlying io.Writer. Returns any errors caused by the writing.

func (*MaskedWriter) Run

func (mw *MaskedWriter) Run()

Run writes any processed data from the output channel to the underlying io.Writer. If no new data is received on the output channel for timeout, the output buffer is forced flushed and all ongoing matches are reset.

This should be run in a separate goroutine.

func (*MaskedWriter) Write

func (mw *MaskedWriter) Write(p []byte) (n int, err error)

Write implements Write from io.Writer It is responsible for finding any matches to mask and mark the appropriate bytes as masked. This function never returns an error. These can instead be caught with Flush().

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL