mirror of https://github.com/v2ray/v2ray-core
comments
parent
498c7dafdf
commit
6a90ce3c43
|
@ -135,6 +135,7 @@ func (c *udpConn) Read(buf []byte) (int, error) {
|
||||||
return copy(buf, in.Bytes()), nil
|
return copy(buf, in.Bytes()), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write implements io.Writer.
|
||||||
func (c *udpConn) Write(buf []byte) (int, error) {
|
func (c *udpConn) Write(buf []byte) (int, error) {
|
||||||
n, err := c.output(buf)
|
n, err := c.output(buf)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
|
@ -76,6 +76,7 @@ func (w *Writer) writeData(mb buf.MultiBuffer) error {
|
||||||
return w.writer.Write(mb2)
|
return w.writer.Write(mb2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write implements buf.MultiBufferWriter.
|
||||||
func (w *Writer) Write(mb buf.MultiBuffer) error {
|
func (w *Writer) Write(mb buf.MultiBuffer) error {
|
||||||
if mb.IsEmpty() {
|
if mb.IsEmpty() {
|
||||||
return w.writeMetaOnly()
|
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) {
|
func (v *BufferedWriter) Write(b []byte) (int, error) {
|
||||||
if !v.buffered || v.buffer == nil {
|
if !v.buffered || v.buffer == nil {
|
||||||
return v.writer.Write(b)
|
return v.writer.Write(b)
|
||||||
|
|
|
@ -20,6 +20,7 @@ type writerAdapter struct {
|
||||||
writer MultiBufferWriter
|
writer MultiBufferWriter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write implements buf.MultiBufferWriter.
|
||||||
func (w *writerAdapter) Write(mb MultiBuffer) error {
|
func (w *writerAdapter) Write(mb MultiBuffer) error {
|
||||||
_, err := w.writer.WriteMultiBuffer(mb)
|
_, err := w.writer.WriteMultiBuffer(mb)
|
||||||
return err
|
return err
|
||||||
|
@ -65,6 +66,7 @@ type bytesToBufferWriter struct {
|
||||||
writer Writer
|
writer Writer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write implements io.Writer.
|
||||||
func (w *bytesToBufferWriter) Write(payload []byte) (int, error) {
|
func (w *bytesToBufferWriter) Write(payload []byte) (int, error) {
|
||||||
mb := NewMultiBuffer()
|
mb := NewMultiBuffer()
|
||||||
for p := payload; len(p) > 0; {
|
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) {
|
func (w *AuthenticationWriter) Write(b []byte) (int, error) {
|
||||||
cipherChunk, err := w.auth.Seal(w.buffer[2:2], b)
|
cipherChunk, err := w.auth.Seal(w.buffer[2:2], b)
|
||||||
if err != nil {
|
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 {
|
func (w *ChunkWriter) Write(mb buf.MultiBuffer) error {
|
||||||
defer mb.Release()
|
defer mb.Release()
|
||||||
|
|
||||||
|
|
|
@ -382,6 +382,7 @@ type UDPWriter struct {
|
||||||
Request *protocol.RequestHeader
|
Request *protocol.RequestHeader
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write implements io.Writer.
|
||||||
func (w *UDPWriter) Write(payload []byte) (int, error) {
|
func (w *UDPWriter) Write(payload []byte) (int, error) {
|
||||||
packet, err := EncodeUDPPacket(w.Request, payload)
|
packet, err := EncodeUDPPacket(w.Request, payload)
|
||||||
if err != nil {
|
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) {
|
func (w *UDPWriter) Write(b []byte) (int, error) {
|
||||||
eb := EncodeUDPPacket(w.request, b)
|
eb := EncodeUDPPacket(w.request, b)
|
||||||
defer eb.Release()
|
defer eb.Release()
|
||||||
|
|
|
@ -145,6 +145,7 @@ func (c *HttpConn) Read(b []byte) (int, error) {
|
||||||
return c.Conn.Read(b)
|
return c.Conn.Read(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write implements io.Writer.
|
||||||
func (c *HttpConn) Write(b []byte) (int, error) {
|
func (c *HttpConn) Write(b []byte) (int, error) {
|
||||||
if c.oneTimeWriter != nil {
|
if c.oneTimeWriter != nil {
|
||||||
err := c.oneTimeWriter.Write(c.Conn)
|
err := c.oneTimeWriter.Write(c.Conn)
|
||||||
|
|
|
@ -12,6 +12,8 @@ type NoOpHeader struct{}
|
||||||
func (NoOpHeader) Size() int {
|
func (NoOpHeader) Size() int {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write implements io.Writer.
|
||||||
func (NoOpHeader) Write([]byte) (int, error) {
|
func (NoOpHeader) Write([]byte) (int, error) {
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ func (*SRTP) Size() int {
|
||||||
return 4
|
return 4
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write implements io.Writer.
|
||||||
func (s *SRTP) Write(b []byte) (int, error) {
|
func (s *SRTP) Write(b []byte) (int, error) {
|
||||||
s.number++
|
s.number++
|
||||||
serial.Uint16ToBytes(s.number, b[:0])
|
serial.Uint16ToBytes(s.number, b[:0])
|
||||||
|
|
|
@ -18,6 +18,7 @@ func (*UTP) Size() int {
|
||||||
return 4
|
return 4
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write implements io.Writer.
|
||||||
func (u *UTP) Write(b []byte) (int, error) {
|
func (u *UTP) Write(b []byte) (int, error) {
|
||||||
serial.Uint16ToBytes(u.connectionId, b[:0])
|
serial.Uint16ToBytes(u.connectionId, b[:0])
|
||||||
b[2] = u.header
|
b[2] = u.header
|
||||||
|
|
|
@ -16,6 +16,7 @@ func (vc *VideoChat) Size() int {
|
||||||
return 13
|
return 13
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write implements io.Writer.
|
||||||
func (vc *VideoChat) Write(b []byte) (int, error) {
|
func (vc *VideoChat) Write(b []byte) (int, error) {
|
||||||
vc.sn++
|
vc.sn++
|
||||||
b = append(b[:0], 0xa1, 0x08)
|
b = append(b[:0], 0xa1, 0x08)
|
||||||
|
|
|
@ -15,6 +15,7 @@ func (o *NoOpConn) Overhead() int {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write implements io.Writer.
|
||||||
func (o *NoOpConn) Write(b []byte) (int, error) {
|
func (o *NoOpConn) Write(b []byte) (int, error) {
|
||||||
return len(b), nil
|
return len(b), nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ func (c *ClientConnection) Overhead() int {
|
||||||
return c.writer.Overhead()
|
return c.writer.Overhead()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write implements io.Writer.
|
||||||
func (c *ClientConnection) Write(b []byte) (int, error) {
|
func (c *ClientConnection) Write(b []byte) (int, error) {
|
||||||
c.RLock()
|
c.RLock()
|
||||||
defer c.RUnlock()
|
defer c.RUnlock()
|
||||||
|
|
|
@ -61,6 +61,7 @@ func (c *connection) getReader() (io.Reader, error) {
|
||||||
return reader, nil
|
return reader, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write implements io.Writer.
|
||||||
func (c *connection) Write(b []byte) (int, error) {
|
func (c *connection) Write(b []byte) (int, error) {
|
||||||
if err := c.wsc.WriteMessage(websocket.BinaryMessage, b); err != nil {
|
if err := c.wsc.WriteMessage(websocket.BinaryMessage, b); err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
|
|
Loading…
Reference in New Issue