dnstap.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (c) 2014,2019 by Farsight Security, Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. //go:generate ./genproto.sh
  17. package dnstap
  18. const outputChannelSize = 32
  19. // FSContentType is the FrameStream content type for dnstap protobuf data.
  20. var FSContentType = []byte("protobuf:dnstap.Dnstap")
  21. // An Input is a source of dnstap data. It provides validation of the
  22. // content type and will present any data read or received on the channel
  23. // provided to the ReadInto method.
  24. type Input interface {
  25. ReadInto(chan []byte)
  26. Wait()
  27. }
  28. // An Output is a destination for dnstap data. It accepts data on the channel
  29. // returned from the GetOutputChannel method. The RunOutputLoop() method
  30. // processes data received on this channel, and returns after the Close()
  31. // method is called.
  32. type Output interface {
  33. GetOutputChannel() chan []byte
  34. RunOutputLoop()
  35. Close()
  36. }
  37. // A Logger prints a formatted log message to the destination of the
  38. // implementation's choice. A Logger may be provided for some Input and
  39. // Output implementations for visibility into their ReadInto() and
  40. // RunOutputLoop() loops.
  41. //
  42. // The result of log.New() satisfies the Logger interface.
  43. type Logger interface {
  44. Printf(format string, v ...interface{})
  45. }
  46. type nullLogger struct{}
  47. func (n nullLogger) Printf(format string, v ...interface{}) {}