Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
package test
import (
// ResponseWriter extends test.ResponseWriter and record useful calls to methods.
type ResponseWriter struct {
writeMsgCallCount uint64
// ResponseWriterCustomRemote is a ResponseWriter which can receive a custom
// remote address.
type ResponseWriterCustomRemote struct {
RemoteIP string
// WriteMsg implement dns.ResponseWriter interface.
func (t *ResponseWriter) WriteMsg(m *dns.Msg) error { t.writeMsgCallCount++; return nil }
// GetWriteMsgCallCount returns the number of WriteMsg calls that were made.
func (t *ResponseWriter) GetWriteMsgCallCount() uint64 { return t.writeMsgCallCount }
// RemoteAddr returns a net.Addr of the remote address connecting to the server.
func (t *ResponseWriterCustomRemote) RemoteAddr() net.Addr {
return &net.UDPAddr{IP: net.ParseIP(t.RemoteIP), Port: 40212, Zone: ""}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.