Skip to content

Commit

Permalink
Doc links.
Browse files Browse the repository at this point in the history
  • Loading branch information
ncruces committed Oct 3, 2023
1 parent 1c89523 commit 6bbf879
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func NewCachingResolver(parent *net.Resolver, options ...CacheOption) *net.Resol
}
}

// NewCachingDialer adds caching to a net.Resolver.Dial function.
// NewCachingDialer adds caching to a [net.Resolver.Dial] function.
func NewCachingDialer(parent DialFunc, options ...CacheOption) DialFunc {
var cache = cache{dial: parent, negative: true}
for _, o := range options {
Expand Down
8 changes: 0 additions & 8 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ type dnsConn struct {

type roundTripper func(ctx context.Context, req string) (res string, err error)

// Read implements net.Conn.
func (c *dnsConn) Read(b []byte) (n int, err error) {
imsg, n, err := c.drainBuffers(b)
if n != 0 || err != nil {
Expand All @@ -41,14 +40,12 @@ func (c *dnsConn) Read(b []byte) (n int, err error) {
return c.fillBuffer(b, omsg)
}

// Write implements net.Conn.
func (c *dnsConn) Write(b []byte) (n int, err error) {
c.Lock()
defer c.Unlock()
return c.ibuf.Write(b)
}

// Close implements net.Conn.
func (c *dnsConn) Close() error {
c.Lock()
cancel := c.cancel
Expand All @@ -60,32 +57,27 @@ func (c *dnsConn) Close() error {
return nil
}

// LocalAddr implements net.Conn.
func (c *dnsConn) LocalAddr() net.Addr {
return nil
}

// RemoteAddr implements net.Conn.
func (c *dnsConn) RemoteAddr() net.Addr {
return nil
}

// SetDeadline implements net.Conn.
func (c *dnsConn) SetDeadline(t time.Time) error {
c.SetReadDeadline(t)
c.SetWriteDeadline(t)
return nil
}

// SetReadDeadline implements net.Conn.
func (c *dnsConn) SetReadDeadline(t time.Time) error {
c.Lock()
defer c.Unlock()
c.deadline = t
return nil
}

// SetWriteDeadline implements net.Conn.
func (c *dnsConn) SetWriteDeadline(t time.Time) error {
// writes do not timeout
return nil
Expand Down
2 changes: 1 addition & 1 deletion dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,5 @@ func addBadServer(address string) {
badServers.next = (badServers.next + 1) % len(badServers.list)
}

// DialFunc is a net.Resolver.Dial function.
// DialFunc is a [net.Resolver.Dial] function.
type DialFunc func(ctx context.Context, network, address string) (net.Conn, error)
2 changes: 1 addition & 1 deletion dot.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,5 @@ func DoTAddresses(addresses ...string) DoTOption { return dotAddresses(addresses
func DoTCache(options ...CacheOption) DoTOption { return dotCache(options) }

// DoTDialFunc sets the DialFunc used by the resolver.
// By default net#Dialer.DialContext is used.
// By default [net.Dialer.DialContext] is used.
func DoTDialFunc(f DialFunc) DoTOption { return dotDialFunc(f) }

0 comments on commit 6bbf879

Please sign in to comment.