mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 11:11:30 -04:00
Have encapsulation.ReadData read into a provided buffer.
Instead of unconditionally allocating its own.
This commit is contained in:
parent
648609dbea
commit
001f691b47
4 changed files with 122 additions and 58 deletions
|
@ -37,11 +37,11 @@ func newEncapsulationPacketConn(
|
|||
|
||||
// ReadFrom reads an encapsulated packet from the stream.
|
||||
func (c *encapsulationPacketConn) ReadFrom(p []byte) (int, net.Addr, error) {
|
||||
data, err := encapsulation.ReadData(c.ReadWriteCloser)
|
||||
n, err := encapsulation.ReadData(c.ReadWriteCloser, p)
|
||||
if err != nil {
|
||||
return 0, c.remoteAddr, err
|
||||
return n, c.remoteAddr, err
|
||||
}
|
||||
return copy(p, data), c.remoteAddr, nil
|
||||
return n, c.remoteAddr, nil
|
||||
}
|
||||
|
||||
// WriteTo writes an encapsulated packet to the stream.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue