Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: minor edits to the Go reference doc #71

Merged
merged 3 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions network/lwip2transport/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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/
Expand Down
2 changes: 1 addition & 1 deletion transport/shadowsocks/cipher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion transport/shadowsocks/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion transport/shadowsocks/salt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//
Expand Down
9 changes: 5 additions & 4 deletions transport/shadowsocks/stream_dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -56,13 +57,13 @@ type StreamDialer struct {
// expect the server to send data first, in which case there is no client payload.
// We therefore use a short delay by default (10ms), longer than any reasonable IPC but shorter than
// typical network latency. (In an Android emulator, the 90th percentile delay
// was ~1 ms.) If no client payload is received by this time, we connect without it.
// is ~1 ms.) If no client payload is received by this time, we connect without it.
hilary-ops marked this conversation as resolved.
Show resolved Hide resolved
jyyi1 marked this conversation as resolved.
Show resolved Hide resolved
ClientDataWait time.Duration
}

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"
Expand Down
2 changes: 1 addition & 1 deletion transport/socks5/socks5.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion transport/socks5/stream_dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions transport/split/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down