Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
40 changes: 5 additions & 35 deletions src/SIPSorcery/net/ICE/RTCIceCandidate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,24 +248,11 @@ public override string ToString()
string candidateStr;
if (protocol == RTCIceProtocol.tcp)
{
candidateStr = String.Format("{0} {1} tcp {2} {3} {4} typ {5} tcptype {6} generation 0",
foundation,
component.GetHashCode(),
priority,
address,
port,
type,
tcpType);
candidateStr = $"{foundation} {component.GetHashCode()} tcp {priority} {address} {port} typ {type} tcptype {tcpType} generation 0";
}
else
{
candidateStr = String.Format("{0} {1} udp {2} {3} {4} typ {5} generation 0",
foundation,
component.GetHashCode(),
priority,
address,
port,
type);
candidateStr = $"{foundation} {component.GetHashCode()} udp {priority} {address} {port} typ {type} generation 0";
}

return candidateStr;
Expand All @@ -282,28 +269,11 @@ public override string ToString()
string candidateStr;
if (protocol == RTCIceProtocol.tcp)
{
candidateStr = String.Format("{0} {1} tcp {2} {3} {4} typ {5} tcptype {6} raddr {7} rport {8} generation 0",
foundation,
component.GetHashCode(),
priority,
address,
port,
type,
tcpType,
relAddr,
relatedPort);
candidateStr = $"{foundation} {component.GetHashCode()} tcp {priority} {address} {port} typ {type} tcptype {tcpType} raddr {relAddr} rport {relatedPort} generation 0";
}
else
{
candidateStr = String.Format("{0} {1} udp {2} {3} {4} typ {5} raddr {6} rport {7} generation 0",
foundation,
component.GetHashCode(),
priority,
address,
port,
type,
relAddr,
relatedPort);
candidateStr = $"{foundation} {component.GetHashCode()} udp {priority} {address} {port} typ {type} raddr {relAddr} rport {relatedPort} generation 0";
}

return candidateStr;
Expand Down Expand Up @@ -383,7 +353,7 @@ public string toJSON()
sdpMid = sdpMid ?? sdpMLineIndex.ToString(),
sdpMLineIndex = sdpMLineIndex,
usernameFragment = usernameFragment,
candidate = CANDIDATE_PREFIX + ":" + this.ToString()
candidate = $"{CANDIDATE_PREFIX}:{this}"
};

return rtcCandInit.toJSON();
Expand Down
15 changes: 8 additions & 7 deletions src/SIPSorcery/net/ICE/RtpIceChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@ private void RefreshTurn(Object state)
}
catch (Exception excp)
{
logger.LogError(excp, "Exception " + nameof(RefreshTurn) + ". {ErrorMessage}", excp);
logger.LogError(excp, "Exception in {Method}.", nameof(RefreshTurn));
}
}

Expand Down Expand Up @@ -1308,12 +1308,12 @@ private async Task UpdateChecklist(RTCIceCandidate localCandidate, RTCIceCandida
{
if (localCandidate == null)
{
logger.LogError(nameof(UpdateChecklist) + " the local candidate supplied to UpdateChecklist was null.");
logger.LogError("{Method} the local candidate supplied to UpdateChecklist was null.", nameof(UpdateChecklist));
return;
}
else if (remoteCandidate == null)
{
logger.LogError(nameof(UpdateChecklist) + " the remote candidate supplied to UpdateChecklist was null.");
logger.LogError("{Method} the remote candidate supplied to UpdateChecklist was null.", nameof(UpdateChecklist));
return;
}

Expand All @@ -1323,7 +1323,7 @@ private async Task UpdateChecklist(RTCIceCandidate localCandidate, RTCIceCandida
// Attempt to resolve the remote candidate address.
if (!IPAddress.TryParse(remoteCandidate.address, out var remoteCandidateIPAddr))
{
if (remoteCandidate.address.ToLower().EndsWith(MDNS_TLD))
if (remoteCandidate.address.EndsWith(MDNS_TLD, StringComparison.OrdinalIgnoreCase))
{
var addresses = await ResolveMdnsName(remoteCandidate).ConfigureAwait(false);
if (addresses.Length == 0)
Expand Down Expand Up @@ -1418,7 +1418,7 @@ private async Task UpdateChecklist(RTCIceCandidate localCandidate, RTCIceCandida
}
catch (Exception excp)
{
logger.LogError(excp, "Exception " + nameof(UpdateChecklist) + ". {ErrorMessage}", excp);
logger.LogError(excp, "Exception in {Method}.", nameof(UpdateChecklist));
}
}

Expand Down Expand Up @@ -1760,7 +1760,7 @@ private void SendSTUNBindingRequest(ChecklistEntry candidatePair, bool setUseCan
{
STUNMessage stunRequest = new STUNMessage(STUNMessageTypesEnum.BindingRequest);
stunRequest.Header.TransactionId = Encoding.ASCII.GetBytes(candidatePair.RequestTransactionID);
stunRequest.AddUsernameAttribute(RemoteIceUser + ":" + LocalIceUser);
stunRequest.AddUsernameAttribute($"{RemoteIceUser}:{LocalIceUser}");
stunRequest.Attributes.Add(new STUNAttribute(STUNAttributeTypesEnum.Priority, BitConverter.GetBytes(candidatePair.LocalPriority)));

if (IsController)
Expand Down Expand Up @@ -2725,7 +2725,8 @@ private async Task<IPAddress[]> ResolveMdnsName(RTCIceCandidate candidate)
{
if (MdnsResolve != null)
{
logger.LogWarning("RTP ICE channel has both "+ nameof(MdnsGetAddresses) + " and " + nameof(MdnsGetAddresses) + " set. Only " + nameof(MdnsGetAddresses) + " will be used.");
logger.LogWarning("RTP ICE channel has both {PrimaryResolver} and {SecondaryResolver} set. Only {SelectedResolver} will be used.",
nameof(MdnsGetAddresses), nameof(MdnsResolve), nameof(MdnsGetAddresses));
}
return await MdnsGetAddresses(candidate.address).ConfigureAwait(false);
}
Expand Down
Loading