mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
remove PacketPaddingContainer abstraction
This commit is contained in:
parent
955cbc847a
commit
1bc310c2e9
6 changed files with 42 additions and 62 deletions
|
@ -13,21 +13,19 @@ type PaddableConnection interface {
|
|||
ReadWriteCloserPreservesBoundary
|
||||
}
|
||||
|
||||
func NewPaddableConnection(rwc ReadWriteCloserPreservesBoundary, padding PacketPaddingContainer) PaddableConnection {
|
||||
func NewPaddableConnection(rwc ReadWriteCloserPreservesBoundary) PaddableConnection {
|
||||
return &paddableConnection{
|
||||
ReadWriteCloserPreservesBoundary: rwc,
|
||||
padding: padding,
|
||||
}
|
||||
}
|
||||
|
||||
type paddableConnection struct {
|
||||
ReadWriteCloserPreservesBoundary
|
||||
padding PacketPaddingContainer
|
||||
}
|
||||
|
||||
func (c *paddableConnection) Write(p []byte) (n int, err error) {
|
||||
dataLen := len(p)
|
||||
if _, err = c.ReadWriteCloserPreservesBoundary.Write(c.padding.Pack(p, 0)); err != nil {
|
||||
if _, err = c.ReadWriteCloserPreservesBoundary.Write(Pack(p, 0)); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return dataLen, nil
|
||||
|
@ -38,7 +36,7 @@ func (c *paddableConnection) Read(p []byte) (n int, err error) {
|
|||
return 0, err
|
||||
}
|
||||
|
||||
payload, _ := c.padding.Unpack(p[:n])
|
||||
payload, _ := Unpack(p[:n])
|
||||
if payload != nil {
|
||||
copy(p, payload)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue