1
0
Fork 0
mirror of https://github.com/SamTherapy/dnscrypt.git synced 2024-11-20 04:43:47 +00:00

code cleanup, go to 1.19

This commit is contained in:
Andrey Meshkov 2023-03-15 18:57:22 +03:00
parent 266e248ed5
commit 6ca80e7ffc
7 changed files with 20 additions and 39 deletions

View file

@ -23,7 +23,7 @@ jobs:
steps:
- uses: actions/checkout@master
- uses: actions/setup-go@v2
- uses: actions/setup-go@v3
with:
go-version: 1.x
@ -32,7 +32,7 @@ jobs:
go test -race -v -bench=. -coverprofile=coverage.txt -covermode=atomic ./...
- name: Upload coverage
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
if: "success() && matrix.os == 'ubuntu-latest'"
with:
token: ${{ secrets.CODECOV_TOKEN }}
@ -47,7 +47,7 @@ jobs:
steps:
- uses: actions/checkout@master
- uses: actions/setup-go@v2
- uses: actions/setup-go@v3
with:
go-version: 1.x

View file

@ -17,10 +17,10 @@ jobs:
- ubuntu-latest
- macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v2.3.0
with:
# This field is required. Dont set the patch version to always use
# the latest patch version.
version: v1.48.0
version: v1.51.2

View file

@ -12,32 +12,19 @@ run:
# autogenerated files. If it's not please let us know.
skip-files:
- ".*generated.*"
- ".*_test.go"
# all available settings of specific linters
linters-settings:
gocyclo:
min-complexity: 20
lll:
line-length: 200
depguard:
list-type: blacklist
include-go-root: false
packages:
- golang.org/x/net/context # we use context
- log # we use github.com/AdguardTeam/golibs/log
linters:
enable:
- deadcode
- errcheck
- govet
- ineffassign
- staticcheck
- structcheck
- unused
- varcheck
- bodyclose
- depguard
- dupl
- gocyclo
@ -47,30 +34,19 @@ linters:
- misspell
- stylecheck
- unconvert
- depguard
disable-all: true
fast: true
issues:
exclude-use-default: false
# List of regexps of issue texts to exclude, empty list by default.
# But independently from this option we use default exclude patterns,
# But independently of this option we use default exclude patterns,
# it can be disabled by `exclude-use-default: false`. To list all
# excluded by default patterns execute `golangci-lint run --help`
exclude:
# errcheck defer Close
- error return value not checked \(defer .*\.Close()\)
# errcheck: Almost all programs ignore errors on these functions and in most cases it's ok
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv). is not checked
# gosec: Duplicated errcheck checks
- G104
# gosec: Expect file permissions to be 0600 or less
- G302
# gosec: Use of weak random number generators
# gosec: Potential file inclusion via variable
# Exclude as it is required it in the command-line tool.
- G304
# gosec: Use of weak random number generator
# Used in tests.
- G404
# errcheck defer Close
- error return value not checked \(defer .*\.Close()\)
# gosec: False positive is triggered by 'src, err := os.ReadFile(filename)'
- Potential file inclusion via variable

View file

@ -1,3 +1,4 @@
// Package main is responsible for the command-line interface.
package main
import (

View file

@ -49,7 +49,7 @@ func (q *EncryptedQuery) Encrypt(packet []byte, sharedKey [sharedKeySize]byte) (
// Step 1: generate nonce
binary.BigEndian.PutUint64(q.Nonce[:8], uint64(time.Now().UnixNano()))
rand.Read(q.Nonce[8:12])
_, _ = rand.Read(q.Nonce[8:12])
// Unencrypted part of the query:
// <client-magic> <client-pk> <client-nonce>

View file

@ -32,7 +32,7 @@ func (r *EncryptedResponse) Encrypt(packet []byte, sharedKey [sharedKeySize]byte
var response []byte
// Step 1: generate nonce
rand.Read(r.Nonce[12:16])
_, _ = rand.Read(r.Nonce[12:16])
binary.BigEndian.PutUint64(r.Nonce[16:nonceSize], uint64(time.Now().UnixNano()))
// Unencrypted part of the query:

View file

@ -262,8 +262,12 @@ func newTestServer(t require.TestingT, handler Handler) *testServer {
srv.udpConn, err = net.ListenUDP("udp", &net.UDPAddr{IP: net.IPv4zero, Port: 0})
require.NoError(t, err)
go s.ServeUDP(srv.udpConn)
go s.ServeTCP(srv.tcpListen)
go func() {
_ = s.ServeUDP(srv.udpConn)
}()
go func() {
_ = s.ServeTCP(srv.tcpListen)
}()
return srv
}