Skip to content

Commit

Permalink
Fix Typos
Browse files Browse the repository at this point in the history
Fix Typos
  • Loading branch information
stv0g committed Nov 16, 2022
1 parent 611de07 commit 8c5d1fd
Show file tree
Hide file tree
Showing 19 changed files with 51 additions and 51 deletions.
8 changes: 4 additions & 4 deletions connctx/connctx_test.go
Expand Up @@ -56,7 +56,7 @@ func TestReadTImeout(t *testing.T) {
b := make([]byte, 100)
n, err := c.ReadContext(ctx, b)
if err == nil {
t.Error("Read unexpectedly successed")
t.Error("Read unexpectedly succeeded")
}
if n != 0 {
t.Errorf("Wrong data length, expected %d, got %d", 0, n)
Expand All @@ -79,7 +79,7 @@ func TestReadCancel(t *testing.T) {
b := make([]byte, 100)
n, err := c.ReadContext(ctx, b)
if err == nil {
t.Error("Read unexpectedly successed")
t.Error("Read unexpectedly succeeded")
}
if n != 0 {
t.Errorf("Wrong data length, expected %d, got %d", 0, n)
Expand Down Expand Up @@ -151,7 +151,7 @@ func TestWriteTimeout(t *testing.T) {
b := make([]byte, 100)
n, err := c.WriteContext(ctx, b)
if err == nil {
t.Error("Write unexpectedly successed")
t.Error("Write unexpectedly succeeded")
}
if n != 0 {
t.Errorf("Wrong data length, expected %d, got %d", 0, n)
Expand All @@ -174,7 +174,7 @@ func TestWriteCancel(t *testing.T) {
b := make([]byte, 100)
n, err := c.WriteContext(ctx, b)
if err == nil {
t.Error("Write unexpectedly successed")
t.Error("Write unexpectedly succeeded")
}
if n != 0 {
t.Errorf("Wrong data length, expected %d, got %d", 0, n)
Expand Down
38 changes: 19 additions & 19 deletions packetio/buffer.go
Expand Up @@ -77,42 +77,42 @@ func (b *Buffer) available(size int) bool {
// grow increases the size of the buffer. If it returns nil, then the
// buffer has been grown. It returns ErrFull if hits a limit.
func (b *Buffer) grow() error {
var newsize int
var newSize int
if len(b.data) < cutoffSize {
newsize = 2 * len(b.data)
newSize = 2 * len(b.data)
} else {
newsize = 5 * len(b.data) / 4
newSize = 5 * len(b.data) / 4
}
if newsize < minSize {
newsize = minSize
if newSize < minSize {
newSize = minSize
}
if (b.limitSize <= 0 || sizeHardlimit) && newsize > maxSize {
newsize = maxSize
if (b.limitSize <= 0 || sizeHardLimit) && newSize > maxSize {
newSize = maxSize
}

// one byte slack
if b.limitSize > 0 && newsize > b.limitSize+1 {
newsize = b.limitSize + 1
if b.limitSize > 0 && newSize > b.limitSize+1 {
newSize = b.limitSize + 1
}

if newsize <= len(b.data) {
if newSize <= len(b.data) {
return ErrFull
}

newdata := make([]byte, newsize)
newData := make([]byte, newSize)

var n int
if b.head <= b.tail {
// data was contiguous
n = copy(newdata, b.data[b.head:b.tail])
n = copy(newData, b.data[b.head:b.tail])
} else {
// data was discontiguous
n = copy(newdata, b.data[b.head:])
n += copy(newdata[n:], b.data[:b.tail])
// data was discontinuous
n = copy(newData, b.data[b.head:])
n += copy(newData[n:], b.data[:b.tail])
}
b.head = 0
b.tail = n
b.data = newdata
b.data = newData

return nil
}
Expand Down Expand Up @@ -329,9 +329,9 @@ func (b *Buffer) size() int {
// Causes Write to return ErrFull when this limit is reached.
// A zero value means 4MB since v0.11.0.
//
// User can set packetioSizeHardlimit build tag to enable 4MB hardlimit.
// When packetioSizeHardlimit build tag is set, SetLimitSize exceeding
// the hardlimit will be silently discarded.
// User can set packetioSizeHardLimit build tag to enable 4MB hard limit.
// When packetioSizeHardLimit build tag is set, SetLimitSize exceeding
// the hard limit will be silently discarded.
func (b *Buffer) SetLimitSize(limit int) {
b.mutex.Lock()
defer b.mutex.Unlock()
Expand Down
6 changes: 3 additions & 3 deletions packetio/buffer_test.go
Expand Up @@ -321,8 +321,8 @@ func TestBufferLimitSize(t *testing.T) {
}

func TestBufferLimitSizes(t *testing.T) {
if sizeHardlimit {
t.Skip("skipping since packetioSizeHardlimit is enabled")
if sizeHardLimit {
t.Skip("skipping since packetioSizeHardLimit is enabled")
}
sizes := []int{
128 * 1024,
Expand All @@ -337,7 +337,7 @@ func TestBufferLimitSizes(t *testing.T) {
size := size
name := "default"
if size > 0 {
name = fmt.Sprintf("%dkbytes", size/1024)
name = fmt.Sprintf("%dkBytes", size/1024)
}

t.Run(name, func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion packetio/hardlimit.go
Expand Up @@ -2,4 +2,4 @@

package packetio

const sizeHardlimit = true
const sizeHardLimit = true
2 changes: 1 addition & 1 deletion packetio/no_hardlimit.go
Expand Up @@ -3,4 +3,4 @@

package packetio

const sizeHardlimit = false
const sizeHardLimit = false
2 changes: 1 addition & 1 deletion replaydetector/replaydetector.go
Expand Up @@ -55,7 +55,7 @@ func (d *slidingWindowDetector) Check(seq uint64) (accept func(), ok bool) {
}

// WithWrap creates ReplayDetector allowing sequence wrapping.
// This is suitable for short bitwidth counter like SRTP and SRTCP.
// This is suitable for short bit width counter like SRTP and SRTCP.
func WithWrap(windowSize uint, maxSeq uint64) ReplayDetector {
return &wrappedSlidingWindowDetector{
maxSeq: maxSeq,
Expand Down
2 changes: 1 addition & 1 deletion replaydetector/replaydetector_test.go
Expand Up @@ -94,7 +94,7 @@ func TestReplayDetector(t *testing.T) {
[]uint64{24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128},
nil,
},
"ContinuouesReplayed": {
"ContinuousReplayed": {
8, 0x0000FFFFFFFFFFFF,
[]uint64{16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25},
[]bool{
Expand Down
2 changes: 1 addition & 1 deletion test/bridge_test.go
Expand Up @@ -469,7 +469,7 @@ func TestNetTest(t *testing.T) {
return &closePropagator{conn0, conn1}, &closePropagator{conn1, conn0},
func() {
// RacyRead test leave receive buffer filled.
// As net.Conn.Read() shoud return received data even after Close()-ed,
// As net.Conn.Read() should return received data even after Close()-ed,
// queue must be cleared explicitly.
br.clear()
_ = conn0.Close()
Expand Down
8 changes: 4 additions & 4 deletions test/util.go
Expand Up @@ -85,17 +85,17 @@ func GatherErrs(c chan error) []error {

// FlattenErrs flattens a slice of errors into a single error
func FlattenErrs(errs []error) error {
var errstrings []string
var errStrings []string

for _, err := range errs {
if err != nil {
errstrings = append(errstrings, err.Error())
errStrings = append(errStrings, err.Error())
}
}

if len(errstrings) == 0 {
if len(errStrings) == 0 {
return nil
}

return fmt.Errorf("%w %s", errFlattenErrs, strings.Join(errstrings, "\n"))
return fmt.Errorf("%w %s", errFlattenErrs, strings.Join(errStrings, "\n"))
}
4 changes: 2 additions & 2 deletions vnet/chunk_test.go
Expand Up @@ -67,7 +67,7 @@ func TestChunk(t *testing.T) {
assert.Equal(t, uc.tag, uc.Tag(), "should match")

// Verify cloned chunk was not affected by the changes to original chunk
uc.userData[0] = []byte("!")[0] // oroginal: "Hello" -> "Hell!"
uc.userData[0] = []byte("!")[0] // original: "Hello" -> "Hell!"
assert.Equal(t, "Hello", string(cloned.userData), "should match")
assert.Equal(t, "192.168.0.2:1234", cloned.SourceAddr().String())
assert.True(t, cloned.getSourceIP().Equal(src.IP), "ip should match")
Expand Down Expand Up @@ -117,7 +117,7 @@ func TestChunk(t *testing.T) {
assert.Equal(t, tc.tag, tc.Tag(), "should match")

// Verify cloned chunk was not affected by the changes to original chunk
tc.userData[0] = []byte("!")[0] // oroginal: "Hello" -> "Hell!"
tc.userData[0] = []byte("!")[0] // original: "Hello" -> "Hell!"
assert.Equal(t, "Hello", string(cloned.userData), "should match")
assert.Equal(t, "192.168.0.2:1234", cloned.SourceAddr().String())
assert.True(t, cloned.getSourceIP().Equal(src.IP), "ip should match")
Expand Down
2 changes: 1 addition & 1 deletion vnet/conn.go
Expand Up @@ -38,7 +38,7 @@ type connObserver interface {
}

// UDPConn is the implementation of the Conn and PacketConn interfaces for UDP network connections.
// comatible with net.PacketConn and net.Conn
// compatible with net.PacketConn and net.Conn
type UDPConn struct {
locAddr *net.UDPAddr // read-only
remAddr *net.UDPAddr // read-only
Expand Down
4 changes: 2 additions & 2 deletions vnet/delay_filter_test.go
Expand Up @@ -73,7 +73,7 @@ func TestDelayFilter(t *testing.T) {
}
}

// schedula 100 chunks
// schedule 100 chunks
sent := time.Now()
for i := 0; i < 100; i++ {
df.onInboundChunk(&chunkUDP{
Expand All @@ -82,7 +82,7 @@ func TestDelayFilter(t *testing.T) {
})
}

// receive 100 chunks with deay>10ms
// receive 100 chunks with delay>10ms
for i := 0; i < 100; i++ {
select {
case c := <-receiveCh:
Expand Down
8 changes: 4 additions & 4 deletions vnet/nat_test.go
Expand Up @@ -16,7 +16,7 @@ import (

const demoIP = "1.2.3.4"

func TestNATTypeDefauts(t *testing.T) {
func TestNATTypeDefaults(t *testing.T) {
loggerFactory := logging.NewDefaultLoggerFactory()
nat, err := newNAT(&natConfig{
natType: NATType{},
Expand Down Expand Up @@ -234,7 +234,7 @@ func TestNATMappingBehavior(t *testing.T) {
_, err = nat.translateInbound(iec)
assert.Nil(t, err, "should succeed")

// packet from different addr will be droped (restricted-cone)
// packet from different addr will be dropped (restricted-cone)
//nolint:forcetypeassert
iec = newChunkUDP(
&net.UDPAddr{
Expand Down Expand Up @@ -356,7 +356,7 @@ func TestNATMappingBehavior(t *testing.T) {
_, err = nat.translateInbound(iec)
assert.NotNil(t, err, "should fail (dropped)")

// packet from different addr will be droped (restricted-cone)
// packet from different addr will be dropped (restricted-cone)
//nolint:forcetypeassert
iec = newChunkUDP(
&net.UDPAddr{
Expand Down Expand Up @@ -637,7 +637,7 @@ func TestNATMappingTimeout(t *testing.T) {
})
}

func TestNAT1To1Bahavior(t *testing.T) {
func TestNAT1To1Behavior(t *testing.T) {
loggerFactory := logging.NewDefaultLoggerFactory()
log := loggerFactory.NewLogger("test")

Expand Down
4 changes: 2 additions & 2 deletions vnet/resolver.go
Expand Up @@ -11,7 +11,7 @@ import (

var (
errHostnameEmpty = errors.New("host name must not be empty")
errFailedtoParseIPAddr = errors.New("failed to parse IP address")
errFailedToParseIPAddr = errors.New("failed to parse IP address")
)

type resolverConfig struct {
Expand Down Expand Up @@ -53,7 +53,7 @@ func (r *resolver) addHost(name string, ipAddr string) error {
}
ip := net.ParseIP(ipAddr)
if ip == nil {
return fmt.Errorf("%w \"%s\"", errFailedtoParseIPAddr, ipAddr)
return fmt.Errorf("%w \"%s\"", errFailedToParseIPAddr, ipAddr)
}
r.hosts[name] = ip
return nil
Expand Down
2 changes: 1 addition & 1 deletion vnet/router.go
Expand Up @@ -331,7 +331,7 @@ func (r *Router) addNIC(nic NIC) error {
return nil
}

// AddRouter adds a chile Router.
// AddRouter adds a child Router.
func (r *Router) AddRouter(router *Router) error {
r.mutex.Lock()
defer r.mutex.Unlock()
Expand Down
2 changes: 1 addition & 1 deletion vnet/tbf.go
Expand Up @@ -43,7 +43,7 @@ func TBFQueueSizeInBytes(bytes int) TBFOption {
}
}

// TBFRate sets the bitrate of a TokenBucketFilter
// TBFRate sets the bit rate of a TokenBucketFilter
func TBFRate(rate int) TBFOption {
return func(t *TokenBucketFilter) TBFOption {
t.mutex.Lock()
Expand Down
2 changes: 1 addition & 1 deletion vnet/tbf_test.go
Expand Up @@ -98,7 +98,7 @@ func TestTokenBucketFilter(t *testing.T) {
bits := float64(bytesSent) * 8.0
rate := bits / time.Since(start).Seconds()
mBitPerSecond := rate / float64(MBit)
log.Infof("duration=%v, bytesSent=%v, pacetsSent=%v throughput=%.2f Mb/s", time.Since(start), bytesSent, packetsSent, mBitPerSecond)
log.Infof("duration=%v, bytesSent=%v, packetsSent=%v throughput=%.2f Mb/s", time.Since(start), bytesSent, packetsSent, mBitPerSecond)

assert.NoError(t, tbf.Close())
}()
Expand Down
2 changes: 1 addition & 1 deletion vnet/udpproxy_direct_test.go
Expand Up @@ -169,7 +169,7 @@ func TestUDPProxyDirectDeliverTypical(t *testing.T) {
}

// Error if deliver to invalid address.
func TestUDPProxyDirectDeliverBadcase(t *testing.T) {
func TestUDPProxyDirectDeliverBadCase(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())

var r0, r1, r2 error
Expand Down
2 changes: 1 addition & 1 deletion vnet/udpproxy_test.go
Expand Up @@ -72,7 +72,7 @@ func (v *MockUDPEchoServer) doMockUDPServer(ctx context.Context) error {
return fmt.Errorf("nn=%v, n=%v", nn, n) // nolint:goerr113
}

// Check the address, shold not change, use content as ID.
// Check the address, should not change, use content as ID.
clientID := string(buf[:n])
if oldAddr, ok := addrs[clientID]; ok && oldAddr.String() != addr.String() {
return fmt.Errorf("address change %v to %v", oldAddr.String(), addr.String()) // nolint:goerr113
Expand Down

0 comments on commit 8c5d1fd

Please sign in to comment.