Hi,
Please find below a patch for Yate version 4.1.1. to get outbound proxying working. The patch introduces a new outboundproxy parameter which can be used for example from regexroute, like
; set proxy gateway
.*=;outboundproxy=112.203.17.24:5069
When this parameter is set it connects the outgoing YateSIPConnection to a proxy and sends all SIP messages there instead of the r-uri destination.
Comments re this patch would be highly welcome.
Cheers Gerry
@@ -4869,45 +4873,71 @@
m_rtpForward = msg.getBoolValue(YSTRING("rtp_forward"));
m_user = msg.getValue(YSTRING("user"));
m_line = msg.getValue(YSTRING("line"));
+
String tmp;
YateSIPLine* line = 0;
if (m_line) {
- line = plugin.findLine(m_line);
- if (line) {
- if (uri.find('@') < 0 && !uri.startsWith("tel:")) {
- if (!uri.startsWith("sip:"))
- tmp = "sip:";
- tmp << uri << "@" << line->domain();
- }
- m_externalAddr = line->getLocalAddr();
- }
- }
+ line = plugin.findLine(m_line);
+ if (line) {
+ if (uri.find('@') < 0 && !uri.startsWith("tel:")) {
+ if (!uri.startsWith("sip:"))
+ tmp = "sip:";
+ tmp << uri << "@" << line->domain();
+ }
+ m_externalAddr = line->getLocalAddr();
+ }
+ }
+
if (tmp.null()) {
- if (!(uri.startsWith("tel:") || uri.startsWith("sip:"))) {
- int sep = uri.find(':');
- if ((sep < 0) || ((sep > 0) && (uri.substr(sep+1).toInteger(-1) > 0)))
- tmp = "sip:";
- }
- tmp << uri;
+ if (!(uri.startsWith("tel:") || uri.startsWith("sip:"))) {
+ int sep = uri.find(':');
+ if ((sep < 0) || ((sep > 0) && (uri.substr(sep+1).toInteger(-1) > 0)))
+ tmp = "sip:";
+ }
+ tmp << uri;
}
m_uri = tmp;
m_uri.parse();
- if (!setParty(msg,false,"o",m_uri.getHost(),m_uri.getPort()) && line) {
- SIPParty* party = line->party();
- setParty(party);
- TelEngine::destruct(party);
- }
+
+ tmp.clear();
+ String rproxyaddr;
+ int rproxyport = 0;
+ tmp = msg.getValue(YSTRING("outboundproxy"));
+ if (tmp) {
+ int sep = tmp.find(':');
+ if (sep > 0) {
+ rproxyport = tmp.substr(sep + 1).toInteger(0);
+ rproxyaddr = tmp.substr(0,sep);
+ }
+ else
+ rproxyaddr = tmp;
+ }
+
+ if (rproxyaddr) {
+ setParty(msg,false,"o",rproxyaddr,rproxyport);
+ } else if (!setParty(msg,false,"o",m_uri.getHost(),m_uri.getPort()) && line) {
+ SIPParty* party = line->party();
+ setParty(party);
+ TelEngine::destruct(party);
+ }
+
SIPMessage* m = new SIPMessage("INVITE",m_uri);
- setSipParty(m,line,true,msg.getValue("host"),msg.getIntValue("port"));
+
+ if (rproxyaddr)
+ setSipParty(m,line,true,rproxyaddr,rproxyport);
+ else
+ setSipParty(m,line,true,msg.getValue("host"),msg.getIntValue("port"));
+
if (!m->getParty()) {