Skip to content

Commit

Permalink
Use CloseRead() and CloseWrite() from wrapped StreamConn.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbruens committed Oct 16, 2024
1 parent ce8af88 commit 7cf5cc8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions caddy/shadowsocks_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (h *ShadowsocksHandler) Provision(ctx caddy.Context) error {
func (h *ShadowsocksHandler) Handle(cx *layer4.Connection, _ layer4.Handler) error {
switch conn := cx.Conn.(type) {
case transport.StreamConn:
h.service.HandleStream(cx.Context, &l4StreamConn{cx})
h.service.HandleStream(cx.Context, &l4StreamConn{Connection: cx, wrappedStreamConn: conn})
case net.PacketConn:
h.service.HandlePacket(conn)
default:
Expand All @@ -126,14 +126,15 @@ func (h *ShadowsocksHandler) Handle(cx *layer4.Connection, _ layer4.Handler) err

type l4StreamConn struct {
*layer4.Connection
wrappedStreamConn transport.StreamConn
}

var _ transport.StreamConn = (*l4StreamConn)(nil)

func (c l4StreamConn) CloseRead() error {
return c.Close()
return c.wrappedStreamConn.CloseRead()
}

func (c l4StreamConn) CloseWrite() error {
return nil
return c.wrappedStreamConn.CloseWrite()
}

0 comments on commit 7cf5cc8

Please sign in to comment.