From 6a90ce3c43db5a631becf8167791db0c8a78dd34 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Fri, 21 Apr 2017 15:36:05 +0200 Subject: [PATCH] comments --- app/proxyman/inbound/worker.go | 1 + app/proxyman/mux/writer.go | 1 + common/buf/buffered_writer.go | 1 + common/buf/writer.go | 2 ++ common/crypto/auth.go | 1 + proxy/shadowsocks/ota.go | 1 + proxy/shadowsocks/protocol.go | 1 + proxy/socks/protocol.go | 1 + transport/internet/headers/http/http.go | 1 + transport/internet/headers/noop/noop.go | 2 ++ transport/internet/headers/srtp/srtp.go | 1 + transport/internet/headers/utp/utp.go | 1 + transport/internet/headers/wechat/wechat.go | 1 + transport/internet/kcp/connection_test.go | 1 + transport/internet/kcp/dialer.go | 1 + transport/internet/websocket/connection.go | 1 + 16 files changed, 18 insertions(+) diff --git a/app/proxyman/inbound/worker.go b/app/proxyman/inbound/worker.go index 2ffb6cdf..c257303e 100644 --- a/app/proxyman/inbound/worker.go +++ b/app/proxyman/inbound/worker.go @@ -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 { diff --git a/app/proxyman/mux/writer.go b/app/proxyman/mux/writer.go index cd82107d..57dbd4a3 100644 --- a/app/proxyman/mux/writer.go +++ b/app/proxyman/mux/writer.go @@ -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() diff --git a/common/buf/buffered_writer.go b/common/buf/buffered_writer.go index cae5945d..196e6a39 100644 --- a/common/buf/buffered_writer.go +++ b/common/buf/buffered_writer.go @@ -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) diff --git a/common/buf/writer.go b/common/buf/writer.go index da777619..16149d61 100644 --- a/common/buf/writer.go +++ b/common/buf/writer.go @@ -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; { diff --git a/common/crypto/auth.go b/common/crypto/auth.go index a0f14288..0092e773 100644 --- a/common/crypto/auth.go +++ b/common/crypto/auth.go @@ -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 { diff --git a/proxy/shadowsocks/ota.go b/proxy/shadowsocks/ota.go index 85b99afa..eb8e3707 100644 --- a/proxy/shadowsocks/ota.go +++ b/proxy/shadowsocks/ota.go @@ -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() diff --git a/proxy/shadowsocks/protocol.go b/proxy/shadowsocks/protocol.go index baaab768..a5c4a892 100644 --- a/proxy/shadowsocks/protocol.go +++ b/proxy/shadowsocks/protocol.go @@ -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 { diff --git a/proxy/socks/protocol.go b/proxy/socks/protocol.go index 2529a7f2..520dbd3d 100644 --- a/proxy/socks/protocol.go +++ b/proxy/socks/protocol.go @@ -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() diff --git a/transport/internet/headers/http/http.go b/transport/internet/headers/http/http.go index d10ad086..012503e6 100644 --- a/transport/internet/headers/http/http.go +++ b/transport/internet/headers/http/http.go @@ -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) diff --git a/transport/internet/headers/noop/noop.go b/transport/internet/headers/noop/noop.go index 4b849231..9d1dd711 100644 --- a/transport/internet/headers/noop/noop.go +++ b/transport/internet/headers/noop/noop.go @@ -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 } diff --git a/transport/internet/headers/srtp/srtp.go b/transport/internet/headers/srtp/srtp.go index 75a1698d..0dffab54 100644 --- a/transport/internet/headers/srtp/srtp.go +++ b/transport/internet/headers/srtp/srtp.go @@ -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]) diff --git a/transport/internet/headers/utp/utp.go b/transport/internet/headers/utp/utp.go index 1eb7695b..ec335eab 100644 --- a/transport/internet/headers/utp/utp.go +++ b/transport/internet/headers/utp/utp.go @@ -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 diff --git a/transport/internet/headers/wechat/wechat.go b/transport/internet/headers/wechat/wechat.go index 2995d359..52edb9f8 100644 --- a/transport/internet/headers/wechat/wechat.go +++ b/transport/internet/headers/wechat/wechat.go @@ -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) diff --git a/transport/internet/kcp/connection_test.go b/transport/internet/kcp/connection_test.go index ae660622..231f6e32 100644 --- a/transport/internet/kcp/connection_test.go +++ b/transport/internet/kcp/connection_test.go @@ -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 } diff --git a/transport/internet/kcp/dialer.go b/transport/internet/kcp/dialer.go index a39b07d7..f6d390f6 100644 --- a/transport/internet/kcp/dialer.go +++ b/transport/internet/kcp/dialer.go @@ -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() diff --git a/transport/internet/websocket/connection.go b/transport/internet/websocket/connection.go index 3523acee..01bfccef 100644 --- a/transport/internet/websocket/connection.go +++ b/transport/internet/websocket/connection.go @@ -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