[Pkg-privacy-commits] [obfs4proxy] 04/11: Reusing read buffer for readPackets
Jérémy Bobbio
lunar at moszumanska.debian.org
Wed Nov 16 18:45:01 UTC 2016
This is an automated email from the git hooks/post-receive script.
lunar pushed a commit to branch master
in repository obfs4proxy.
commit df6aeeca8cc8e953284ce1cb8a0910500579dfaf
Author: Ox Cart <ox.to.a.cart at gmail.com>
Date: Wed Oct 19 20:18:07 2016 -0500
Reusing read buffer for readPackets
---
transports/obfs4/obfs4.go | 5 +++--
transports/obfs4/packet.go | 5 ++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/transports/obfs4/obfs4.go b/transports/obfs4/obfs4.go
index 40b1406..304097e 100644
--- a/transports/obfs4/obfs4.go
+++ b/transports/obfs4/obfs4.go
@@ -265,7 +265,7 @@ func (sf *obfs4ServerFactory) WrapConn(conn net.Conn) (net.Conn, error) {
iatDist = probdist.New(sf.iatSeed, 0, maxIATDelay, biasedDist)
}
- c := &obfs4Conn{conn, true, lenDist, iatDist, sf.iatMode, bytes.NewBuffer(nil), bytes.NewBuffer(nil), nil, nil}
+ c := &obfs4Conn{conn, true, lenDist, iatDist, sf.iatMode, bytes.NewBuffer(nil), bytes.NewBuffer(nil), make([]byte, consumeReadSize), nil, nil}
startTime := time.Now()
@@ -288,6 +288,7 @@ type obfs4Conn struct {
receiveBuffer *bytes.Buffer
receiveDecodedBuffer *bytes.Buffer
+ readBuffer []byte
encoder *framing.Encoder
decoder *framing.Decoder
@@ -311,7 +312,7 @@ func newObfs4ClientConn(conn net.Conn, args *obfs4ClientArgs) (c *obfs4Conn, err
}
// Allocate the client structure.
- c = &obfs4Conn{conn, false, lenDist, iatDist, args.iatMode, bytes.NewBuffer(nil), bytes.NewBuffer(nil), nil, nil}
+ c = &obfs4Conn{conn, false, lenDist, iatDist, args.iatMode, bytes.NewBuffer(nil), bytes.NewBuffer(nil), make([]byte, consumeReadSize), nil, nil}
// Start the handshake timeout.
deadline := time.Now().Add(clientHandshakeTimeout)
diff --git a/transports/obfs4/packet.go b/transports/obfs4/packet.go
index 461ad54..5125be6 100644
--- a/transports/obfs4/packet.go
+++ b/transports/obfs4/packet.go
@@ -110,9 +110,8 @@ func (conn *obfs4Conn) makePacket(w io.Writer, pktType uint8, data []byte, padLe
func (conn *obfs4Conn) readPackets() (err error) {
// Attempt to read off the network.
- var buf [consumeReadSize]byte
- rdLen, rdErr := conn.Conn.Read(buf[:])
- conn.receiveBuffer.Write(buf[:rdLen])
+ rdLen, rdErr := conn.Conn.Read(conn.readBuffer)
+ conn.receiveBuffer.Write(conn.readBuffer[:rdLen])
var decoded [framing.MaximumFramePayloadLength]byte
for conn.receiveBuffer.Len() > 0 {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/obfs4proxy.git
More information about the Pkg-privacy-commits
mailing list