update docs; replace "data frame" refs with "raw message"
This commit is contained in:
parent
e148c23156
commit
8255b4a03f
12
server.go
12
server.go
|
@ -198,17 +198,17 @@ func HandleFunc(pattern string, handler func(ResponseWriter, *Msg)) {
|
||||||
DefaultServeMux.HandleFunc(pattern, handler)
|
DefaultServeMux.HandleFunc(pattern, handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Writer writes DNS data frames; each call to Write should send an entire frame.
|
// Writer writes raw DNS messages; each call to Write should send an entire message.
|
||||||
type Writer interface {
|
type Writer interface {
|
||||||
io.Writer
|
io.Writer
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reader reads DNS data frames; each call to ReadTCP or ReadUDP should return an entire frame.
|
// Reader reads raw DNS messages; each call to ReadTCP or ReadUDP should return an entire message.
|
||||||
type Reader interface {
|
type Reader interface {
|
||||||
// ReadTCP reads a data frame from a TCP connection. Implementations may alter
|
// ReadTCP reads a raw message from a TCP connection. Implementations may alter
|
||||||
// connection properties, for example the read-deadline.
|
// connection properties, for example the read-deadline.
|
||||||
ReadTCP(conn *net.TCPConn, timeout time.Duration) ([]byte, error)
|
ReadTCP(conn *net.TCPConn, timeout time.Duration) ([]byte, error)
|
||||||
// ReadUDP reads a data frame from a UDP connection. Implementations may alter
|
// ReadUDP reads a raw message from a UDP connection. Implementations may alter
|
||||||
// connection properties, for example the read-deadline.
|
// connection properties, for example the read-deadline.
|
||||||
ReadUDP(conn *net.UDPConn, timeout time.Duration) ([]byte, *SessionUDP, error)
|
ReadUDP(conn *net.UDPConn, timeout time.Duration) ([]byte, *SessionUDP, error)
|
||||||
}
|
}
|
||||||
|
@ -263,9 +263,9 @@ type Server struct {
|
||||||
Unsafe bool
|
Unsafe bool
|
||||||
// If NotifyStartedFunc is set is is called, once the server has started listening.
|
// If NotifyStartedFunc is set is is called, once the server has started listening.
|
||||||
NotifyStartedFunc func()
|
NotifyStartedFunc func()
|
||||||
// DecorateReader is optional, allows customization of the process that reads DNS frames.
|
// DecorateReader is optional, allows customization of the process that reads raw DNS messages.
|
||||||
DecorateReader DecorateReader
|
DecorateReader DecorateReader
|
||||||
// DecorateWriter is optional, allows customization of the process that writes DNS frames.
|
// DecorateWriter is optional, allows customization of the process that writes raw DNS messages.
|
||||||
DecorateWriter DecorateWriter
|
DecorateWriter DecorateWriter
|
||||||
|
|
||||||
// For graceful shutdown.
|
// For graceful shutdown.
|
||||||
|
|
|
@ -403,12 +403,12 @@ type ExampleFrameLengthWriter struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *ExampleFrameLengthWriter) Write(m []byte) (int, error) {
|
func (e *ExampleFrameLengthWriter) Write(m []byte) (int, error) {
|
||||||
fmt.Println("writing DNS data frame of length", len(m))
|
fmt.Println("writing raw DNS message of length", len(m))
|
||||||
return e.Writer.Write(m)
|
return e.Writer.Write(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExampleDecorateWriter() {
|
func ExampleDecorateWriter() {
|
||||||
// instrument DNS data frame writing
|
// instrument raw DNS message writing
|
||||||
wf := DecorateWriter(func(w Writer) Writer {
|
wf := DecorateWriter(func(w Writer) Writer {
|
||||||
return &ExampleFrameLengthWriter{w}
|
return &ExampleFrameLengthWriter{w}
|
||||||
})
|
})
|
||||||
|
@ -446,5 +446,5 @@ func ExampleDecorateWriter() {
|
||||||
fmt.Println("failed to exchange", err.Error())
|
fmt.Println("failed to exchange", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Output: writing DNS data frame of length 56
|
// Output: writing raw DNS message of length 56
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue