Add Suricata input plugin (#3145)
This commit is contained in:
committed by
Daniel Nelson
parent
f669ef4452
commit
d2d6f1ab21
38
plugins/inputs/suricata/suricata_testutil.go
Normal file
38
plugins/inputs/suricata/suricata_testutil.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package suricata
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// A thread-safe Buffer wrapper to enable concurrent access to log output.
|
||||
type buffer struct {
|
||||
b bytes.Buffer
|
||||
m sync.Mutex
|
||||
}
|
||||
|
||||
func (b *buffer) Read(p []byte) (n int, err error) {
|
||||
b.m.Lock()
|
||||
defer b.m.Unlock()
|
||||
return b.b.Read(p)
|
||||
}
|
||||
func (b *buffer) Write(p []byte) (n int, err error) {
|
||||
b.m.Lock()
|
||||
defer b.m.Unlock()
|
||||
return b.b.Write(p)
|
||||
}
|
||||
func (b *buffer) String() string {
|
||||
b.m.Lock()
|
||||
defer b.m.Unlock()
|
||||
return b.b.String()
|
||||
}
|
||||
func (b *buffer) Reset() {
|
||||
b.m.Lock()
|
||||
defer b.m.Unlock()
|
||||
b.b.Reset()
|
||||
}
|
||||
func (b *buffer) Bytes() []byte {
|
||||
b.m.Lock()
|
||||
defer b.m.Unlock()
|
||||
return b.b.Bytes()
|
||||
}
|
||||
Reference in New Issue
Block a user