Skip to content

Commit

Permalink
fix: remove ioutil deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Jan 5, 2024
1 parent 8867fb1 commit c7a15f4
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
3 changes: 1 addition & 2 deletions _examples/ssh-sftpserver/sftp.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"fmt"
"io"
"io/ioutil"
"log"

"github.com/gliderlabs/ssh"
Expand All @@ -12,7 +11,7 @@ import (

// SftpHandler handler for SFTP subsystem
func SftpHandler(sess ssh.Session) {
debugStream := ioutil.Discard
debugStream := io.Discard
serverOptions := []sftp.ServerOption{
sftp.WithDebug(debugStream),
}
Expand Down
4 changes: 2 additions & 2 deletions agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package ssh

import (
"io"
"io/ioutil"
"net"
"os"
"path"
"sync"

Expand Down Expand Up @@ -36,7 +36,7 @@ func AgentRequested(sess Session) bool {
// NewAgentListener sets up a temporary Unix socket that can be communicated
// to the session environment and used for forwarding connections.
func NewAgentListener() (net.Listener, error) {
dir, err := ioutil.TempDir("", agentTempDir)
dir, err := os.MkdirTemp("", agentTempDir)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package ssh_test

import (
"io"
"io/ioutil"
"os"

"github.com/gliderlabs/ssh"
)
Expand All @@ -28,7 +28,7 @@ func ExampleNoPty() {
func ExamplePublicKeyAuth() {
ssh.ListenAndServe(":2222", nil,
ssh.PublicKeyAuth(func(ctx ssh.Context, key ssh.PublicKey) bool {
data, _ := ioutil.ReadFile("/path/to/allowed/key.pub")
data, _ := os.ReadFile("/path/to/allowed/key.pub")
allowed, _, _, _, _ := ssh.ParseAuthorizedKey(data)
return ssh.KeysEqual(key, allowed)
}),
Expand Down
4 changes: 2 additions & 2 deletions options.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ssh

import (
"io/ioutil"
"os"

gossh "golang.org/x/crypto/ssh"
)
Expand All @@ -26,7 +26,7 @@ func PublicKeyAuth(fn PublicKeyHandler) Option {
// from a PEM file at filepath.
func HostKeyFile(filepath string) Option {
return func(srv *Server) error {
pemBytes, err := ioutil.ReadFile(filepath)
pemBytes, err := os.ReadFile(filepath)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions tcpip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package ssh

import (
"bytes"
"io/ioutil"
"io"
"net"
"strconv"
"strings"
Expand Down Expand Up @@ -58,7 +58,7 @@ func TestLocalPortForwardingWorks(t *testing.T) {
if err != nil {
t.Fatalf("Error connecting to %v: %v", l.Addr().String(), err)
}
result, err := ioutil.ReadAll(conn)
result, err := io.ReadAll(conn)
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit c7a15f4

Please sign in to comment.