[reSIProcate] [patch] stateless-proxy
Hello,
I started looking at resiprocate, and began with the stateless-proxy example.
I got it working with the following patch. Part was gleened from Jay
(http://list.sipfoundry.org/archive/resiprocate-devel/msg01312.html).
Thanks Jay!
I'm not sure whether my changes to TransportSelector.cxx are appropriate...
But it works for me :)
Jon
Index: resiprocate/DnsResult.cxx
===================================================================
--- resiprocate/DnsResult.cxx (revision 3372)
+++ resiprocate/DnsResult.cxx (working copy)
@@ -175,6 +175,12 @@
{
lookupNAPTR(); // for current target
}
+
+ // Handles case of numeric IP - no DNS required
+ if (mType == Available)
+ {
+ mHandler->handle(this);
+ }
}
}
Index: resiprocate/TransportSelector.cxx
===================================================================
--- resiprocate/TransportSelector.cxx (revision 3372)
+++ resiprocate/TransportSelector.cxx (working copy)
@@ -568,6 +568,18 @@
// We assume that all stray responses have been discarded, so we
always
// know the transport that the corresponding request was received on
// and this has been copied by TransactionState::sendToWire into
target.transport
+ if (target.transport == 0)
+ {
+ if (target.getType() == TLS)
+ {
+ target.transport = findTlsTransport(msg->getTlsDomain());
+ }
+ else
+ {
+ target.transport = findTransport(target);
+ }
+ }
+
assert(target.transport);
if (target.transport->getTuple().isAnyInterface())
{
Index: stateless-proxy/StatelessProxy.hxx
===================================================================
--- stateless-proxy/StatelessProxy.hxx (revision 3372)
+++ stateless-proxy/StatelessProxy.hxx (working copy)
@@ -2,6 +2,7 @@
#define STATELESS_PROXY_HXX
#include "resiprocate/SipStack.hxx"
+#include "resiprocate/Uri.hxx"
#include "resiprocate/os/Data.hxx"
#include "resiprocate/os/ThreadIf.hxx"
Index: stateless-proxy/stateless-proxy.cxx
===================================================================
--- stateless-proxy/stateless-proxy.cxx (revision 3372)
+++ stateless-proxy/stateless-proxy.cxx (working copy)
@@ -26,6 +26,7 @@
int proxyPort=5060;
char* targetHost=0;
int targetPort=5060;
+ char* targetTransport=0;
char* logType=0;
char* logLevel=0;
#if defined (HAVE_POPT_H)
@@ -34,6 +35,7 @@
{"port", 'p', POPT_ARG_INT, &proxyPort, 0, "port to listen on", 0},
{"target", 't', POPT_ARG_STRING, &targetHost, 0, "target of stateless
proxy", 0},
{"target-port", 'o', POPT_ARG_INT, &targetPort, 0, "target port of
stateless proxy", 0},
+ {"target-transport", 'x', POPT_ARG_STRING, &targetTransport, 0, "target
transport of stateless proxy", 0},
{"log-type", 'l', POPT_ARG_STRING, &logType, 0, "where to send logging
messages", "syslog|cerr|cout"},
{"log-level", 'v', POPT_ARG_STRING, &logLevel, 0, "specify the default
log level", "LOG_DEBUG|LOG_INFO|LOG_WARNING|LOG_ALERT"},
POPT_AUTOHELP
@@ -45,7 +47,7 @@
Log::initialize(Log::toType(logType), Log::toLevel(logLevel), argv[0]);
- resip::StatelessProxy proxy(proxyHost, proxyPort, targetHost, targetPort);
+ resip::StatelessProxy proxy(proxyHost, proxyPort, targetHost, targetPort,
targetTransport);
proxy.run();
proxy.join();
Index: stateless-proxy/StatelessProxy.cxx
===================================================================
--- stateless-proxy/StatelessProxy.cxx (revision 3372)
+++ stateless-proxy/StatelessProxy.cxx (working copy)
@@ -17,8 +17,6 @@
mLoose(false),
mUseTarget(targetHost != 0)
{
- assert(proto == 0 || proto == Symbols::UDP || proto == Symbols::TCP);
-
// used for record-route
mProxyUrl.host() = proxyHost;
mProxyUrl.port() = proxyPort;
@@ -26,6 +24,8 @@
// where to proxy the requests
if (mUseTarget)
{
+ assert(proto && (!strcmp(proto, Symbols::UDP) || !strcmp(proto,
Symbols::TCP)));
+
mTarget.host() = targetHost;
mTarget.port() = targetPort;
mTarget.param(p_protocol) = proto;