Skip to content

Commit

Permalink
fix bug with UDP source when using ExternalIP=
Browse files Browse the repository at this point in the history
  • Loading branch information
willamowius committed Jan 9, 2023
1 parent 56c6b02 commit ca518b4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions ProxyChannel.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -12965,6 +12965,11 @@ void H46019Session::Send(DWORD sendMultiplexID, const IPAndPortAddress & toAddre
return;
}

PIPSocket::Address * sourceIP = NULL;
if (gkIP && Toolkit::Instance()->GetExternalIP().IsEmpty()) { // let OS/firewall handle setting source IP with ExternalIP
sourceIP = gkIP;
}

if (sendMultiplexID != INVALID_MULTIPLEX_ID) {
lenToSend += 4;
BYTE * multiplexMsg = NULL;
Expand All @@ -12980,11 +12985,11 @@ void H46019Session::Send(DWORD sendMultiplexID, const IPAndPortAddress & toAddre
PUInt32b networkID = sendMultiplexID; // convert multiplex ID to network format
*((PUInt32b*)multiplexMsg) = networkID; // set multiplexID

sent = UDPSendWithSourceIP(osSocket, multiplexMsg, lenToSend, toAddress, gkIP);
sent = UDPSendWithSourceIP(osSocket, multiplexMsg, lenToSend, toAddress, sourceIP);
if (!bufferHasRoomForID)
free(multiplexMsg);
} else {
sent = UDPSendWithSourceIP(osSocket, data, lenToSend, toAddress, gkIP);
sent = UDPSendWithSourceIP(osSocket, data, lenToSend, toAddress, sourceIP);
}
if (sent != lenToSend) {
PTRACE(1, "RTPM\tError sending RTP to " << toAddress << ": should send=" << lenToSend << " did send=" << (int)sent << " errno=" << errno << " osSocket=" << osSocket << " retry=" << isRetry);
Expand Down Expand Up @@ -13026,7 +13031,7 @@ void H46019Session::Send(DWORD sendMultiplexID, const IPAndPortAddress & toAddre
}
}
if (newsocket > 0) {
Send(sendMultiplexID, toAddress, newsocket, data, len, bufferHasRoomForID, gkIP, true); // re-try sending
Send(sendMultiplexID, toAddress, newsocket, data, len, bufferHasRoomForID, sourceIP, true); // re-try sending
close(newsocket);
} else {
PTRACE(1, "RTPM\tError: creating new socket for multiplex re-try failed");
Expand Down Expand Up @@ -14751,7 +14756,8 @@ ProxySocket::Result UDPProxySocket::ReceiveData()
WORD toPort = 0;
GetSendAddress(toIP, toPort);
PIPSocket::Address gkIP;
if (m_call && (*m_call) && (*m_call)->GetEndpointIPMapping(toIP, gkIP)) {
if (m_call && (*m_call) && (*m_call)->GetEndpointIPMapping(toIP, gkIP)
&& Toolkit::Instance()->GetExternalIP().IsEmpty()) { // let OS/firewall handle setting source IP with ExternalIP
UDPSendWithSourceIP(os_handle, wbuffer, buflen, toIP, toPort, &gkIP);
} else {
UDPSendWithSourceIP(os_handle, wbuffer, buflen, toIP, toPort, NULL);
Expand Down
2 changes: 1 addition & 1 deletion changes.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Changes from 5.10 to 5.11
=========================
- fix bug with H.245 address when using ExternalIP=
- fix bug with H.245 address and UDP source when using ExternalIP=
- remove non-working command line switch -e / --externalip, use config file to set ExternalIP
- new accounting variables %{registrations}, %{calls}, %{total-calls}, %{successful-calls}, %{allocated-bandwidth}
- new switch [HttpAcct] Authorization= to send authorization headers to support InfluxDB
Expand Down

0 comments on commit ca518b4

Please sign in to comment.