< Previous by Date Date Index Next by Date >
  Thread Index  

[reSIProcate]support outbound proxy in dum test program(basicRegister.cxx)


Hi all,

I've added an outbound proxy support to the test resip/dum/test/basicRegister.cxx, Just a nasty code. Hope it's useful to someone. I use this just for removing the registered contact on some proxy, and it's useful when the domain name is a fake domain name.

the patch is applied as a text version below and as an attachment.

Regards,

Sam Jiang


-------------------------patch begin--------------------
Index: resip/dum/test/basicRegister.cxx

===================================================================

--- resip/dum/test/basicRegister.cxx 锛堜慨璁㈢増 5603锛?
+++ resip/dum/test/basicRegister.cxx 锛堝伐浣滄嫹璐濓級

@@ -9,6 +9,8 @@

#include "rutil/Subsystem.hxx"
#include "resip/dum/KeepAliveManager.hxx"

+#include <sstream>
+
#ifdef WIN32
#include "resip/stack/WinSecurity.hxx"
#endif
@@ -63,8 +65,9 @@

main (int argc, char** argv)
{

-   if ( argc < 3 ) {
-      cout << "usage: " << argv[0] << " sip:user passwd\n";
+   if ( argc < 4 ) {
+ cout << "usage: " << argv[0] << " sip:user passwd realm [outboundhost] [outboundport]\n";
+
      return 0;
   }

@@ -72,7 +75,27 @@


   NameAddr userAor(argv[1]);
   Data passwd(argv[2]);
+   Data realm(argv[3]);

+   Data outboundhost("");
+   int outboundport = 5060;
+
+   if(argc == 5) {
+    outboundhost+=argv[4];
+   }
+   else {
+       if(argc == 6) {
+     outboundhost+=argv[4];
+           string temp(argv[5]);
+           istringstream src(temp);
+           src >> outboundport;
+       }
+   }
+
+   InfoLog ( << "from: " << userAor << endl);
+   InfoLog ( << "passwd: " << passwd << ", realm: " << realm << endl);
+ InfoLog ( << "outboundhost:outboundport "<< outboundhost << ":" << outboundport << endl);
+
#ifdef USE_SSL
#ifdef WIN32
   Security* security = new WinSecurity;
@@ -110,10 +133,21 @@

   profile->setDigestCredential(userAor.uri().host(),
                                     userAor.uri().user(),
                                     passwd);
+   if(outboundhost.size() != 0)
+   {
+        InfoLog ( << "setting outbound proxy" << endl );
+        Uri outboundproxy;

+        outboundproxy.host() = outboundhost;
+        outboundproxy.port() = outboundport;
+        profile->setOutboundProxy(outboundproxy);
+   }
+
   SipMessage & regMessage = clientDum.makeRegistration(userAor);
-   NameAddr contact;
+//   NameAddr contact;

+   regMessage.header(h_Expires).value() = 60;
+
   clientDum.send( regMessage );
-----------------patch end--------------------

Attachment: basicRegister.patch
Description: Binary data