Fix comment capitalization

Comments should start with an uppercase letter.
This commit is contained in:
Steffen Vogel
2023-04-18 19:38:54 +02:00
parent f07b6d16ad
commit f40dd65abb
25 changed files with 129 additions and 142 deletions
+3 -3
View File
@@ -47,7 +47,7 @@ type Agent struct {
onConnected chan struct{}
onConnectedOnce sync.Once
// force candidate to be contacted immediately (instead of waiting for task ticker)
// Force candidate to be contacted immediately (instead of waiting for task ticker)
forceCandidateContact chan bool
tieBreaker uint64
@@ -718,7 +718,7 @@ func (a *Agent) checkKeepalive() {
if (a.keepaliveInterval != 0) &&
((time.Since(selectedPair.Local.LastSent()) > a.keepaliveInterval) ||
(time.Since(selectedPair.Remote.LastReceived()) > a.keepaliveInterval)) {
// we use binding request instead of indication to support refresh consent schemas
// We use binding request instead of indication to support refresh consent schemas
// see https://tools.ietf.org/html/rfc7675
a.selector.PingCandidate(selectedPair.Local, selectedPair.Remote)
}
@@ -730,7 +730,7 @@ func (a *Agent) AddRemoteCandidate(c Candidate) error {
return nil
}
// cannot check for network yet because it might not be applied
// Cannot check for network yet because it might not be applied
// when mDNS hostname is used.
if c.TCPType() == TCPTypeActive {
// TCP Candidates with TCP type active will probe server passive ones, so
+8 -8
View File
@@ -25,25 +25,25 @@ const (
// defaultFailedTimeout is the default time till an Agent transitions to failed after disconnected
defaultFailedTimeout = 25 * time.Second
// wait time before nominating a host candidate
// defaultHostAcceptanceMinWait is the wait time before nominating a host candidate
defaultHostAcceptanceMinWait = 0
// wait time before nominating a srflx candidate
// defaultSrflxAcceptanceMinWait is the wait time before nominating a srflx candidate
defaultSrflxAcceptanceMinWait = 500 * time.Millisecond
// wait time before nominating a prflx candidate
// defaultPrflxAcceptanceMinWait is the wait time before nominating a prflx candidate
defaultPrflxAcceptanceMinWait = 1000 * time.Millisecond
// wait time before nominating a relay candidate
// defaultRelayAcceptanceMinWait is the wait time before nominating a relay candidate
defaultRelayAcceptanceMinWait = 2000 * time.Millisecond
// max binding request before considering a pair failed
// defaultMaxBindingRequests is the maximum number of binding requests before considering a pair failed
defaultMaxBindingRequests = 7
// the number of bytes that can be buffered before we start to error
// maxBufferSize is the number of bytes that can be buffered before we start to error
maxBufferSize = 1000 * 1000 // 1MB
// wait time before binding requests can be deleted
// maxBindingRequestTimeout is the wait time before binding requests can be deleted
maxBindingRequestTimeout = 4000 * time.Millisecond
)
@@ -245,7 +245,7 @@ func (config *AgentConfig) initExtIPMapping(a *Agent) error {
return err
}
if a.extIPMapper == nil {
return nil // this may happen when config.NAT1To1IPs is an empty array
return nil // This may happen when config.NAT1To1IPs is an empty array
}
if a.extIPMapper.candidateType == CandidateTypeHost {
if a.mDNSMode == MulticastDNSModeQueryAndGather {
+14 -14
View File
@@ -38,7 +38,7 @@ func TestOnSelectedCandidatePairChange(t *testing.T) {
report := test.CheckRoutines(t)
defer report()
// avoid deadlocks?
// Avoid deadlocks?
defer test.TimeOut(1 * time.Second).Stop()
a, err := NewAgent(&AgentConfig{})
@@ -77,7 +77,7 @@ func TestOnSelectedCandidatePairChange(t *testing.T) {
t.Fatalf("Failed to construct remote relay candidate: %s", err)
}
// select the pair
// Select the pair
if err = a.run(context.Background(), func(ctx context.Context, agent *Agent) {
p := newCandidatePair(hostLocal, relayRemote, false)
agent.setSelectedPair(p)
@@ -85,7 +85,7 @@ func TestOnSelectedCandidatePairChange(t *testing.T) {
t.Fatalf("Failed to setValidPair(): %s", err)
}
// ensure that the callback fired on setting the pair
// Ensure that the callback fired on setting the pair
<-callbackCalled
assert.NoError(t, a.Close())
}
@@ -154,12 +154,12 @@ func TestHandlePeerReflexive(t *testing.T) {
a.handleInbound(msg, local, remote)
// length of remote candidate list must be one now
// Length of remote candidate list must be one now
if len(a.remoteCandidates) != 1 {
t.Fatal("failed to add a network type to the remote candidate list")
}
// length of remote candidate list for a network type must be 1
// Length of remote candidate list for a network type must be 1
set := a.remoteCandidates[local.NetworkType()]
if len(set) != 1 {
t.Fatal("failed to add prflx candidate to remote candidate list")
@@ -247,7 +247,7 @@ func TestHandlePeerReflexive(t *testing.T) {
}
// Assert that Agent on startup sends message, and doesn't wait for connectivityTicker to fire
// github.com/pion/ice/issues/15
// https://github.com/pion/ice/issues/15
func TestConnectivityOnStartup(t *testing.T) {
report := test.CheckRoutines(t)
defer report()
@@ -685,7 +685,7 @@ func TestCandidatePairStats(t *testing.T) {
report := test.CheckRoutines(t)
defer report()
// avoid deadlocks?
// Avoid deadlocks?
defer test.TimeOut(1 * time.Second).Stop()
a, err := NewAgent(&AgentConfig{})
@@ -818,7 +818,7 @@ func TestLocalCandidateStats(t *testing.T) {
report := test.CheckRoutines(t)
defer report()
// avoid deadlocks?
// Avoid deadlocks?
defer test.TimeOut(1 * time.Second).Stop()
a, err := NewAgent(&AgentConfig{})
@@ -899,7 +899,7 @@ func TestRemoteCandidateStats(t *testing.T) {
report := test.CheckRoutines(t)
defer report()
// avoid deadlocks?
// Avoid deadlocks?
defer test.TimeOut(1 * time.Second).Stop()
a, err := NewAgent(&AgentConfig{})
@@ -1077,7 +1077,7 @@ func TestInitExtIPMapping(t *testing.T) {
// NewAgent should return if newExternalIPMapper() returns an error.
_, err = NewAgent(&AgentConfig{
NAT1To1IPs: []string{"bad.2.3.4"}, // bad IP
NAT1To1IPs: []string{"bad.2.3.4"}, // Bad IP
NAT1To1IPCandidateType: CandidateTypeHost,
})
if !errors.Is(err, ErrInvalidNAT1To1IPMapping) {
@@ -1096,16 +1096,16 @@ func TestBindingRequestTimeout(t *testing.T) {
now := time.Now()
a.pendingBindingRequests = append(a.pendingBindingRequests, bindingRequest{
timestamp: now, // valid
timestamp: now, // Valid
})
a.pendingBindingRequests = append(a.pendingBindingRequests, bindingRequest{
timestamp: now.Add(-3900 * time.Millisecond), // valid
timestamp: now.Add(-3900 * time.Millisecond), // Valid
})
a.pendingBindingRequests = append(a.pendingBindingRequests, bindingRequest{
timestamp: now.Add(-4100 * time.Millisecond), // invalid
timestamp: now.Add(-4100 * time.Millisecond), // Invalid
})
a.pendingBindingRequests = append(a.pendingBindingRequests, bindingRequest{
timestamp: now.Add(-75 * time.Hour), // invalid
timestamp: now.Add(-75 * time.Hour), // Invalid
})
a.invalidatePendingBindingRequests(now)
+5 -5
View File
@@ -64,7 +64,7 @@ func TestMuxAgent(t *testing.T) {
require.NotNil(t, pair)
require.Equal(t, muxPort, pair.Local.Port())
// send a packet to Mux
// Send a packet to Mux
data := []byte("hello world")
_, err = conn.Write(data)
require.NoError(t, err)
@@ -74,7 +74,7 @@ func TestMuxAgent(t *testing.T) {
require.NoError(t, err)
require.Equal(t, data, buf[:n])
// send a packet from Mux
// Send a packet from Mux
_, err = muxedConn.Write(data)
require.NoError(t, err)
@@ -82,16 +82,16 @@ func TestMuxAgent(t *testing.T) {
require.NoError(t, err)
require.Equal(t, data, buf[:n])
// close it down
// Close it down
require.NoError(t, conn.Close())
require.NoError(t, muxedConn.Close())
require.NoError(t, udpMux.Close())
// expect error when reading from closed mux
// Expect error when reading from closed mux
_, err = muxedConn.Read(data)
require.Error(t, err)
// expect error when writing to closed mux
// Expect error when writing to closed mux
_, err = muxedConn.Write(data)
require.Error(t, err)
})
+3 -3
View File
@@ -41,8 +41,8 @@ type virtualNet struct {
}
func (v *virtualNet) close() {
v.server.Close() // nolint:errcheck,gosec
v.wan.Stop() // nolint:errcheck,gosec
v.server.Close() //nolint:errcheck,gosec
v.wan.Stop() //nolint:errcheck,gosec
}
func buildVNet(natType0, natType1 *vnet.NATType) (*virtualNet, error) {
@@ -58,7 +58,7 @@ func buildVNet(natType0, natType1 *vnet.NATType) (*virtualNet, error) {
}
wanNet, err := vnet.NewNet(&vnet.NetConfig{
StaticIP: vnetSTUNServerIP, // will be assigned to eth0
StaticIP: vnetSTUNServerIP, // Will be assigned to eth0
})
if err != nil {
return nil, err
+1 -1
View File
@@ -18,7 +18,7 @@ import (
"github.com/pion/randutil"
)
// nolint:gochecknoglobals
//nolint:gochecknoglobals
var (
isControlling bool
iceAgent *ice.Agent
+5 -5
View File
@@ -18,9 +18,9 @@ func validateIPString(ipStr string) (net.IP, bool, error) {
// ipMapping holds the mapping of local and external IP address for a particular IP family
type ipMapping struct {
ipSole net.IP // when non-nil, this is the sole external IP for one local IP assumed
ipMap map[string]net.IP // local-to-external IP mapping (k: local, v: external)
valid bool // if not set any external IP, valid is false
ipSole net.IP // When non-nil, this is the sole external IP for one local IP assumed
ipMap map[string]net.IP // Local-to-external IP mapping (k: local, v: external)
valid bool // If not set any external IP, valid is false
}
func (m *ipMapping) setSoleIP(ip net.IP) error {
@@ -41,7 +41,7 @@ func (m *ipMapping) addIPMapping(locIP, extIP net.IP) error {
locIPStr := locIP.String()
// check if dup of local IP
// Check if dup of local IP
if _, ok := m.ipMap[locIPStr]; ok {
return ErrInvalidNAT1To1IPMapping
}
@@ -80,7 +80,7 @@ func newExternalIPMapper(candidateType CandidateType, ips []string) (*externalIP
return nil, nil //nolint:nilnil
}
if candidateType == CandidateTypeUnspecified {
candidateType = CandidateTypeHost // defaults to host
candidateType = CandidateTypeHost // Defaults to host
} else if candidateType != CandidateTypeHost && candidateType != CandidateTypeServerReflexive {
return nil, ErrUnsupportedNAT1To1IPCandidateType
}
+9 -9
View File
@@ -223,13 +223,13 @@ func TestExternalIPMapper(t *testing.T) {
assert.NotNil(t, m.ipv4Mapping.ipSole)
assert.NotNil(t, m.ipv6Mapping.ipSole)
// find external IPv4
// Find external IPv4
extIP, err = m.findExternalIP("10.0.0.1")
assert.NoError(t, err, "should succeed")
assert.Equal(t, "1.2.3.4", extIP.String(), "should match")
// find external IPv6
extIP, err = m.findExternalIP("fe80::0001") // use '0001' instead of '1' on purpose
// Find external IPv6
extIP, err = m.findExternalIP("fe80::0001") // Use '0001' instead of '1' on purpose
assert.NoError(t, err, "should succeed")
assert.Equal(t, "2200::1", extIP.String(), "should match")
@@ -253,7 +253,7 @@ func TestExternalIPMapper(t *testing.T) {
assert.NoError(t, err, "should succeed")
assert.NotNil(t, m, "should not be nil")
// find external IPv4
// Find external IPv4
extIP, err = m.findExternalIP("10.0.0.1")
assert.NoError(t, err, "should succeed")
assert.Equal(t, "1.2.3.4", extIP.String(), "should match")
@@ -265,12 +265,12 @@ func TestExternalIPMapper(t *testing.T) {
_, err = m.findExternalIP("10.0.0.3")
assert.Error(t, err, "should fail")
// find external IPv6
extIP, err = m.findExternalIP("fe80::0001") // use '0001' instead of '1' on purpose
// Find external IPv6
extIP, err = m.findExternalIP("fe80::0001") // Use '0001' instead of '1' on purpose
assert.NoError(t, err, "should succeed")
assert.Equal(t, "2200::1", extIP.String(), "should match")
extIP, err = m.findExternalIP("fe80::0002") // use '0002' instead of '2' on purpose
extIP, err = m.findExternalIP("fe80::0002") // Use '0002' instead of '2' on purpose
assert.NoError(t, err, "should succeed")
assert.Equal(t, "2200::2", extIP.String(), "should match")
@@ -291,7 +291,7 @@ func TestExternalIPMapper(t *testing.T) {
})
assert.NoError(t, err, "should succeed")
// attempt to find IPv6 that does not exist in the map
// Attempt to find IPv6 that does not exist in the map
extIP, err := m.findExternalIP("fe80::1")
assert.NoError(t, err, "should succeed")
assert.Equal(t, "fe80::1", extIP.String(), "should match")
@@ -301,7 +301,7 @@ func TestExternalIPMapper(t *testing.T) {
})
assert.NoError(t, err, "should succeed")
// attempt to find IPv4 that does not exist in the map
// Attempt to find IPv4 that does not exist in the map
extIP, err = m.findExternalIP("10.0.0.1")
assert.NoError(t, err, "should succeed")
assert.Equal(t, "10.0.0.1", extIP.String(), "should match")
+2 -2
View File
@@ -125,7 +125,7 @@ func (a *Agent) gatherCandidatesLocal(ctx context.Context, networkTypes []Networ
}
}
// when UDPMux is enabled, skip other UDP candidates
// When UDPMux is enabled, skip other UDP candidates
if a.udpMux != nil {
if err := a.gatherCandidatesLocalUDPMux(ctx); err != nil {
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
continue
}
tcpType = TCPTypePassive
// is there a way to verify that the listen address is even
// Is there a way to verify that the listen address is even
// accessible from the current interface.
case udp:
conn, err := listenUDPInPortRange(a.net, a.log, int(a.portMax), int(a.portMin), network, &net.UDPAddr{IP: ip, Port: 0})
+4 -4
View File
@@ -108,7 +108,7 @@ func TestGatherConcurrency(t *testing.T) {
candidateGatheredFunc()
}))
// tesing for panic
// Testing for panic
for i := 0; i < 10; i++ {
_ = a.GatherCandidates()
}
@@ -812,11 +812,11 @@ func TestUniversalUDPMuxUsage(t *testing.T) {
<-candidateGathered.Done()
assert.NoError(t, a.Close())
// twice because of 2 STUN servers configured
// Twice because of 2 STUN servers configured
assert.Equal(t, numSTUNS, udpMuxSrflx.getXORMappedAddrUsedTimes, "expected times that GetXORMappedAddr should be called")
// one for Restart() when agent has been initialized and one time when Close() the agent
// One for Restart() when agent has been initialized and one time when Close() the agent
assert.Equal(t, 2, udpMuxSrflx.removeConnByUfragTimes, "expected times that RemoveConnByUfrag should be called")
// twice because of 2 STUN servers configured
// Twice because of 2 STUN servers configured
assert.Equal(t, numSTUNS, udpMuxSrflx.getConnForURLTimes, "expected times that GetConnForURL should be called")
}
+2 -3
View File
@@ -24,7 +24,6 @@ func TestVNetGather(t *testing.T) {
defer report()
loggerFactory := logging.NewDefaultLoggerFactory()
// log := loggerFactory.NewLogger("test")
t.Run("No local IP address", func(t *testing.T) {
n, err := vnet.NewNet(&vnet.NetConfig{})
@@ -214,7 +213,7 @@ func TestVNetGatherWithNAT1To1(t *testing.T) {
Net: nw,
})
assert.NoError(t, err, "should succeed")
defer a.Close() // nolint:errcheck
defer a.Close() //nolint:errcheck
done := make(chan struct{})
err = a.OnCandidate(func(c Candidate) {
@@ -314,7 +313,7 @@ func TestVNetGatherWithNAT1To1(t *testing.T) {
Net: nw,
})
assert.NoError(t, err, "should succeed")
defer a.Close() // nolint:errcheck
defer a.Close() //nolint:errcheck
done := make(chan struct{})
err = a.OnCandidate(func(c Candidate) {
+2 -2
View File
@@ -52,10 +52,10 @@ func localInterfaces(n transport.Net, interfaceFilter func(string) bool, ipFilte
for _, iface := range ifaces {
if iface.Flags&net.FlagUp == 0 {
continue // interface down
continue // Interface down
}
if (iface.Flags&net.FlagLoopback != 0) && !includeLoopback {
continue // loopback interface
continue // Loopback interface
}
if interfaceFilter != nil && !interfaceFilter(iface.Name) {
+3 -3
View File
@@ -198,7 +198,7 @@ func (s *controlledSelector) PingCandidate(local, remote Candidate) {
}
func (s *controlledSelector) HandleSuccessResponse(m *stun.Message, local, remote Candidate, remoteAddr net.Addr) {
// nolint:godox
//nolint:godox
// TODO according to the standard we should specifically answer a failed nomination:
// https://tools.ietf.org/html/rfc8445#section-7.3.1.5
// If the controlled agent does not accept the request from the
@@ -288,8 +288,8 @@ type liteSelector struct {
// A lite selector should not contact candidates
func (s *liteSelector) ContactCandidates() {
if _, ok := s.pairCandidateSelector.(*controllingSelector); ok {
// nolint:godox
// pion/ice#96
//nolint:godox
// https://github.com/pion/ice/issues/96
// TODO: implement lite controlling agent. For now falling back to full agent.
// This only happens if both peers are lite. See RFC 8445 S6.1.1 and S6.2
s.pairCandidateSelector.ContactCandidates()
+2 -2
View File
@@ -71,7 +71,7 @@ type TCPMuxParams struct {
Logger logging.LeveledLogger
ReadBufferSize int
// max buffer size for write op. 0 means no write buffer, the write op will block until the whole packet is written
// Maximum buffer size for write op. 0 means no write buffer, the write op will block until the whole packet is written
// if the write buffer is full, the subsequent write packet will be dropped until it has enough space.
// a default 4MB is recommended.
WriteBufferSize int
@@ -207,7 +207,7 @@ func (m *TCPMuxDefault) handleConn(conn net.Conn) {
return
}
if m == nil || msg.Type.Method != stun.MethodBinding { // not a stun
if m == nil || msg.Type.Method != stun.MethodBinding { // Not a STUN
m.closeAndLogError(conn)
m.params.Logger.Warnf("Not a STUN message from %s to %s", conn.RemoteAddr(), conn.LocalAddr())
return
+1 -1
View File
@@ -81,7 +81,7 @@ func TestMultiTCPMux_Recv(t *testing.T) {
assert.Equal(t, n, n2, "received byte size mismatch")
assert.Equal(t, msg.Raw, recv, "received bytes mismatch")
// check echo response
// Check echo response
n, err = pktConn.WriteTo(recv, conn.LocalAddr())
require.NoError(t, err, "error writing echo stun packet")
recvEcho := make([]byte, n)
+1 -1
View File
@@ -78,7 +78,7 @@ func TestTCPMux_Recv(t *testing.T) {
assert.Equal(t, n, n2, "received byte size mismatch")
assert.Equal(t, msg.Raw, recv, "received bytes mismatch")
// check echo response
// Check echo response
n, err = pktConn.WriteTo(recv, conn.LocalAddr())
require.NoError(t, err, "error writing echo stun packet")
recvEcho := make([]byte, n)
-11
View File
@@ -159,7 +159,6 @@ func (t *tcpPacketConn) startReading(conn net.Conn) {
for {
n, err := readStreamingPacket(conn, buf)
// t.params.Logger.Infof("readStreamingPacket read %d bytes", n)
if err != nil {
t.params.Logger.Infof("%v: %s", errReadingStreamingPacket, err)
t.handleRecv(streamingPacket{nil, conn.RemoteAddr(), err})
@@ -170,7 +169,6 @@ func (t *tcpPacketConn) startReading(conn net.Conn) {
data := make([]byte, n)
copy(data, buf[:n])
// t.params.Logger.Infof("Writing read streaming packet to recvChan: %d bytes", len(data))
t.handleRecv(streamingPacket{data, conn.RemoteAddr(), nil})
}
}
@@ -229,15 +227,6 @@ func (t *tcpPacketConn) WriteTo(buf []byte, rAddr net.Addr) (n int, err error) {
if !ok {
return 0, io.ErrClosedPipe
// conn, err := net.DialTCP(tcp, nil, rAddr.(*net.TCPAddr))
// if err != nil {
// t.params.Logger.Tracef("DialTCP error: %s", err)
// return 0, err
// }
// go t.startReading(conn)
// t.conns[rAddr.String()] = conn
}
n, err = writeStreamingPacket(conn, buf)
+1 -1
View File
@@ -52,7 +52,7 @@ func (a *Agent) connect(ctx context.Context, isControlling bool, remoteUfrag, re
return nil, err
}
// block until pair selected
// Block until pair selected
select {
case <-a.done:
return nil, a.getErr()
+8 -8
View File
@@ -31,7 +31,7 @@ func TestStressDuplex(t *testing.T) {
func testTimeout(t *testing.T, c *Conn, timeout time.Duration) {
const pollRate = 100 * time.Millisecond
const margin = 20 * time.Millisecond // allow 20msec error in time
const margin = 20 * time.Millisecond // Allow 20msec error in time
ticker := time.NewTicker(pollRate)
defer func() {
ticker.Stop()
@@ -52,7 +52,7 @@ func testTimeout(t *testing.T, c *Conn, timeout time.Duration) {
cs = agent.connectionState
})
if err != nil {
// we should never get here.
// We should never get here.
panic(err)
}
@@ -86,7 +86,7 @@ func TestTimeout(t *testing.T) {
ca, cb := pipe(nil)
err := cb.Close()
if err != nil {
// we should never get here.
// We should never get here.
panic(err)
}
@@ -97,7 +97,7 @@ func TestTimeout(t *testing.T) {
ca, cb := pipeWithTimeout(5*time.Second, 3*time.Second)
err := cb.Close()
if err != nil {
// we should never get here.
// We should never get here.
panic(err)
}
@@ -118,13 +118,13 @@ func TestReadClosed(t *testing.T) {
err := ca.Close()
if err != nil {
// we should never get here.
// We should never get here.
panic(err)
}
err = cb.Close()
if err != nil {
// we should never get here.
// We should never get here.
panic(err)
}
@@ -354,13 +354,13 @@ func TestConnStats(t *testing.T) {
err := ca.Close()
if err != nil {
// we should never get here.
// We should never get here.
panic(err)
}
err = cb.Close()
if err != nil {
// we should never get here.
// We should never get here.
panic(err)
}
}
+3 -3
View File
@@ -38,12 +38,12 @@ type UDPMuxDefault struct {
addressMapMu sync.RWMutex
addressMap map[string]*udpMuxedConn
// buffer pool to recycle buffers for net.UDPAddr encodes/decodes
// Buffer pool to recycle buffers for net.UDPAddr encodes/decodes
pool *sync.Pool
mu sync.Mutex
// for UDP connection listen at unspecified address
// For UDP connection listen at unspecified address
localAddrsForUnspecified []net.Addr
}
@@ -112,7 +112,7 @@ func NewUDPMuxDefault(params UDPMuxParams) *UDPMuxDefault {
closedChan: make(chan struct{}, 1),
pool: &sync.Pool{
New: func() interface{} {
// big enough buffer to fit both packet and address
// Big enough buffer to fit both packet and address
return newBufferHolder(receiveMTU + maxAddrSize)
},
},

Some files were not shown because too many files have changed in this diff Show More