mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-21 09:36:34 -05:00
comments
This commit is contained in:
parent
498c7dafdf
commit
6a90ce3c43
@ -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 {
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
@ -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; {
|
||||
|
@ -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 {
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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])
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user