Skip to content

Commit

Permalink
Merge pull request #22 from denis-tingajkin/fix_extra_logging
Browse files Browse the repository at this point in the history
Remove extra logging
  • Loading branch information
edwarnicke authored Apr 14, 2020
2 parents 0497c39 + 091dd3b commit 8da957c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
4 changes: 4 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,7 @@ issues:
- path: "setup_test.go"
linters:
- gocyclo
# gocritic conflicts with other linters
- path: "client.go"
linters:
- gocritic
22 changes: 12 additions & 10 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,26 +65,28 @@ func (c *client) Endpoint() string {
// Request sends request to DNS server
func (c *client) Request(ctx context.Context, r *request.Request) (*dns.Msg, error) {
start := time.Now()

conn, err := c.transport.Dial(ctx, c.net)
if err != nil {
return nil, err
}
defer func() {
logErrIfNotNil(conn.Close())
_ = conn.Close()
}()

logErrIfNotNil(conn.SetWriteDeadline(time.Now().Add(maxTimeout)))
if err = conn.WriteMsg(r.Req); err != nil {
logErrIfNotNil(err)
return nil, err
}
logErrIfNotNil(conn.SetReadDeadline(time.Now().Add(readTimeout)))
var ret *dns.Msg
go func() {
<-ctx.Done()
_ = conn.Close()
}()
if err = conn.SetWriteDeadline(time.Now().Add(maxTimeout)); err != nil {
return nil, err
}
if err = conn.WriteMsg(r.Req); err != nil {
return nil, err
}
if err = conn.SetReadDeadline(time.Now().Add(readTimeout)); err != nil {
return nil, err
}
var ret *dns.Msg

for {
ret, err = conn.ReadMsg()
if err != nil {
Expand Down

0 comments on commit 8da957c

Please sign in to comment.