Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions dnscrypt-proxy/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"bytes"
"encoding/binary"
"errors"
"io/ioutil"
"net"
"os"
"strconv"
Expand Down Expand Up @@ -161,7 +160,7 @@
}

func ReadTextFile(filename string) (string, error) {
bin, err := ioutil.ReadFile(filename)
bin, err := os.ReadFile(filename)
if err != nil {
return "", err
}
Expand Down
3 changes: 1 addition & 2 deletions dnscrypt-proxy/local-doh.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/base64"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"strings"
Expand Down Expand Up @@ -36,7 +35,7 @@ func (handler localDoHHandler) ServeHTTP(writer http.ResponseWriter, request *ht
start := time.Now()
if request.Method == "POST" &&
request.Header.Get("Content-Type") == dataType {
packet, err = ioutil.ReadAll(io.LimitReader(request.Body, int64(MaxDNSPacketSize)))
packet, err = io.ReadAll(io.LimitReader(request.Body, int64(MaxDNSPacketSize)))
if err != nil {
dlog.Warnf("No body in a local DoH query")
return
Expand Down
5 changes: 2 additions & 3 deletions dnscrypt-proxy/sources.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"bytes"
"fmt"
"io/ioutil"
"math/rand"
"net/url"
"os"
Expand Down Expand Up @@ -54,10 +53,10 @@ var timeNow = time.Now

func (source *Source) fetchFromCache(now time.Time) (delay time.Duration, err error) {
var bin, sig []byte
if bin, err = ioutil.ReadFile(source.cacheFile); err != nil {
if bin, err = os.ReadFile(source.cacheFile); err != nil {
return
}
if sig, err = ioutil.ReadFile(source.cacheFile + ".minisig"); err != nil {
if sig, err = os.ReadFile(source.cacheFile + ".minisig"); err != nil {
return
}
if err = source.checkSignature(bin, sig); err != nil {
Expand Down
8 changes: 4 additions & 4 deletions dnscrypt-proxy/sources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ type SourceTestExpect struct {
}

func readFixture(t *testing.T, name string) []byte {
bin, err := ioutil.ReadFile(filepath.Join("testdata", name))
bin, err := os.ReadFile(filepath.Join("testdata", name))
if err != nil {
t.Fatalf("Unable to read test fixture %s: %v", name, err)
}
Expand All @@ -86,7 +86,7 @@ func writeSourceCache(t *testing.T, e *SourceTestExpect) {
if perms == 0 {
perms = 0644
}
if err := ioutil.WriteFile(path, f.content, perms); err != nil {
if err := os.WriteFile(path, f.content, perms); err != nil {
t.Fatalf("Unable to write cache file %s: %v", path, err)
}
if err := acl.Chmod(path, perms); err != nil {
Expand All @@ -109,7 +109,7 @@ func checkSourceCache(c *check.C, e *SourceTestExpect) {
for _, f := range e.cache {
path := e.cachePath + f.suffix
_ = acl.Chmod(path, 0644) // don't worry if this fails, reading it will catch the same problem
got, err := ioutil.ReadFile(path)
got, err := os.ReadFile(path)
c.DeepEqual(got, f.content, "Unexpected content for cache file '%s', err %v", path, err)
if f.suffix != "" {
continue
Expand Down Expand Up @@ -196,7 +196,7 @@ func loadFixtures(t *testing.T, d *SourceTestData) {
}

func makeTempDir(t *testing.T, d *SourceTestData) {
name, err := ioutil.TempDir("", "sources_test.go."+t.Name())
name, err := os.MkdirTemp("", "sources_test.go."+t.Name())
if err != nil {
t.Fatalf("Unable to create temporary directory: %v", err)
}
Expand Down
8 changes: 4 additions & 4 deletions dnscrypt-proxy/xtransport.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
"encoding/hex"
"errors"
"io"
"io/ioutil"
"math/rand"
"net"
"net/http"
"net/url"
"os"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -178,7 +178,7 @@ func (xTransport *XTransport) rebuildTransport() {
if certPool == nil {
dlog.Fatalf("Additional CAs not supported on this platform: %v", certPoolErr)
}
additionalCaCert, err := ioutil.ReadFile(clientCreds.rootCA)
additionalCaCert, err := os.ReadFile(clientCreds.rootCA)
if err != nil {
dlog.Fatal(err)
}
Expand Down Expand Up @@ -444,7 +444,7 @@ func (xTransport *XTransport) Fetch(
}
if body != nil {
req.ContentLength = int64(len(*body))
req.Body = ioutil.NopCloser(bytes.NewReader(*body))
req.Body = io.NopCloser(bytes.NewReader(*body))
}
start := time.Now()
resp, err := client.Do(req)
Expand Down Expand Up @@ -500,7 +500,7 @@ func (xTransport *XTransport) Fetch(
}
}
tls := resp.TLS
bin, err := ioutil.ReadAll(io.LimitReader(resp.Body, MaxHTTPBodyLength))
bin, err := io.ReadAll(io.LimitReader(resp.Body, MaxHTTPBodyLength))
if err != nil {
return nil, statusCode, tls, rtt, err
}
Expand Down
Loading