Skip to content

Commit f40dd65

Browse files
committed
Fix comment capitalization
Comments should start with an uppercase letter.
1 parent f07b6d1 commit f40dd65

25 files changed

+129
-142
lines changed

agent.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ type Agent struct {
4747
onConnected chan struct{}
4848
onConnectedOnce sync.Once
4949

50-
// force candidate to be contacted immediately (instead of waiting for task ticker)
50+
// Force candidate to be contacted immediately (instead of waiting for task ticker)
5151
forceCandidateContact chan bool
5252

5353
tieBreaker uint64
@@ -718,7 +718,7 @@ func (a *Agent) checkKeepalive() {
718718
if (a.keepaliveInterval != 0) &&
719719
((time.Since(selectedPair.Local.LastSent()) > a.keepaliveInterval) ||
720720
(time.Since(selectedPair.Remote.LastReceived()) > a.keepaliveInterval)) {
721-
// we use binding request instead of indication to support refresh consent schemas
721+
// We use binding request instead of indication to support refresh consent schemas
722722
// see https://tools.ietf.org/html/rfc7675
723723
a.selector.PingCandidate(selectedPair.Local, selectedPair.Remote)
724724
}
@@ -730,7 +730,7 @@ func (a *Agent) AddRemoteCandidate(c Candidate) error {
730730
return nil
731731
}
732732

733-
// cannot check for network yet because it might not be applied
733+
// Cannot check for network yet because it might not be applied
734734
// when mDNS hostname is used.
735735
if c.TCPType() == TCPTypeActive {
736736
// TCP Candidates with TCP type active will probe server passive ones, so

agent_config.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,25 @@ const (
2525
// defaultFailedTimeout is the default time till an Agent transitions to failed after disconnected
2626
defaultFailedTimeout = 25 * time.Second
2727

28-
// wait time before nominating a host candidate
28+
// defaultHostAcceptanceMinWait is the wait time before nominating a host candidate
2929
defaultHostAcceptanceMinWait = 0
3030

31-
// wait time before nominating a srflx candidate
31+
// defaultSrflxAcceptanceMinWait is the wait time before nominating a srflx candidate
3232
defaultSrflxAcceptanceMinWait = 500 * time.Millisecond
3333

34-
// wait time before nominating a prflx candidate
34+
// defaultPrflxAcceptanceMinWait is the wait time before nominating a prflx candidate
3535
defaultPrflxAcceptanceMinWait = 1000 * time.Millisecond
3636

37-
// wait time before nominating a relay candidate
37+
// defaultRelayAcceptanceMinWait is the wait time before nominating a relay candidate
3838
defaultRelayAcceptanceMinWait = 2000 * time.Millisecond
3939

40-
// max binding request before considering a pair failed
40+
// defaultMaxBindingRequests is the maximum number of binding requests before considering a pair failed
4141
defaultMaxBindingRequests = 7
4242

43-
// the number of bytes that can be buffered before we start to error
43+
// maxBufferSize is the number of bytes that can be buffered before we start to error
4444
maxBufferSize = 1000 * 1000 // 1MB
4545

46-
// wait time before binding requests can be deleted
46+
// maxBindingRequestTimeout is the wait time before binding requests can be deleted
4747
maxBindingRequestTimeout = 4000 * time.Millisecond
4848
)
4949

@@ -245,7 +245,7 @@ func (config *AgentConfig) initExtIPMapping(a *Agent) error {
245245
return err
246246
}
247247
if a.extIPMapper == nil {
248-
return nil // this may happen when config.NAT1To1IPs is an empty array
248+
return nil // This may happen when config.NAT1To1IPs is an empty array
249249
}
250250
if a.extIPMapper.candidateType == CandidateTypeHost {
251251
if a.mDNSMode == MulticastDNSModeQueryAndGather {

agent_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func TestOnSelectedCandidatePairChange(t *testing.T) {
3838
report := test.CheckRoutines(t)
3939
defer report()
4040

41-
// avoid deadlocks?
41+
// Avoid deadlocks?
4242
defer test.TimeOut(1 * time.Second).Stop()
4343

4444
a, err := NewAgent(&AgentConfig{})
@@ -77,15 +77,15 @@ func TestOnSelectedCandidatePairChange(t *testing.T) {
7777
t.Fatalf("Failed to construct remote relay candidate: %s", err)
7878
}
7979

80-
// select the pair
80+
// Select the pair
8181
if err = a.run(context.Background(), func(ctx context.Context, agent *Agent) {
8282
p := newCandidatePair(hostLocal, relayRemote, false)
8383
agent.setSelectedPair(p)
8484
}); err != nil {
8585
t.Fatalf("Failed to setValidPair(): %s", err)
8686
}
8787

88-
// ensure that the callback fired on setting the pair
88+
// Ensure that the callback fired on setting the pair
8989
<-callbackCalled
9090
assert.NoError(t, a.Close())
9191
}
@@ -154,12 +154,12 @@ func TestHandlePeerReflexive(t *testing.T) {
154154

155155
a.handleInbound(msg, local, remote)
156156

157-
// length of remote candidate list must be one now
157+
// Length of remote candidate list must be one now
158158
if len(a.remoteCandidates) != 1 {
159159
t.Fatal("failed to add a network type to the remote candidate list")
160160
}
161161

162-
// length of remote candidate list for a network type must be 1
162+
// Length of remote candidate list for a network type must be 1
163163
set := a.remoteCandidates[local.NetworkType()]
164164
if len(set) != 1 {
165165
t.Fatal("failed to add prflx candidate to remote candidate list")
@@ -247,7 +247,7 @@ func TestHandlePeerReflexive(t *testing.T) {
247247
}
248248

249249
// Assert that Agent on startup sends message, and doesn't wait for connectivityTicker to fire
250-
// github.com/pion/ice/issues/15
250+
// https://github.com/pion/ice/issues/15
251251
func TestConnectivityOnStartup(t *testing.T) {
252252
report := test.CheckRoutines(t)
253253
defer report()
@@ -685,7 +685,7 @@ func TestCandidatePairStats(t *testing.T) {
685685
report := test.CheckRoutines(t)
686686
defer report()
687687

688-
// avoid deadlocks?
688+
// Avoid deadlocks?
689689
defer test.TimeOut(1 * time.Second).Stop()
690690

691691
a, err := NewAgent(&AgentConfig{})
@@ -818,7 +818,7 @@ func TestLocalCandidateStats(t *testing.T) {
818818
report := test.CheckRoutines(t)
819819
defer report()
820820

821-
// avoid deadlocks?
821+
// Avoid deadlocks?
822822
defer test.TimeOut(1 * time.Second).Stop()
823823

824824
a, err := NewAgent(&AgentConfig{})
@@ -899,7 +899,7 @@ func TestRemoteCandidateStats(t *testing.T) {
899899
report := test.CheckRoutines(t)
900900
defer report()
901901

902-
// avoid deadlocks?
902+
// Avoid deadlocks?
903903
defer test.TimeOut(1 * time.Second).Stop()
904904

905905
a, err := NewAgent(&AgentConfig{})
@@ -1077,7 +1077,7 @@ func TestInitExtIPMapping(t *testing.T) {
10771077

10781078
// NewAgent should return if newExternalIPMapper() returns an error.
10791079
_, err = NewAgent(&AgentConfig{
1080-
NAT1To1IPs: []string{"bad.2.3.4"}, // bad IP
1080+
NAT1To1IPs: []string{"bad.2.3.4"}, // Bad IP
10811081
NAT1To1IPCandidateType: CandidateTypeHost,
10821082
})
10831083
if !errors.Is(err, ErrInvalidNAT1To1IPMapping) {
@@ -1096,16 +1096,16 @@ func TestBindingRequestTimeout(t *testing.T) {
10961096

10971097
now := time.Now()
10981098
a.pendingBindingRequests = append(a.pendingBindingRequests, bindingRequest{
1099-
timestamp: now, // valid
1099+
timestamp: now, // Valid
11001100
})
11011101
a.pendingBindingRequests = append(a.pendingBindingRequests, bindingRequest{
1102-
timestamp: now.Add(-3900 * time.Millisecond), // valid
1102+
timestamp: now.Add(-3900 * time.Millisecond), // Valid
11031103
})
11041104
a.pendingBindingRequests = append(a.pendingBindingRequests, bindingRequest{
1105-
timestamp: now.Add(-4100 * time.Millisecond), // invalid
1105+
timestamp: now.Add(-4100 * time.Millisecond), // Invalid
11061106
})
11071107
a.pendingBindingRequests = append(a.pendingBindingRequests, bindingRequest{
1108-
timestamp: now.Add(-75 * time.Hour), // invalid
1108+
timestamp: now.Add(-75 * time.Hour), // Invalid
11091109
})
11101110

11111111
a.invalidatePendingBindingRequests(now)

agent_udpmux_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func TestMuxAgent(t *testing.T) {
6464
require.NotNil(t, pair)
6565
require.Equal(t, muxPort, pair.Local.Port())
6666

67-
// send a packet to Mux
67+
// Send a packet to Mux
6868
data := []byte("hello world")
6969
_, err = conn.Write(data)
7070
require.NoError(t, err)
@@ -74,24 +74,24 @@ func TestMuxAgent(t *testing.T) {
7474
require.NoError(t, err)
7575
require.Equal(t, data, buf[:n])
7676

77-
// send a packet from Mux
77+
// Send a packet from Mux
7878
_, err = muxedConn.Write(data)
7979
require.NoError(t, err)
8080

8181
n, err = conn.Read(buf)
8282
require.NoError(t, err)
8383
require.Equal(t, data, buf[:n])
8484

85-
// close it down
85+
// Close it down
8686
require.NoError(t, conn.Close())
8787
require.NoError(t, muxedConn.Close())
8888
require.NoError(t, udpMux.Close())
8989

90-
// expect error when reading from closed mux
90+
// Expect error when reading from closed mux
9191
_, err = muxedConn.Read(data)
9292
require.Error(t, err)
9393

94-
// expect error when writing to closed mux
94+
// Expect error when writing to closed mux
9595
_, err = muxedConn.Write(data)
9696
require.Error(t, err)
9797
})

connectivity_vnet_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ type virtualNet struct {
4141
}
4242

4343
func (v *virtualNet) close() {
44-
v.server.Close() // nolint:errcheck,gosec
45-
v.wan.Stop() // nolint:errcheck,gosec
44+
v.server.Close() //nolint:errcheck,gosec
45+
v.wan.Stop() //nolint:errcheck,gosec
4646
}
4747

4848
func buildVNet(natType0, natType1 *vnet.NATType) (*virtualNet, error) {
@@ -58,7 +58,7 @@ func buildVNet(natType0, natType1 *vnet.NATType) (*virtualNet, error) {
5858
}
5959

6060
wanNet, err := vnet.NewNet(&vnet.NetConfig{
61-
StaticIP: vnetSTUNServerIP, // will be assigned to eth0
61+
StaticIP: vnetSTUNServerIP, // Will be assigned to eth0
6262
})
6363
if err != nil {
6464
return nil, err

examples/ping-pong/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"github.com/pion/randutil"
1919
)
2020

21-
// nolint:gochecknoglobals
21+
//nolint:gochecknoglobals
2222
var (
2323
isControlling bool
2424
iceAgent *ice.Agent

external_ip_mapper.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ func validateIPString(ipStr string) (net.IP, bool, error) {
1818

1919
// ipMapping holds the mapping of local and external IP address for a particular IP family
2020
type ipMapping struct {
21-
ipSole net.IP // when non-nil, this is the sole external IP for one local IP assumed
22-
ipMap map[string]net.IP // local-to-external IP mapping (k: local, v: external)
23-
valid bool // if not set any external IP, valid is false
21+
ipSole net.IP // When non-nil, this is the sole external IP for one local IP assumed
22+
ipMap map[string]net.IP // Local-to-external IP mapping (k: local, v: external)
23+
valid bool // If not set any external IP, valid is false
2424
}
2525

2626
func (m *ipMapping) setSoleIP(ip net.IP) error {
@@ -41,7 +41,7 @@ func (m *ipMapping) addIPMapping(locIP, extIP net.IP) error {
4141

4242
locIPStr := locIP.String()
4343

44-
// check if dup of local IP
44+
// Check if dup of local IP
4545
if _, ok := m.ipMap[locIPStr]; ok {
4646
return ErrInvalidNAT1To1IPMapping
4747
}
@@ -80,7 +80,7 @@ func newExternalIPMapper(candidateType CandidateType, ips []string) (*externalIP
8080
return nil, nil //nolint:nilnil
8181
}
8282
if candidateType == CandidateTypeUnspecified {
83-
candidateType = CandidateTypeHost // defaults to host
83+
candidateType = CandidateTypeHost // Defaults to host
8484
} else if candidateType != CandidateTypeHost && candidateType != CandidateTypeServerReflexive {
8585
return nil, ErrUnsupportedNAT1To1IPCandidateType
8686
}

external_ip_mapper_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,13 @@ func TestExternalIPMapper(t *testing.T) {
223223
assert.NotNil(t, m.ipv4Mapping.ipSole)
224224
assert.NotNil(t, m.ipv6Mapping.ipSole)
225225

226-
// find external IPv4
226+
// Find external IPv4
227227
extIP, err = m.findExternalIP("10.0.0.1")
228228
assert.NoError(t, err, "should succeed")
229229
assert.Equal(t, "1.2.3.4", extIP.String(), "should match")
230230

231-
// find external IPv6
232-
extIP, err = m.findExternalIP("fe80::0001") // use '0001' instead of '1' on purpose
231+
// Find external IPv6
232+
extIP, err = m.findExternalIP("fe80::0001") // Use '0001' instead of '1' on purpose
233233
assert.NoError(t, err, "should succeed")
234234
assert.Equal(t, "2200::1", extIP.String(), "should match")
235235

@@ -253,7 +253,7 @@ func TestExternalIPMapper(t *testing.T) {
253253
assert.NoError(t, err, "should succeed")
254254
assert.NotNil(t, m, "should not be nil")
255255

256-
// find external IPv4
256+
// Find external IPv4
257257
extIP, err = m.findExternalIP("10.0.0.1")
258258
assert.NoError(t, err, "should succeed")
259259
assert.Equal(t, "1.2.3.4", extIP.String(), "should match")
@@ -265,12 +265,12 @@ func TestExternalIPMapper(t *testing.T) {
265265
_, err = m.findExternalIP("10.0.0.3")
266266
assert.Error(t, err, "should fail")
267267

268-
// find external IPv6
269-
extIP, err = m.findExternalIP("fe80::0001") // use '0001' instead of '1' on purpose
268+
// Find external IPv6
269+
extIP, err = m.findExternalIP("fe80::0001") // Use '0001' instead of '1' on purpose
270270
assert.NoError(t, err, "should succeed")
271271
assert.Equal(t, "2200::1", extIP.String(), "should match")
272272

273-
extIP, err = m.findExternalIP("fe80::0002") // use '0002' instead of '2' on purpose
273+
extIP, err = m.findExternalIP("fe80::0002") // Use '0002' instead of '2' on purpose
274274
assert.NoError(t, err, "should succeed")
275275
assert.Equal(t, "2200::2", extIP.String(), "should match")
276276

@@ -291,7 +291,7 @@ func TestExternalIPMapper(t *testing.T) {
291291
})
292292
assert.NoError(t, err, "should succeed")
293293

294-
// attempt to find IPv6 that does not exist in the map
294+
// Attempt to find IPv6 that does not exist in the map
295295
extIP, err := m.findExternalIP("fe80::1")
296296
assert.NoError(t, err, "should succeed")
297297
assert.Equal(t, "fe80::1", extIP.String(), "should match")
@@ -301,7 +301,7 @@ func TestExternalIPMapper(t *testing.T) {
301301
})
302302
assert.NoError(t, err, "should succeed")
303303

304-
// attempt to find IPv4 that does not exist in the map
304+
// Attempt to find IPv4 that does not exist in the map
305305
extIP, err = m.findExternalIP("10.0.0.1")
306306
assert.NoError(t, err, "should succeed")
307307
assert.Equal(t, "10.0.0.1", extIP.String(), "should match")

gather.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func (a *Agent) gatherCandidatesLocal(ctx context.Context, networkTypes []Networ
125125
}
126126
}
127127

128-
// when UDPMux is enabled, skip other UDP candidates
128+
// When UDPMux is enabled, skip other UDP candidates
129129
if a.udpMux != nil {
130130
if err := a.gatherCandidatesLocalUDPMux(ctx); err != nil {
131131
a.log.Warnf("could not create host candidate for UDPMux: %s", err)
@@ -202,7 +202,7 @@ func (a *Agent) gatherCandidatesLocal(ctx context.Context, networkTypes []Networ
202202
continue
203203
}
204204
tcpType = TCPTypePassive
205-
// is there a way to verify that the listen address is even
205+
// Is there a way to verify that the listen address is even
206206
// accessible from the current interface.
207207
case udp:
208208
conn, err := listenUDPInPortRange(a.net, a.log, int(a.portMax), int(a.portMin), network, &net.UDPAddr{IP: ip, Port: 0})

gather_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func TestGatherConcurrency(t *testing.T) {
108108
candidateGatheredFunc()
109109
}))
110110

111-
// tesing for panic
111+
// Testing for panic
112112
for i := 0; i < 10; i++ {
113113
_ = a.GatherCandidates()
114114
}
@@ -812,11 +812,11 @@ func TestUniversalUDPMuxUsage(t *testing.T) {
812812
<-candidateGathered.Done()
813813

814814
assert.NoError(t, a.Close())
815-
// twice because of 2 STUN servers configured
815+
// Twice because of 2 STUN servers configured
816816
assert.Equal(t, numSTUNS, udpMuxSrflx.getXORMappedAddrUsedTimes, "expected times that GetXORMappedAddr should be called")
817-
// one for Restart() when agent has been initialized and one time when Close() the agent
817+
// One for Restart() when agent has been initialized and one time when Close() the agent
818818
assert.Equal(t, 2, udpMuxSrflx.removeConnByUfragTimes, "expected times that RemoveConnByUfrag should be called")
819-
// twice because of 2 STUN servers configured
819+
// Twice because of 2 STUN servers configured
820820
assert.Equal(t, numSTUNS, udpMuxSrflx.getConnForURLTimes, "expected times that GetConnForURL should be called")
821821
}
822822

0 commit comments

Comments
 (0)