Add mangle to Conn

This commit is contained in:
Miek Gieben 2011-03-28 10:39:01 +02:00
parent f9088e1e75
commit 7cc589d52a
1 changed files with 14 additions and 3 deletions

17
dns.go
View File

@ -86,9 +86,6 @@ type Conn struct {
// The remote port number of open the connection.
Port int
// The remote addr which is going to be dialed.
RemoteAddr string
// If TSIG is used, this holds all the information.
// If unused is must be nil.
Tsig *Tsig
@ -99,6 +96,15 @@ type Conn struct {
// Number of attempts to try to Read/Write from/to a
// connection.
Attempts int
// The remote addr which is going to be dialed.
RemoteAddr string
// Mangle the packet before writing it be feeding
// it through this function.
Mangle func([]byte) []byte
// rtt times?
}
// Dial connects to the remote address raddr on the network net.
@ -262,6 +268,11 @@ func (d *Conn) Write(p []byte) (n int, err os.Error) {
} else {
attempts = d.Attempts
}
// Mangle before TSIG?
if d.Mangle != nil {
p = d.Mangle(p)
}
d.SetTimeout()
if d.Tsig != nil {
// Create a new buffer with the TSIG added.