From f3da0edd196f644962f3560cacf0e6d8123d039a Mon Sep 17 00:00:00 2001 From: hilary-ops <70233933+hilary-ops@users.noreply.github.com> Date: Fri, 13 Oct 2023 13:37:53 -0400 Subject: [PATCH] chore: minor edits to the Go reference doc (#71) --- network/lwip2transport/device.go | 4 ++-- transport/shadowsocks/cipher.go | 2 +- transport/shadowsocks/packet.go | 2 +- transport/shadowsocks/salt.go | 2 +- transport/shadowsocks/stream_dialer.go | 7 ++++--- transport/socks5/socks5.go | 2 +- transport/socks5/stream_dialer.go | 2 +- transport/split/writer.go | 4 ++-- 8 files changed, 13 insertions(+), 12 deletions(-) diff --git a/network/lwip2transport/device.go b/network/lwip2transport/device.go index 20591fb1..d590beec 100644 --- a/network/lwip2transport/device.go +++ b/network/lwip2transport/device.go @@ -53,7 +53,7 @@ var inst *lwIPDevice = nil // [lwIP library] to perform the translation. // // LwIP device must be a singleton object due to limitations in [lwIP library]. If you try to call ConfigureDevice more -// than once, we will Close the previous device and reconfigures it. +// than once, we will Close the previous device and reconfigure it. // // To use a LwIP device: // 1. Call [ConfigureDevice] with two handlers for TCP and UDP traffic. @@ -62,7 +62,7 @@ var inst *lwIPDevice = nil // 3. Read IP packets from the device to get the TCP/UDP responses. // // A LwIP device is NOT thread-safe. However it is safe to use Write, Read/WriteTo and Close in different goroutines. -// But keep in mind that only one goroutine can call Write at a time; and only one goroutine can use either Read or +// Keep in mind that only one goroutine can call Write at a time, and only one goroutine can use either Read or // WriteTo at a time. // // [lwIP library]: https://savannah.nongnu.org/projects/lwip/ diff --git a/transport/shadowsocks/cipher.go b/transport/shadowsocks/cipher.go index 4efd91ef..2dbf53ea 100644 --- a/transport/shadowsocks/cipher.go +++ b/transport/shadowsocks/cipher.go @@ -137,7 +137,7 @@ func simpleEVPBytesToKey(data []byte, keyLen int) ([]byte, error) { return derived[:keyLen], nil } -// NewEncryptionKey creates a Cipher given a cipher name and a secret. +// NewEncryptionKey creates a Cipher with a cipher name and a secret. // The cipher name must be the IETF name (as per https://www.iana.org/assignments/aead-parameters/aead-parameters.xhtml) // or the Shadowsocks alias from https://shadowsocks.org/guide/aead.html. func NewEncryptionKey(cipherName string, secretText string) (*EncryptionKey, error) { diff --git a/transport/shadowsocks/packet.go b/transport/shadowsocks/packet.go index 270d6365..23a7bada 100644 --- a/transport/shadowsocks/packet.go +++ b/transport/shadowsocks/packet.go @@ -19,7 +19,7 @@ import ( "io" ) -// ErrShortPacket indicates the destination packet given to Unpack is too short. +// ErrShortPacket indicates that the destination packet given to Unpack is too short. var ErrShortPacket = errors.New("short packet") // Assumes all ciphers have NonceSize() <= 12. diff --git a/transport/shadowsocks/salt.go b/transport/shadowsocks/salt.go index ead5bffd..4902822a 100644 --- a/transport/shadowsocks/salt.go +++ b/transport/shadowsocks/salt.go @@ -50,7 +50,7 @@ func (g prefixSaltGenerator) GetSalt(salt []byte) error { return err } -// NewPrefixSaltGenerator returns a SaltGenerator whose output consists of +// NewPrefixSaltGenerator returns a SaltGenerator with output including // the provided prefix, followed by random bytes. This is useful to change // how shadowsocks traffic is classified by middleboxes. // diff --git a/transport/shadowsocks/stream_dialer.go b/transport/shadowsocks/stream_dialer.go index 0bf04655..8749e73f 100644 --- a/transport/shadowsocks/stream_dialer.go +++ b/transport/shadowsocks/stream_dialer.go @@ -41,11 +41,12 @@ type StreamDialer struct { key *EncryptionKey // SaltGenerator is used by Shadowsocks to generate the connection salts. - // `SaltGenerator` may be `nil`, which defaults to [shadowsocks.RandomSaltGenerator]. + // `SaltGenerator` can be `nil`, which defaults to [shadowsocks.RandomSaltGenerator]. SaltGenerator SaltGenerator // ClientDataWait specifies the amount of time to wait for client data before sending - // the Shadowsocks connection request to the proxy server. It's 10 milliseconds by default. + // the Shadowsocks connection request to the proxy server. This value is 10 milliseconds + // by default. // // StreamDialer has an optimization to send the initial client payload along with // the Shadowsocks connection request. This saves one packet during connection, and also @@ -62,7 +63,7 @@ type StreamDialer struct { var _ transport.StreamDialer = (*StreamDialer)(nil) -// Dial implements StreamDialer.Dial via a Shadowsocks server. +// Dial implements StreamDialer.Dial using a Shadowsocks server. // // The Shadowsocks StreamDialer returns a connection after the connection to the proxy is established, // but before the connection to the target is established. That means we cannot signal "connection refused" diff --git a/transport/socks5/socks5.go b/transport/socks5/socks5.go index 18ca51a0..3e9f3ad2 100644 --- a/transport/socks5/socks5.go +++ b/transport/socks5/socks5.go @@ -21,7 +21,7 @@ import ( "strconv" ) -// ReplyCode is byte unsigned number that represents a SOCKS error as indicated in the REP field of the server response. +// ReplyCode is a byte-unsigned number that represents a SOCKS error as indicated in the REP field of the server response. type ReplyCode byte // SOCKS reply codes, as enumerated in https://datatracker.ietf.org/doc/html/rfc1928#section-6. diff --git a/transport/socks5/stream_dialer.go b/transport/socks5/stream_dialer.go index aac3cc7b..14743d34 100644 --- a/transport/socks5/stream_dialer.go +++ b/transport/socks5/stream_dialer.go @@ -56,7 +56,7 @@ func (c *streamDialer) Dial(ctx context.Context, remoteAddr string) (transport.S // For protocol details, see https://datatracker.ietf.org/doc/html/rfc1928#section-3 - // Buffer large enough for method and connect requests with a domain name address + // Buffer large enough for method and connect requests with a domain name address. header := [3 + 4 + 256 + 2]byte{} // Method request: diff --git a/transport/split/writer.go b/transport/split/writer.go index cc3f19ff..430a9bbd 100644 --- a/transport/split/writer.go +++ b/transport/split/writer.go @@ -27,8 +27,8 @@ type SplitWriter struct { var _ io.Writer = (*SplitWriter)(nil) var _ io.ReaderFrom = (*SplitWriter)(nil) -// NewWriter creates a [io.Writer] that ensures the byte sequence is split at prefixBytes, -// meaning a write will end right after byte index prefixBytes - 1, before a write starting at byte index prefixBytes. +// NewWriter creates a [io.Writer] that ensures the byte sequence is split at prefixBytes. +// A write will end right after byte index prefixBytes - 1, before a write starting at byte index prefixBytes. // For example, if you have a write of [0123456789] and prefixBytes = 3, you will get writes [012] and [3456789]. func NewWriter(writer io.Writer, prefixBytes int64) *SplitWriter { return &SplitWriter{writer, prefixBytes}