Skip to content

Commit

Permalink
Fix capitalization of tracing messages
Browse files Browse the repository at this point in the history
  • Loading branch information
stv0g committed Jun 24, 2023
1 parent db5d7ea commit 38d0e6d
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
10 changes: 5 additions & 5 deletions agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ func (a *Agent) setSelectedPair(p *CandidatePair) {
}

func (a *Agent) pingAllCandidates() {
a.log.Trace("pinging all candidates")
a.log.Trace("Pinging all candidates")

if len(a.checklist) == 0 {
a.log.Warn("Failed to ping without candidate pairs. Connection is not possible yet.")
Expand All @@ -549,7 +549,7 @@ func (a *Agent) pingAllCandidates() {
}

if p.bindingRequestCount > a.maxBindingRequests {
a.log.Tracef("max requests reached for pair %s, marking it as failed", p)
a.log.Tracef("Maximum requests reached for pair %s, marking it as failed", p)
p.state = CandidatePairStateFailed
} else {
a.selector.PingCandidate(p.Local, p.Remote)
Expand Down Expand Up @@ -959,7 +959,7 @@ func (a *Agent) findRemoteCandidate(networkType NetworkType, addr net.Addr) Cand
}

func (a *Agent) sendBindingRequest(m *stun.Message, local, remote Candidate) {
a.log.Tracef("ping STUN from %s to %s", local.String(), remote.String())
a.log.Tracef("Ping STUN from %s to %s", local.String(), remote.String())

a.invalidatePendingBindingRequests(time.Now())
a.pendingBindingRequests = append(a.pendingBindingRequests, bindingRequest{
Expand Down Expand Up @@ -1041,7 +1041,7 @@ func (a *Agent) handleInbound(m *stun.Message, local Candidate, remote net.Addr)
!(m.Type.Class == stun.ClassSuccessResponse ||
m.Type.Class == stun.ClassRequest ||
m.Type.Class == stun.ClassIndication) {
a.log.Tracef("unhandled STUN from %s to %s class(%s) method(%s)", remote, local, m.Type.Class, m.Type.Method)
a.log.Tracef("Unhandled STUN from %s to %s class(%s) method(%s)", remote, local, m.Type.Class, m.Type.Method)
return
}

Expand Down Expand Up @@ -1109,7 +1109,7 @@ func (a *Agent) handleInbound(m *stun.Message, local Candidate, remote net.Addr)
a.addRemoteCandidate(remoteCandidate)
}

a.log.Tracef("inbound STUN (Request) from %s to %s", remote.String(), local.String())
a.log.Tracef("Inbound STUN (Request) from %s to %s", remote.String(), local.String())

a.selector.HandleBindingRequest(m, local, remoteCandidate)
}
Expand Down
2 changes: 1 addition & 1 deletion candidatepair.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ func (p *CandidatePair) Write(b []byte) (int, error) {
func (a *Agent) sendSTUN(msg *stun.Message, local, remote Candidate) {
_, err := local.writeTo(msg.Raw, remote)
if err != nil {
a.log.Tracef("failed to send STUN message: %s", err)
a.log.Tracef("Failed to send STUN message: %s", err)
}
}
14 changes: 7 additions & 7 deletions selection.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (s *controllingSelector) ContactCandidates() {
switch {
case s.agent.getSelectedPair() != nil:
if s.agent.validateSelectedPair() {
s.log.Trace("checking keepalive")
s.log.Trace("Checking keepalive")
s.agent.checkKeepalive()
}
case s.nominatedPair != nil:
Expand Down Expand Up @@ -87,7 +87,7 @@ func (s *controllingSelector) nominatePair(pair *CandidatePair) {
return
}

s.log.Tracef("ping STUN (nominate candidate pair) from %s to %s", pair.Local.String(), pair.Remote.String())
s.log.Tracef("Ping STUN (nominate candidate pair) from %s to %s", pair.Local.String(), pair.Remote.String())
s.agent.sendBindingRequest(msg, pair.Local, pair.Remote)
}

Expand Down Expand Up @@ -130,7 +130,7 @@ func (s *controllingSelector) HandleSuccessResponse(m *stun.Message, local, remo
return
}

s.log.Tracef("inbound STUN (SuccessResponse) from %s to %s", remote.String(), local.String())
s.log.Tracef("Inbound STUN (SuccessResponse) from %s to %s", remote.String(), local.String())
p := s.agent.findPair(local, remote)

if p == nil {
Expand Down Expand Up @@ -173,7 +173,7 @@ func (s *controlledSelector) Start() {
func (s *controlledSelector) ContactCandidates() {
if s.agent.getSelectedPair() != nil {
if s.agent.validateSelectedPair() {
s.log.Trace("checking keepalive")
s.log.Trace("Checking keepalive")
s.agent.checkKeepalive()
}
} else {
Expand Down Expand Up @@ -221,7 +221,7 @@ func (s *controlledSelector) HandleSuccessResponse(m *stun.Message, local, remot
return
}

s.log.Tracef("inbound STUN (SuccessResponse) from %s to %s", remote.String(), local.String())
s.log.Tracef("Inbound STUN (SuccessResponse) from %s to %s", remote.String(), local.String())

p := s.agent.findPair(local, remote)
if p == nil {
Expand All @@ -237,7 +237,7 @@ func (s *controlledSelector) HandleSuccessResponse(m *stun.Message, local, remot
(selectedPair != p && selectedPair.priority() <= p.priority()) {
s.agent.setSelectedPair(p)
} else if selectedPair != p {
s.log.Tracef("ignore nominate new pair %s, already nominated pair %s", p, selectedPair)
s.log.Tracef("Ignore nominate new pair %s, already nominated pair %s", p, selectedPair)
}
}
}
Expand All @@ -262,7 +262,7 @@ func (s *controlledSelector) HandleBindingRequest(m *stun.Message, local, remote
(selectedPair != p && selectedPair.priority() <= p.priority()) {
s.agent.setSelectedPair(p)
} else if selectedPair != p {
s.log.Tracef("ignore nominate new pair %s, already nominated pair %s", p, selectedPair)
s.log.Tracef("Ignore nominate new pair %s, already nominated pair %s", p, selectedPair)
}
} else {
// If the received Binding request triggered a new check to be
Expand Down
2 changes: 1 addition & 1 deletion tcp_mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (m *TCPMuxDefault) handleConn(conn net.Conn) {
}

for _, attr := range msg.Attributes {
m.params.Logger.Debugf("msg attr: %s", attr.String())
m.params.Logger.Debugf("Message attribute: %s", attr.String())
}

attr, err := msg.Get(stun.AttrUsername)
Expand Down
4 changes: 2 additions & 2 deletions tcp_packet_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ func (bc *bufferedConn) writeProcess() {
}

if err != nil {
bc.logger.Warnf("read buffer error: %s", err)
bc.logger.Warnf("Failed to read from buffer: %s", err)
continue
}

if _, err := bc.Conn.Write(pktBuf[:n]); err != nil {
bc.logger.Warnf("write error: %s", err)
bc.logger.Warnf("Failed to write: %s", err)
continue
}
}
Expand Down
12 changes: 6 additions & 6 deletions udp_mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func NewUDPMuxDefault(params UDPMuxParams) *UDPMuxDefault {
if params.Net == nil {
var err error
if params.Net, err = stdnet.NewNet(); err != nil {
params.Logger.Errorf("failed to get create network: %v", err)
params.Logger.Errorf("Failed to get create network: %v", err)
}
}

Expand All @@ -99,7 +99,7 @@ func NewUDPMuxDefault(params UDPMuxParams) *UDPMuxDefault {
localAddrsForUnspecified = append(localAddrsForUnspecified, &net.UDPAddr{IP: ip, Port: addr.Port})
}
} else {
params.Logger.Errorf("failed to get local interfaces for unspecified addr: %v", err)
params.Logger.Errorf("Failed to get local interfaces for unspecified addr: %v", err)
}
}
}
Expand Down Expand Up @@ -290,15 +290,15 @@ func (m *UDPMuxDefault) connWorker() {
if os.IsTimeout(err) {
continue
} else if !errors.Is(err, io.EOF) {
logger.Errorf("could not read udp packet: %v", err)
logger.Errorf("Failed to read UDP packet: %v", err)
}

return
}

udpAddr, ok := addr.(*net.UDPAddr)
if !ok {
logger.Errorf("underlying PacketConn did not return a UDPAddr")
logger.Errorf("Underlying PacketConn did not return a UDPAddr")
return
}

Expand Down Expand Up @@ -333,12 +333,12 @@ func (m *UDPMuxDefault) connWorker() {
}

if destinationConn == nil {
m.params.Logger.Tracef("dropping packet from %s, addr: %s", udpAddr.String(), addr.String())
m.params.Logger.Tracef("Dropping packet from %s, addr: %s", udpAddr.String(), addr.String())
continue
}

if err = destinationConn.writePacket(buf[:n], udpAddr); err != nil {
m.params.Logger.Errorf("could not write packet: %v", err)
m.params.Logger.Errorf("Failed to write packet: %v", err)
}
}
}
Expand Down

0 comments on commit 38d0e6d

Please sign in to comment.