Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ioutil package #31

Merged
merged 1 commit into from
Oct 20, 2023
Merged
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
4 changes: 2 additions & 2 deletions cmd/letsdane/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"bufio"
"bytes"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"strings"
)

Expand Down Expand Up @@ -47,7 +47,7 @@ var nameConstraints = map[string]struct{} {
}
sb.WriteString("}\n")

if err := ioutil.WriteFile("tld.go", sb.Bytes(), 0600); err != nil {
if err := os.WriteFile("tld.go", sb.Bytes(), 0600); err != nil {
log.Fatal(err)
}

Expand Down
18 changes: 9 additions & 9 deletions cmd/letsdane/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ import (
"errors"
"flag"
"fmt"
"github.com/buffrr/hsig0"
"github.com/buffrr/letsdane"
rs "github.com/buffrr/letsdane/resolver"
"github.com/miekg/dns"
"io/ioutil"
"log"
"net"
"net/url"
"os"
"path"
"strings"
"time"

"github.com/buffrr/hsig0"
"github.com/buffrr/letsdane"
rs "github.com/buffrr/letsdane/resolver"
"github.com/miekg/dns"
)

const KSK2017 = `. IN DS 20326 8 2 E06D44B80B8F1D39A95C0B0D7C65D08458E880409BBC683457104237C7F8EC8D`
Expand Down Expand Up @@ -108,12 +108,12 @@ func getOrCreateCA() (string, string) {
}

func loadX509KeyPair(certFile, keyFile string) (tls.Certificate, error) {
certPEMBlock, err := ioutil.ReadFile(certFile)
certPEMBlock, err := os.ReadFile(certFile)
if err != nil {
return tls.Certificate{}, err
}

keyPEMBlock, err := ioutil.ReadFile(keyFile)
keyPEMBlock, err := os.ReadFile(keyFile)
if err != nil {
return tls.Certificate{}, err
}
Expand Down Expand Up @@ -174,12 +174,12 @@ func isLoopback(r string) bool {
}

func exportCA() {
b, err := ioutil.ReadFile(*certPath)
b, err := os.ReadFile(*certPath)
if err != nil {
log.Fatal(err)
}

if err := ioutil.WriteFile(*output, b, 0600); err != nil {
if err := os.WriteFile(*output, b, 0600); err != nil {
log.Fatal(err)
}
}
Expand Down
4 changes: 2 additions & 2 deletions dialer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package letsdane
import (
"bufio"
"context"
"io/ioutil"
"io"
"net"
"net/http"
"net/http/httptest"
Expand Down Expand Up @@ -42,7 +42,7 @@ func TestDialTLS(t *testing.T) {
}
defer resp.Body.Close()

body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
t.Fatal(err)
}
Expand Down
8 changes: 4 additions & 4 deletions proxy/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"crypto/tls"
"crypto/x509"
"io/ioutil"
"io"
"net"
"net/http"
"net/http/httptest"
Expand Down Expand Up @@ -57,7 +57,7 @@ func TestHijacker(t *testing.T) {
t.Fatal(err)
}

body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
t.Fatal(err)
}
Expand All @@ -84,7 +84,7 @@ func TestHandler_ServeHTTPTunnelerAddr(t *testing.T) {
proxy.ServeHTTP(w, req)

resp := w.Result()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -120,7 +120,7 @@ func TestHandler_ServeHTTPNonConnect(t *testing.T) {
t.Errorf("status = %d, wanted %d", resp.StatusCode, http.StatusTeapot)
}

b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
if err != nil {
t.Fatal(err)
}
Expand Down
7 changes: 4 additions & 3 deletions resolver/stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import (
"context"
"errors"
"fmt"
"github.com/miekg/dns"
"io/ioutil"
"io"
"net"
"net/http"
"net/url"
"time"

"github.com/miekg/dns"
)

// Stub is an AD-bit aware stub resolver
Expand Down Expand Up @@ -157,7 +158,7 @@ func exchangeDOH(ctx context.Context, m *dns.Msg, doh string) (r *dns.Msg, rtt t
}

defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
if err != nil {
return nil, 0, err
}
Expand Down
11 changes: 6 additions & 5 deletions tunnel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ import (
"crypto/x509"
"errors"
"fmt"
"github.com/miekg/dns"
"io/ioutil"
"io"
"net"
"net/http"
"net/http/httptest"
"net/url"
"strings"
"testing"
"time"

"github.com/miekg/dns"
)

func newProxyTestConfig(t *testing.T) (*x509.Certificate, *Config) {
Expand Down Expand Up @@ -111,7 +112,7 @@ func TestNonConnectHandler(t *testing.T) {
}

if resp.StatusCode == http.StatusOK {
b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -369,7 +370,7 @@ func TestHandlerTLS(t *testing.T) {
t.Fatal(err)
}

body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
resp.Body.Close()
content := string(body)
if content != "foo" {
Expand Down Expand Up @@ -418,7 +419,7 @@ func TestHandlerTLS(t *testing.T) {
}
defer resp.Body.Close()

body, _ := ioutil.ReadAll(resp.Body)
body, _ := io.ReadAll(resp.Body)
c := string(body)
if c != "ALPN TEST" {
t.Fatalf("body = %s, wanted 'ALPN TEST'", c)
Expand Down
Loading