1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 09:36:34 -05:00
This commit is contained in:
Darien Raymond 2017-04-21 15:36:05 +02:00
parent 498c7dafdf
commit 6a90ce3c43
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
16 changed files with 18 additions and 0 deletions

View File

@ -135,6 +135,7 @@ func (c *udpConn) Read(buf []byte) (int, error) {
return copy(buf, in.Bytes()), nil
}
// Write implements io.Writer.
func (c *udpConn) Write(buf []byte) (int, error) {
n, err := c.output(buf)
if err == nil {

View File

@ -76,6 +76,7 @@ func (w *Writer) writeData(mb buf.MultiBuffer) error {
return w.writer.Write(mb2)
}
// Write implements buf.MultiBufferWriter.
func (w *Writer) Write(mb buf.MultiBuffer) error {
if mb.IsEmpty() {
return w.writeMetaOnly()

View File

@ -19,6 +19,7 @@ func NewBufferedWriter(rawWriter io.Writer) *BufferedWriter {
}
}
// Write implements io.Writer.
func (v *BufferedWriter) Write(b []byte) (int, error) {
if !v.buffered || v.buffer == nil {
return v.writer.Write(b)

View File

@ -20,6 +20,7 @@ type writerAdapter struct {
writer MultiBufferWriter
}
// Write implements buf.MultiBufferWriter.
func (w *writerAdapter) Write(mb MultiBuffer) error {
_, err := w.writer.WriteMultiBuffer(mb)
return err
@ -65,6 +66,7 @@ type bytesToBufferWriter struct {
writer Writer
}
// Write implements io.Writer.
func (w *bytesToBufferWriter) Write(payload []byte) (int, error) {
mb := NewMultiBuffer()
for p := payload; len(p) > 0; {

View File

@ -232,6 +232,7 @@ func NewAuthenticationWriter(auth Authenticator, writer io.Writer, sizeMask Uint
}
}
// Write implements io.Writer.
func (w *AuthenticationWriter) Write(b []byte) (int, error) {
cipherChunk, err := w.auth.Seal(w.buffer[2:2], b)
if err != nil {

View File

@ -117,6 +117,7 @@ func NewChunkWriter(writer io.Writer, auth *Authenticator) *ChunkWriter {
}
}
// Write implements buf.MultiBufferWriter.
func (w *ChunkWriter) Write(mb buf.MultiBuffer) error {
defer mb.Release()

View File

@ -382,6 +382,7 @@ type UDPWriter struct {
Request *protocol.RequestHeader
}
// Write implements io.Writer.
func (w *UDPWriter) Write(payload []byte) (int, error) {
packet, err := EncodeUDPPacket(w.Request, payload)
if err != nil {

View File

@ -369,6 +369,7 @@ func NewUDPWriter(request *protocol.RequestHeader, writer io.Writer) *UDPWriter
}
}
// Write implements io.Writer.
func (w *UDPWriter) Write(b []byte) (int, error) {
eb := EncodeUDPPacket(w.request, b)
defer eb.Release()

View File

@ -145,6 +145,7 @@ func (c *HttpConn) Read(b []byte) (int, error) {
return c.Conn.Read(b)
}
// Write implements io.Writer.
func (c *HttpConn) Write(b []byte) (int, error) {
if c.oneTimeWriter != nil {
err := c.oneTimeWriter.Write(c.Conn)

View File

@ -12,6 +12,8 @@ type NoOpHeader struct{}
func (NoOpHeader) Size() int {
return 0
}
// Write implements io.Writer.
func (NoOpHeader) Write([]byte) (int, error) {
return 0, nil
}

View File

@ -17,6 +17,7 @@ func (*SRTP) Size() int {
return 4
}
// Write implements io.Writer.
func (s *SRTP) Write(b []byte) (int, error) {
s.number++
serial.Uint16ToBytes(s.number, b[:0])

View File

@ -18,6 +18,7 @@ func (*UTP) Size() int {
return 4
}
// Write implements io.Writer.
func (u *UTP) Write(b []byte) (int, error) {
serial.Uint16ToBytes(u.connectionId, b[:0])
b[2] = u.header

View File

@ -16,6 +16,7 @@ func (vc *VideoChat) Size() int {
return 13
}
// Write implements io.Writer.
func (vc *VideoChat) Write(b []byte) (int, error) {
vc.sn++
b = append(b[:0], 0xa1, 0x08)

View File

@ -15,6 +15,7 @@ func (o *NoOpConn) Overhead() int {
return 0
}
// Write implements io.Writer.
func (o *NoOpConn) Write(b []byte) (int, error) {
return len(b), nil
}

View File

@ -38,6 +38,7 @@ func (c *ClientConnection) Overhead() int {
return c.writer.Overhead()
}
// Write implements io.Writer.
func (c *ClientConnection) Write(b []byte) (int, error) {
c.RLock()
defer c.RUnlock()

View File

@ -61,6 +61,7 @@ func (c *connection) getReader() (io.Reader, error) {
return reader, nil
}
// Write implements io.Writer.
func (c *connection) Write(b []byte) (int, error) {
if err := c.wsc.WriteMessage(websocket.BinaryMessage, b); err != nil {
return 0, err