Skip to content
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
2 changes: 1 addition & 1 deletion plugin/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func Test_newCfgForManualLaunch(t *testing.T) {
// as in the context of where this function is used we don't care.
func runUncheckedDummyAcceptor(logger logging.Logger, listener net.Listener) {
httpMux := http.NewServeMux()
httpMux.Handle(ipc.NewHijackAcceptor(logger, func(context.Context, io.ReadWriteCloser) {}))
httpMux.Handle(ipc.NewHijackAcceptor(logger, func(context.Context, io.ReadWriter) {}))
server := &http.Server{Handler: httpMux}
go func() {
_ = server.Serve(listener)
Expand Down
4 changes: 2 additions & 2 deletions x/ipc/hijack.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ type CloseWriter interface {
}

type hijackHandler struct {
cb func(ctx context.Context, closer io.ReadWriteCloser)
cb func(ctx context.Context, rw io.ReadWriter)
ackTimeout time.Duration
logger logging.Logger
}
Expand Down Expand Up @@ -163,6 +163,6 @@ func (h *hijackHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
}

func NewHijackAcceptor(logger logging.Logger, cb func(context.Context, io.ReadWriteCloser)) (string, http.Handler) {
func NewHijackAcceptor(logger logging.Logger, cb func(context.Context, io.ReadWriter)) (string, http.Handler) {
return hijackPath, &hijackHandler{logger: logger, cb: cb, ackTimeout: hijackTimeout}
}
9 changes: 4 additions & 5 deletions x/ipc/hijack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ func Test_hijacking(t *testing.T) {
t.Cleanup(func() { l.Close() })

httpMux := http.NewServeMux()
ch := make(chan io.ReadWriteCloser)
ch := make(chan io.ReadWriter)
wait := make(chan struct{})
once := sync.OnceFunc(func() { close(wait) })
defer once()
httpMux.Handle(NewHijackAcceptor(testhelper.TestLogger(t), func(_ context.Context, closer io.ReadWriteCloser) {
httpMux.Handle(NewHijackAcceptor(testhelper.TestLogger(t), func(_ context.Context, closer io.ReadWriter) {
ch <- closer
<-wait
}))
Expand All @@ -68,7 +68,6 @@ func Test_hijacking(t *testing.T) {
assert.Equal(t, "ping", readLine(connServer))
assert.NoError(t, writeLine(connServer, "pong"))
assert.Equal(t, "pong", readLine(connHijacked))
assert.NoError(t, connServer.Close())
assert.NoError(t, connHijacked.Close())
once()

Expand All @@ -93,7 +92,7 @@ func TestHijackify_hijackRequest_timeout(t *testing.T) {
assert.ErrorContains(t, err, "i/o timeout")
}

func readLine(conn io.ReadWriteCloser) string {
func readLine(conn io.Reader) string {
r := bufio.NewReader(conn)
line, err := r.ReadString('\n')
if err != nil {
Expand All @@ -102,7 +101,7 @@ func readLine(conn io.ReadWriteCloser) string {
return strings.TrimRight(line, "\r\n ")
}

func writeLine(conn io.ReadWriteCloser, line string) error {
func writeLine(conn io.Writer, line string) error {
_, err := conn.Write([]byte(line + "\r\n"))
return err
}
Expand Down
Loading