revert reader creation based on per-connection buffer

pull/1269/head
Darien Raymond 6 years ago
parent 2e11653694
commit 57966adf49
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

@ -92,13 +92,7 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn in
requestDone := func() error {
defer timer.SetTimeout(plcy.Timeouts.DownlinkOnly)
var reader buf.Reader
if plcy.Buffer.PerConnection == 0 {
reader = &buf.SingleReader{Reader: conn}
} else {
reader = buf.NewReader(conn)
}
reader := buf.NewReader(conn)
if err := buf.Copy(reader, link.Writer, buf.UpdateActivity(timer)); err != nil {
return newError("failed to transport request").Base(err)
}

@ -141,13 +141,7 @@ func (h *Handler) Process(ctx context.Context, link *core.Link, dialer proxy.Dia
responseDone := func() error {
defer timer.SetTimeout(plcy.Timeouts.UplinkOnly)
var reader buf.Reader
if plcy.Buffer.PerConnection == 0 {
reader = &buf.SingleReader{Reader: conn}
} else {
reader = buf.NewReader(conn)
}
if err := buf.Copy(reader, output, buf.UpdateActivity(timer)); err != nil {
if err := buf.Copy(buf.NewReader(conn), output, buf.UpdateActivity(timer)); err != nil {
return newError("failed to process response").Base(err)
}

@ -196,13 +196,7 @@ func (s *Server) handleConnect(ctx context.Context, request *http.Request, reade
requestDone := func() error {
defer timer.SetTimeout(plcy.Timeouts.DownlinkOnly)
var reader buf.Reader
if plcy.Buffer.PerConnection == 0 {
reader = &buf.SingleReader{Reader: conn}
} else {
reader = buf.NewReader(conn)
}
return buf.Copy(reader, link.Writer, buf.UpdateActivity(timer))
return buf.Copy(buf.NewReader(conn), link.Writer, buf.UpdateActivity(timer))
}
responseDone := func() error {

@ -149,16 +149,7 @@ func (s *Server) handleConnection(ctx context.Context, conn internet.Connection,
sessionPolicy := s.v.PolicyManager().ForLevel(s.user.Level)
conn.SetReadDeadline(time.Now().Add(sessionPolicy.Timeouts.Handshake))
var bufferedReader buf.BufferedReader
{
var reader buf.Reader
if sessionPolicy.Buffer.PerConnection == 0 {
reader = &buf.SingleReader{Reader: conn}
} else {
reader = buf.NewReader(conn)
}
bufferedReader = buf.BufferedReader{Reader: reader}
}
bufferedReader := buf.BufferedReader{Reader: buf.NewReader(conn)}
request, bodyReader, err := ReadTCPSession(s.user, &bufferedReader)
if err != nil {
log.Record(&log.AccessMessage{

@ -113,13 +113,7 @@ func (c *Client) Process(ctx context.Context, link *core.Link, dialer proxy.Dial
}
responseFunc = func() error {
defer timer.SetTimeout(p.Timeouts.UplinkOnly)
var reader buf.Reader
if p.Buffer.PerConnection == 0 {
reader = &buf.SingleReader{Reader: conn}
} else {
reader = buf.NewReader(conn)
}
return buf.Copy(reader, link.Writer, buf.UpdateActivity(timer))
return buf.Copy(buf.NewReader(conn), link.Writer, buf.UpdateActivity(timer))
}
} else if request.Command == protocol.RequestCommandUDP {
udpConn, err := dialer.Dial(ctx, udpRequest.Destination())

@ -73,17 +73,6 @@ func (s *Server) processTCP(ctx context.Context, conn internet.Connection, dispa
newError("failed to set deadline").Base(err).WriteToLog(session.ExportIDToError(ctx))
}
var reader *buf.BufferedReader
{
var r buf.Reader
if plcy.Buffer.PerConnection == 0 {
r = &buf.SingleReader{Reader: conn}
} else {
r = buf.NewReader(conn)
}
reader = &buf.BufferedReader{Reader: r}
}
inboundDest, ok := proxy.InboundEntryPointFromContext(ctx)
if !ok {
return newError("inbound entry point not specified")
@ -93,6 +82,7 @@ func (s *Server) processTCP(ctx context.Context, conn internet.Connection, dispa
port: inboundDest.Port,
}
reader := &buf.BufferedReader{Reader: buf.NewReader(conn)}
request, err := svrSession.Handshake(reader, conn)
if err != nil {
if source, ok := proxy.SourceFromContext(ctx); ok {

@ -224,7 +224,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection i
return newError("unable to set read deadline").Base(err).AtWarning()
}
reader := &buf.BufferedReader{Reader: &buf.SingleReader{Reader: connection}}
reader := &buf.BufferedReader{Reader: buf.NewReader(connection)}
svrSession := encoding.NewServerSession(h.clients, h.sessionHistory)
request, err := svrSession.DecodeRequestHeader(reader)
@ -280,9 +280,6 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection i
requestDone := func() error {
defer timer.SetTimeout(sessionPolicy.Timeouts.DownlinkOnly)
if sessionPolicy.Buffer.PerConnection > 0 {
reader.Reader = buf.NewReader(connection)
}
return transferRequest(timer, svrSession, request, reader, link.Writer)
}

@ -144,16 +144,7 @@ func (v *Handler) Process(ctx context.Context, link *core.Link, dialer proxy.Dia
responseDone := func() error {
defer timer.SetTimeout(sessionPolicy.Timeouts.UplinkOnly)
var reader *buf.BufferedReader
{
var r buf.Reader
if sessionPolicy.Buffer.PerConnection == 0 {
r = &buf.SingleReader{Reader: conn}
} else {
r = buf.NewReader(conn)
}
reader = &buf.BufferedReader{Reader: r}
}
reader := &buf.BufferedReader{Reader: buf.NewReader(conn)}
header, err := session.DecodeResponseHeader(reader)
if err != nil {
return newError("failed to read header").Base(err)

Loading…
Cancel
Save