forked from DoubangoTelecom/webrtc2sip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
resiprocate-deprecated.patch
executable file
·12363 lines (12265 loc) · 414 KB
/
resiprocate-deprecated.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Index: Makefile.am
===================================================================
--- Makefile.am (revision 9737)
+++ Makefile.am (working copy)
@@ -19,7 +19,8 @@
# The Makefiles for these don't separate SSL stuff yet...
if USE_SSL
-SUBDIRS += reTurn
+# By Mamadou: Do not enable reTurn
+#SUBDIRS += reTurn reTurn/client
if BUILD_RECON
SUBDIRS += reflow
SUBDIRS += resip/recon
Index: reSIProcate_9_0.sln
===================================================================
--- reSIProcate_9_0.sln (revision 9737)
+++ reSIProcate_9_0.sln (working copy)
@@ -53,8 +53,6 @@
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ares", "rutil\dns\ares\ares_9_0.vcproj", "{96CD935E-1951-43B8-AF75-F1C06B3778C1}"
EndProject
-Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "ReproSetup", "repro\WinSetup\Setup_9_0.vdproj", "{02954DA6-5079-4717-BC3D-B3ACA815CFED}"
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "reprolib", "repro\reprolib_9_0.vcproj", "{31B0654F-E08E-405F-909F-80F86CB14B9E}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "basicClient", "resip\dum\test\basicClient_9_0.vcproj", "{5973C598-5CB7-4724-A1EB-EBE3D9F84888}"
@@ -165,14 +163,6 @@
{96CD935E-1951-43B8-AF75-F1C06B3778C1}.SSL-Debug|Win32.Build.0 = Debug|Win32
{96CD935E-1951-43B8-AF75-F1C06B3778C1}.SSL-Release|Win32.ActiveCfg = Release|Win32
{96CD935E-1951-43B8-AF75-F1C06B3778C1}.SSL-Release|Win32.Build.0 = Release|Win32
- {02954DA6-5079-4717-BC3D-B3ACA815CFED}.Debug|Win32.ActiveCfg = Debug
- {02954DA6-5079-4717-BC3D-B3ACA815CFED}.Debug|Win32.Build.0 = Debug
- {02954DA6-5079-4717-BC3D-B3ACA815CFED}.Release|Win32.ActiveCfg = Release
- {02954DA6-5079-4717-BC3D-B3ACA815CFED}.Release|Win32.Build.0 = Release
- {02954DA6-5079-4717-BC3D-B3ACA815CFED}.SSL-Debug|Win32.ActiveCfg = Debug
- {02954DA6-5079-4717-BC3D-B3ACA815CFED}.SSL-Debug|Win32.Build.0 = Debug
- {02954DA6-5079-4717-BC3D-B3ACA815CFED}.SSL-Release|Win32.ActiveCfg = Release
- {02954DA6-5079-4717-BC3D-B3ACA815CFED}.SSL-Release|Win32.Build.0 = Release
{31B0654F-E08E-405F-909F-80F86CB14B9E}.Debug|Win32.ActiveCfg = Debug|Win32
{31B0654F-E08E-405F-909F-80F86CB14B9E}.Debug|Win32.Build.0 = Debug|Win32
{31B0654F-E08E-405F-909F-80F86CB14B9E}.Release|Win32.ActiveCfg = Release|Win32
Index: repro/AclStore.cxx
===================================================================
--- repro/AclStore.cxx (revision 9737)
+++ repro/AclStore.cxx (working copy)
@@ -498,8 +498,8 @@
bool
AclStore::isRequestTrusted(const SipMessage& request)
{
- bool trusted = false;
- Tuple source = request.getSource();
+ Tuple source = request.getSource();
+ bool trusted = (source.getType() == resip::WS);
// check if the request came over a secure channel and sucessfully authenticated
// (ex: TLS or DTLS)
Index: repro/RRDecorator.cxx
===================================================================
--- repro/RRDecorator.cxx (revision 9737)
+++ repro/RRDecorator.cxx (working copy)
@@ -171,9 +171,12 @@
InfoLog(<< "Adding outbound Record-Route: " << rt);
}
- routes->front().uri().param(p_drr);
- routes->push_front(rt);
- ++mAddedRecordRoute;
+ if(routes->size() > 0){
+ routes->front().uri().param(p_drr);
+ }
+
+ routes->push_front(rt);
+ ++mAddedRecordRoute;
}
void
Index: repro/ReproRunner.cxx
===================================================================
--- repro/ReproRunner.cxx (revision 9737)
+++ repro/ReproRunner.cxx (working copy)
@@ -1,1352 +1,1358 @@
-#if defined(HAVE_CONFIG_H)
-#include "config.h"
-#endif
-
-#include "rutil/Log.hxx"
-#include "rutil/Logger.hxx"
-#include "rutil/DnsUtil.hxx"
-#include "rutil/dns/DnsStub.hxx"
-#include "rutil/GeneralCongestionManager.hxx"
-
-#include "resip/stack/SipStack.hxx"
-#include "resip/stack/Compression.hxx"
-#include "resip/stack/EventStackThread.hxx"
-#include "resip/stack/InteropHelper.hxx"
-#include "resip/stack/ConnectionManager.hxx"
-
-#include "resip/dum/InMemorySyncRegDb.hxx"
-#include "resip/dum/MasterProfile.hxx"
-#include "resip/dum/DialogUsageManager.hxx"
-#include "resip/dum/DumThread.hxx"
-#include "resip/dum/TlsPeerAuthManager.hxx"
-
-#include "repro/AsyncProcessorWorker.hxx"
-#include "repro/ReproRunner.hxx"
-#include "repro/Proxy.hxx"
-#include "repro/ProxyConfig.hxx"
-#include "repro/BerkeleyDb.hxx"
-#include "repro/Dispatcher.hxx"
-#include "repro/UserAuthGrabber.hxx"
-#include "repro/ProcessorChain.hxx"
-#include "repro/ReproVersion.hxx"
-#include "repro/WebAdmin.hxx"
-#include "repro/WebAdminThread.hxx"
-#include "repro/Registrar.hxx"
-#include "repro/ReproServerAuthManager.hxx"
-#include "repro/RegSyncClient.hxx"
-#include "repro/RegSyncServer.hxx"
-#include "repro/RegSyncServerThread.hxx"
-#include "repro/CommandServer.hxx"
-#include "repro/CommandServerThread.hxx"
-#include "repro/monkeys/IsTrustedNode.hxx"
-#include "repro/monkeys/AmIResponsible.hxx"
-#include "repro/monkeys/DigestAuthenticator.hxx"
-#include "repro/monkeys/LocationServer.hxx"
-#include "repro/monkeys/RecursiveRedirect.hxx"
-#include "repro/monkeys/SimpleStaticRoute.hxx"
-#include "repro/monkeys/StaticRoute.hxx"
-#include "repro/monkeys/StrictRouteFixup.hxx"
-#include "repro/monkeys/OutboundTargetHandler.hxx"
-#include "repro/monkeys/QValueTargetHandler.hxx"
-#include "repro/monkeys/SimpleTargetHandler.hxx"
-#include "repro/monkeys/GeoProximityTargetSorter.hxx"
-#include "repro/monkeys/RequestFilter.hxx"
-#include "repro/monkeys/MessageSilo.hxx"
-#include "repro/monkeys/CertificateAuthenticator.hxx"
-
-#if defined(USE_SSL)
-#include "repro/stateAgents/CertServer.hxx"
-#include "resip/stack/ssl/Security.hxx"
-#endif
-
-#if defined(USE_MYSQL)
-#include "repro/MySqlDb.hxx"
-#endif
-
-#include "rutil/WinLeakCheck.hxx"
-
-#define RESIPROCATE_SUBSYSTEM resip::Subsystem::REPRO
-
-using namespace resip;
-using namespace repro;
-using namespace std;
-
-class ReproLogger : public ExternalLogger
-{
-public:
- virtual ~ReproLogger() {}
- /** return true to also do default logging, false to supress default logging. */
- virtual bool operator()(Log::Level level,
- const Subsystem& subsystem,
- const Data& appName,
- const char* file,
- int line,
- const Data& message,
- const Data& messageWithHeaders)
- {
- // Log any errors to the screen
- if(level <= Log::Err)
- {
- resipCout << messageWithHeaders << endl;
- }
- return true;
- }
-};
-ReproLogger g_ReproLogger;
-
-ReproRunner::ReproRunner()
- : mRunning(false)
- , mRestarting(false)
- , mThreadedStack(false)
- , mSipAuthDisabled(false)
- , mUseV4(true)
- , mUseV6 (false)
- , mRegSyncPort(0)
- , mProxyConfig(0)
- , mFdPollGrp(0)
- , mAsyncProcessHandler(0)
- , mSipStack(0)
- , mStackThread(0)
- , mAbstractDb(0)
- , mRegistrationPersistenceManager(0)
- , mAuthRequestDispatcher(0)
- , mAsyncProcessorDispatcher(0)
- , mMonkeys(0)
- , mLemurs(0)
- , mBaboons(0)
- , mProxy(0)
- , mWebAdmin(0)
- , mWebAdminThread(0)
- , mRegistrar(0)
- , mDum(0)
- , mDumThread(0)
- , mCertServer(0)
- , mRegSyncClient(0)
- , mRegSyncServerV4(0)
- , mRegSyncServerV6(0)
- , mRegSyncServerThread(0)
- , mCommandServerV4(0)
- , mCommandServerV6(0)
- , mCommandServerThread(0)
- , mCongestionManager(0)
-{
-}
-
-ReproRunner::~ReproRunner()
-{
- if(mRunning) shutdown();
-}
-
-bool
-ReproRunner::run(int argc, char** argv)
-{
- if(mRunning) return false;
-
- if(!mRestarting)
- {
- // Store original arc and argv - so we can reuse them on restart request
- mArgc = argc;
- mArgv = argv;
- }
-
- // Parse command line and configuration file
- assert(!mProxyConfig);
- Data defaultConfigFilename("repro.config");
- try
- {
- mProxyConfig = new ProxyConfig(mArgc, mArgv, defaultConfigFilename);
- }
- catch(BaseException& ex)
- {
- std::cerr << "Error parsing configuration: " << ex << std::endl;
- return false;
- }
-
- // Non-Windows server process stuff
- if(!mRestarting)
- {
- setPidFile(mProxyConfig->getConfigData("PidFile", "", true));
- if(mProxyConfig->getConfigBool("Daemonize", false))
- {
- daemonize();
- }
- }
-
- // Initialize resip logger
- GenericLogImpl::MaxByteCount = mProxyConfig->getConfigUnsignedLong("LogFileMaxBytes", 5242880 /*5 Mb */);
- Data loggingType = mProxyConfig->getConfigData("LoggingType", "cout", true);
- Log::initialize(loggingType,
- mProxyConfig->getConfigData("LogLevel", "INFO", true),
- mArgv[0],
- mProxyConfig->getConfigData("LogFilename", "repro.log", true).c_str(),
- isEqualNoCase(loggingType, "file") ? &g_ReproLogger : 0); // if logging to file then write WARNINGS, and Errors to console still
-
- InfoLog( << "Starting repro version " << VersionUtils::instance().releaseVersion() << "...");
-
- // Create SipStack and associated objects
- if(!createSipStack())
- {
- return false;
- }
-
- // Create datastore
- if(!createDatastore())
- {
- return false;
- }
-
- // Create DialogUsageManager that handles ServerRegistration,
- // and potentially certificate subscription server
- createDialogUsageManager();
-
- // Create the Proxy and associate objects
- if(!createProxy())
- {
- return false;
- }
-
- // Create HTTP WebAdmin and Thread
- if(!createWebAdmin())
- {
- return false;
- }
-
- // Create reg sync components if required
- createRegSync();
-
- // Create command server if required
- if(!mRestarting)
- {
- createCommandServer();
- }
-
- // Make it all go - startup all threads
- mThreadedStack = mProxyConfig->getConfigBool("ThreadedStack", true);
- if(mThreadedStack)
- {
- // If configured, then start the sub-threads within the stack
- mSipStack->run();
- }
- mStackThread->run();
- if(mDumThread)
- {
- mDumThread->run();
- }
- mProxy->run();
- if(mWebAdminThread)
- {
- mWebAdminThread->run();
- }
- if(!mRestarting && mCommandServerThread)
- {
- mCommandServerThread->run();
- }
- if(mRegSyncServerThread)
- {
- mRegSyncServerThread->run();
- }
- if(mRegSyncClient)
- {
- mRegSyncClient->run();
- }
-
- mRunning = true;
-
- return true;
-}
-
-void
-ReproRunner::shutdown()
-{
- if(!mRunning) return;
-
- // Tell all threads to shutdown
- if(mWebAdminThread)
- {
- mWebAdminThread->shutdown();
- }
- if(mDumThread)
- {
- mDumThread->shutdown();
- }
- mProxy->shutdown();
- mStackThread->shutdown();
- if(!mRestarting && mCommandServerThread) // leave command server running if we are restarting
- {
- mCommandServerThread->shutdown();
- }
- if(mRegSyncServerThread)
- {
- mRegSyncServerThread->shutdown();
- }
- if(mRegSyncClient)
- {
- mRegSyncClient->shutdown();
- }
-
- // Wait for all threads to shutdown, and destroy objects
- mProxy->join();
- if(mThreadedStack)
- {
- mSipStack->shutdownAndJoinThreads();
- }
- mStackThread->join();
- if(mWebAdminThread)
- {
- mWebAdminThread->join();
- }
- if(mDumThread)
- {
- mDumThread->join();
- }
- if(mAuthRequestDispatcher)
- {
- // Both proxy and dum threads are down at this point, we can
- // destroy the authRequest dispatcher and associated threads now
- delete mAuthRequestDispatcher;
- mAuthRequestDispatcher = 0;
- }
- if(mAsyncProcessorDispatcher)
- {
- // Both proxy and dum threads are down at this point, we can
- // destroy the async processor dispatcher and associated threads now
- delete mAsyncProcessorDispatcher;
- mAsyncProcessorDispatcher = 0;
- }
- if(!mRestarting && mCommandServerThread) // we leave command server running during restart
- {
- mCommandServerThread->join();
- }
- if(mRegSyncServerThread)
- {
- mRegSyncServerThread->join();
- }
- if(mRegSyncClient)
- {
- mRegSyncClient->join();
- }
-
- mSipStack->setCongestionManager(0);
-
- cleanupObjects();
- mRunning = false;
-}
-
-void
-ReproRunner::restart()
-{
- if(!mRunning) return;
- mRestarting = true;
- shutdown();
- run(0, 0);
- mRestarting = false;
-}
-
-void
-ReproRunner::cleanupObjects()
-{
- delete mCongestionManager; mCongestionManager = 0;
- if(!mRestarting)
- {
- // We leave command server running during restart
- delete mCommandServerThread; mCommandServerThread = 0;
- delete mCommandServerV6; mCommandServerV6 = 0;
- delete mCommandServerV4; mCommandServerV4 = 0;
- }
- delete mRegSyncServerThread; mRegSyncServerThread = 0;
- delete mRegSyncServerV6; mRegSyncServerV6 = 0;
- delete mRegSyncServerV4; mRegSyncServerV4 = 0;
- delete mRegSyncClient; mRegSyncClient = 0;
-#if defined(USE_SSL)
- delete mCertServer; mCertServer = 0;
-#endif
- delete mDumThread; mDumThread = 0;
- delete mDum; mDum = 0;
- delete mRegistrar; mRegistrar = 0;
- delete mWebAdminThread; mWebAdminThread = 0;
- delete mWebAdmin; mWebAdmin = 0;
- delete mProxy; mProxy = 0;
- delete mBaboons; mBaboons = 0;
- delete mLemurs; mLemurs = 0;
- delete mMonkeys; mMonkeys = 0;
- delete mAuthRequestDispatcher; mAuthRequestDispatcher = 0;
- delete mAsyncProcessorDispatcher; mAsyncProcessorDispatcher = 0;
- if(!mRestarting)
- {
- // If we are restarting then leave the In Memory Registration database intact
- delete mRegistrationPersistenceManager; mRegistrationPersistenceManager = 0;
- }
- delete mAbstractDb; mAbstractDb = 0;
- delete mStackThread; mStackThread = 0;
- delete mSipStack; mSipStack = 0;
- delete mAsyncProcessHandler; mAsyncProcessHandler = 0;
- delete mFdPollGrp; mFdPollGrp = 0;
- delete mProxyConfig; mProxyConfig = 0;
-}
-
-bool
-ReproRunner::createSipStack()
-{
- // Override T1 timer if configured to do so
- unsigned long overrideT1 = mProxyConfig->getConfigInt("TimerT1", 0);
- if(overrideT1)
- {
- WarningLog(<< "Overriding T1! (new value is " <<
- overrideT1 << ")");
- resip::Timer::resetT1(overrideT1);
- }
-
- // Create Security (TLS / Certificates) and Compression (SigComp) objects if
- // pre-precessor defines are enabled
- Security* security = 0;
- Compression* compression = 0;
-#ifdef USE_SSL
-#ifdef WIN32
- Data certPath("C:\\sipCerts");
-#else
- Data certPath(getenv("HOME"));
- certPath += "/.sipCerts";
-#endif
- mProxyConfig->getConfigValue("CertificatePath", certPath);
- security = new Security(certPath);
- Data caDir;
- mProxyConfig->getConfigValue("CADirectory", caDir);
- if(!caDir.empty())
- {
- security->addCADirectory(caDir);
- }
- Data caFile;
- mProxyConfig->getConfigValue("CAFile", caFile);
- if(!caFile.empty())
- {
- security->addCAFile(caFile);
- }
-#endif
-
-#ifdef USE_SIGCOMP
- compression = new Compression(Compression::DEFLATE);
-#endif
-
- // Create EventThreadInterruptor used to wake up the stack for
- // for reasons other than an Fd signalling
- assert(!mFdPollGrp);
- mFdPollGrp = FdPollGrp::create();
- assert(!mAsyncProcessHandler);
- mAsyncProcessHandler = new EventThreadInterruptor(*mFdPollGrp);
-
- // Set Flags that will enable/disable IPv4 and/or IPv6, based on
- // configuration and pre-processor flags
- mUseV4 = !mProxyConfig->getConfigBool("DisableIPv4", false);
-#ifdef USE_IPV6
- mUseV6 = mProxyConfig->getConfigBool("EnableIPv6", true);
-#else
- bool useV6 = false;
-#endif
- if (mUseV4) InfoLog (<< "V4 enabled");
- if (mUseV6) InfoLog (<< "V6 enabled");
-
- // Build DNS Server list from config
- DnsStub::NameserverList dnsServers;
- std::vector<resip::Data> dnsServersConfig;
- mProxyConfig->getConfigValue("DNSServers", dnsServersConfig);
- for(std::vector<resip::Data>::iterator it = dnsServersConfig.begin(); it != dnsServersConfig.end(); it++)
- {
- if((mUseV4 && DnsUtil::isIpV4Address(*it)) || (mUseV6 && DnsUtil::isIpV6Address(*it)))
- {
- InfoLog(<< "Using DNS Server from config: " << *it);
- dnsServers.push_back(Tuple(*it, 0, UNKNOWN_TRANSPORT).toGenericIPAddress());
- }
- }
-
- // Create the SipStack Object
- assert(!mSipStack);
- mSipStack = new SipStack(security,
- dnsServers,
- mAsyncProcessHandler,
- /*stateless*/false,
- /*socketFunc*/0,
- compression,
- mFdPollGrp);
-
- // Set any enum suffixes from configuration
- std::vector<Data> enumSuffixes;
- mProxyConfig->getConfigValue("EnumSuffixes", enumSuffixes);
- if (enumSuffixes.size() > 0)
- {
- mSipStack->setEnumSuffixes(enumSuffixes);
- }
-
- // Add stack transports
- bool allTransportsSpecifyRecordRoute=false;
- if(!addTransports(allTransportsSpecifyRecordRoute))
- {
- cleanupObjects();
- return false;
- }
-
- // Enable and configure RFC5626 Outbound support
- InteropHelper::setOutboundVersion(mProxyConfig->getConfigInt("OutboundVersion", 5626));
- InteropHelper::setOutboundSupported(mProxyConfig->getConfigBool("DisableOutbound", false) ? false : true);
- InteropHelper::setRRTokenHackEnabled(mProxyConfig->getConfigBool("EnableFlowTokens", false));
- InteropHelper::setAssumeFirstHopSupportsOutboundEnabled(mProxyConfig->getConfigBool("AssumeFirstHopSupportsOutbound", false));
- Data clientNATDetectionMode = mProxyConfig->getConfigData("ClientNatDetectionMode", "DISABLED");
- if(isEqualNoCase(clientNATDetectionMode, "ENABLED"))
- {
- InteropHelper::setClientNATDetectionMode(InteropHelper::ClientNATDetectionEnabled);
- }
- else if(isEqualNoCase(clientNATDetectionMode, "PRIVATE_TO_PUBLIC"))
- {
- InteropHelper::setClientNATDetectionMode(InteropHelper::ClientNATDetectionPrivateToPublicOnly);
- }
- unsigned long outboundFlowTimer = mProxyConfig->getConfigUnsignedLong("FlowTimer", 0);
- if(outboundFlowTimer > 0)
- {
- InteropHelper::setFlowTimerSeconds(outboundFlowTimer);
- ConnectionManager::MinimumGcAge = 7200000; // Timeout connections not related to a flow timer after 2 hours - TODO make configurable
- ConnectionManager::EnableAgressiveGc = true;
- }
-
- // Check Path and RecordRoute settings, print warning if features are enabled that
- // require record-routing and record-route uri(s) is not configured
- bool assumePath = mProxyConfig->getConfigBool("AssumePath", false);
- bool forceRecordRoute = mProxyConfig->getConfigBool("ForceRecordRouting", false);
- Uri recordRouteUri;
- mProxyConfig->getConfigValue("RecordRouteUri", recordRouteUri);
- if((InteropHelper::getOutboundSupported()
- || InteropHelper::getRRTokenHackEnabled()
- || InteropHelper::getClientNATDetectionMode() != InteropHelper::ClientNATDetectionDisabled
- || assumePath
- || forceRecordRoute
- )
- && !(allTransportsSpecifyRecordRoute || !recordRouteUri.host().empty()))
- {
- CritLog(<< "In order for outbound support, the Record-Route flow-token"
- " hack, or force-record-route to work, you MUST specify a Record-Route URI. Launching "
- "without...");
- InteropHelper::setOutboundSupported(false);
- InteropHelper::setRRTokenHackEnabled(false);
- InteropHelper::setClientNATDetectionMode(InteropHelper::ClientNATDetectionDisabled);
- assumePath = false;
- forceRecordRoute=false;
- }
-
- // Configure misc. stack settings
- mSipStack->setFixBadDialogIdentifiers(false);
- mSipStack->setFixBadCSeqNumbers(false);
- int statsLogInterval = mProxyConfig->getConfigInt("StatisticsLogInterval", 60);
- if(statsLogInterval > 0)
- {
- mSipStack->setStatisticsInterval(statsLogInterval);
- mSipStack->statisticsManagerEnabled() = true;
- }
- else
- {
- mSipStack->statisticsManagerEnabled() = false;
- }
-
- // Create Congestion Manager, if required
- assert(!mCongestionManager);
- if(mProxyConfig->getConfigBool("CongestionManagement", true))
- {
- Data metricData = mProxyConfig->getConfigData("CongestionManagementMetric", "WAIT_TIME", true);
- GeneralCongestionManager::MetricType metric = GeneralCongestionManager::WAIT_TIME;
- if(isEqualNoCase(metricData, "TIME_DEPTH"))
- {
- metric = GeneralCongestionManager::TIME_DEPTH;
- }
- else if(isEqualNoCase(metricData, "SIZE"))
- {
- metric = GeneralCongestionManager::SIZE;
- }
- else if(!isEqualNoCase(metricData, "WAIT_TIME"))
- {
- WarningLog( << "CongestionManagementMetric specified as an unknown value (" << metricData << "), defaulting to WAIT_TIME.");
- }
- mCongestionManager = new GeneralCongestionManager(
- metric,
- mProxyConfig->getConfigUnsignedLong("CongestionManagementTolerance", 200));
- mSipStack->setCongestionManager(mCongestionManager);
- }
-
- // Create base thread to run stack in (note: stack may use other sub-threads, depending on configuration)
- assert(!mStackThread);
- mStackThread = new EventStackThread(*mSipStack,
- *dynamic_cast<EventThreadInterruptor*>(mAsyncProcessHandler),
- *mFdPollGrp);
- return true;
-}
-
-bool
-ReproRunner::createDatastore()
-{
- // Create Database access objects
- assert(!mAbstractDb);
-#ifdef USE_MYSQL
- Data mySQLServer;
- mProxyConfig->getConfigValue("MySQLServer", mySQLServer);
- if (!mySQLServer.empty())
- {
- mAbstractDb = new MySqlDb(mySQLServer,
- mProxyConfig->getConfigData("MySQLUser", ""),
- mProxyConfig->getConfigData("MySQLPassword", ""),
- mProxyConfig->getConfigData("MySQLDatabaseName", ""),
- mProxyConfig->getConfigUnsignedLong("MySQLPort", 0),
- mProxyConfig->getConfigData("MySQLCustomUserAuthQuery", ""));
- }
-#endif
- if (!mAbstractDb)
- {
- mAbstractDb = new BerkeleyDb(mProxyConfig->getConfigData("DatabasePath", "./", true));
- }
- assert(mAbstractDb);
- if(!mAbstractDb->isSane())
- {
- CritLog(<<"Failed to open configuration database");
- cleanupObjects();
- return false;
- }
- mProxyConfig->createDataStore(mAbstractDb);
-
- // Create ImMemory Registration Database
- mRegSyncPort = mProxyConfig->getConfigInt("RegSyncPort", 0);
- // We only need removed records to linger if we have reg sync enabled
- if(!mRestarting) // If we are restarting then we left the InMemoryRegistrationDb intact at shutdown - don't recreate
- {
- assert(!mRegistrationPersistenceManager);
- mRegistrationPersistenceManager = new InMemorySyncRegDb(mRegSyncPort ? 86400 /* 24 hours */ : 0 /* removeLingerSecs */); // !slg! could make linger time a setting
- }
- assert(mRegistrationPersistenceManager);
-
- // Copy contacts from the StaticRegStore to the RegistrationPersistanceManager
- populateRegistrations();
-
- return true;
-}
-
-void
-ReproRunner::createDialogUsageManager()
-{
- // Create Profile settings for DUM Instance that handles ServerRegistration,
- // and potentially certificate subscription server
- SharedPtr<MasterProfile> profile(new MasterProfile);
- profile->clearSupportedMethods();
- profile->addSupportedMethod(resip::REGISTER);
-#ifdef USE_SSL
- profile->addSupportedScheme(Symbols::Sips);
-#endif
- if(InteropHelper::getOutboundSupported())
- {
- profile->addSupportedOptionTag(Token(Symbols::Outbound));
- }
- profile->addSupportedOptionTag(Token(Symbols::Path));
- if(mProxyConfig->getConfigBool("AllowBadReg", false))
- {
- profile->allowBadRegistrationEnabled() = true;
- }
-
- // Create DialogeUsageManager if Registrar or Certificate Server are enabled
- assert(!mRegistrar);
- assert(!mDum);
- assert(!mDumThread);
- mRegistrar = new Registrar;
- resip::MessageFilterRuleList ruleList;
- bool registrarEnabled = !mProxyConfig->getConfigBool("DisableRegistrar", false);
- bool certServerEnabled = mProxyConfig->getConfigBool("EnableCertServer", false);
- if (registrarEnabled || certServerEnabled)
- {
- mDum = new DialogUsageManager(*mSipStack);
- mDum->setMasterProfile(profile);
- addDomains(*mDum, false /* log? already logged when adding to Proxy - no need to log again*/);
- }
-
- // If registrar is enabled, configure DUM to handle REGISTER requests
- if (registrarEnabled)
- {
- assert(mDum);
- assert(mRegistrationPersistenceManager);
- mDum->setServerRegistrationHandler(mRegistrar);
- mDum->setRegistrationPersistenceManager(mRegistrationPersistenceManager);
-
- // Install rules so that the registrar only gets REGISTERs
- resip::MessageFilterRule::MethodList methodList;
- methodList.push_back(resip::REGISTER);
- ruleList.push_back(MessageFilterRule(resip::MessageFilterRule::SchemeList(),
- resip::MessageFilterRule::DomainIsMe,
- methodList) );
- }
-
- // If Certificate Server is enabled, configure DUM to handle SUBSCRIBE and
- // PUBLISH requests for events: credential and certificate
- assert(!mCertServer);
- if (certServerEnabled)
- {
-#if defined(USE_SSL)
- mCertServer = new CertServer(*mDum);
-
- // Install rules so that the cert server receives SUBSCRIBEs and PUBLISHs
- resip::MessageFilterRule::MethodList methodList;
- resip::MessageFilterRule::EventList eventList;
- methodList.push_back(resip::SUBSCRIBE);
- methodList.push_back(resip::PUBLISH);
- eventList.push_back(resip::Symbols::Credential);
- eventList.push_back(resip::Symbols::Certificate);
- ruleList.push_back(MessageFilterRule(resip::MessageFilterRule::SchemeList(),
- resip::MessageFilterRule::DomainIsMe,
- methodList,
- eventList));
-#endif
- }
-
- if (mDum)
- {
- if(mProxyConfig->getConfigBool("EnableCertificateAuthenticator", false))
- {
- // TODO: perhaps this should be initialised from the trusted node
- // monkey? Or should the list of trusted TLS peers be independent
- // from the trusted node list?
- std::set<Data> trustedPeers;
- SharedPtr<TlsPeerAuthManager> certAuth(new TlsPeerAuthManager(*mDum, mDum->dumIncomingTarget(), trustedPeers));
- mDum->addIncomingFeature(certAuth);
- }
-
- mSipAuthDisabled = mProxyConfig->getConfigBool("DisableAuth", false);
-
- // If Authentication is enabled, then configure DUM to authenticate requests
- if (!mSipAuthDisabled)
- {
- // Create UserAuthGrabber Worker Thread Pool if auth is enabled
- assert(!mAuthRequestDispatcher);
- int numAuthGrabberWorkerThreads = mProxyConfig->getConfigInt("NumAuthGrabberWorkerThreads", 2);
- if(numAuthGrabberWorkerThreads < 1) numAuthGrabberWorkerThreads = 1; // must have at least one thread
- std::auto_ptr<Worker> grabber(new UserAuthGrabber(mProxyConfig->getDataStore()->mUserStore));
- mAuthRequestDispatcher = new Dispatcher(grabber, mSipStack, numAuthGrabberWorkerThreads);
-
- SharedPtr<ServerAuthManager>
- uasAuth( new ReproServerAuthManager(*mDum,
- mAuthRequestDispatcher,
- mProxyConfig->getDataStore()->mAclStore,
- !mProxyConfig->getConfigBool("DisableAuthInt", false) /*useAuthInt*/,
- mProxyConfig->getConfigBool("RejectBadNonces", false)));
- mDum->setServerAuthManager(uasAuth);
- }
-
- // Set the MessageFilterRuleList on DUM and create a thread to run DUM in
- mDum->setMessageFilterRuleList(ruleList);
- mDumThread = new DumThread(*mDum);
- }
-}
-
-bool
-ReproRunner::createProxy()
-{
- // Create AsyncProcessorDispatcher thread pool that is shared by the processsors for
- // any asyncronous tasks (ie: RequestFilter and MessageSilo processors)
- int numAsyncProcessorWorkerThreads = mProxyConfig->getConfigInt("NumAsyncProcessorWorkerThreads", 2);
- if(numAsyncProcessorWorkerThreads > 0)
- {
- assert(!mAsyncProcessorDispatcher);
- mAsyncProcessorDispatcher = new Dispatcher(std::auto_ptr<Worker>(new AsyncProcessorWorker),
- mSipStack,
- numAsyncProcessorWorkerThreads);
- }
-
- // Create proxy processor chains
- /* Explanation: "Monkeys" are processors which operate on incoming requests
- "Lemurs" are processors which operate on incoming responses
- "Baboons" are processors which operate on a request for each target
- as the request is about to be forwarded to that target */
- // Make Monkeys
- assert(!mMonkeys);
- mMonkeys = new ProcessorChain(Processor::REQUEST_CHAIN);
- makeRequestProcessorChain(*mMonkeys);
- InfoLog(<< *mMonkeys);
-
- // Make Lemurs
- assert(!mLemurs);
- mLemurs = new ProcessorChain(Processor::RESPONSE_CHAIN);
- makeResponseProcessorChain(*mLemurs);
- InfoLog(<< *mLemurs);
-
- // Make Baboons
- assert(!mBaboons);
- mBaboons = new ProcessorChain(Processor::TARGET_CHAIN);
- makeTargetProcessorChain(*mBaboons);
- InfoLog(<< *mBaboons);
-
- // Create main Proxy class
- assert(!mProxy);
- mProxy = new Proxy(*mSipStack,
- *mProxyConfig,
- *mMonkeys,
- *mLemurs,
- *mBaboons);
- mHttpRealm = addDomains(*mProxy, true);
-
- // Register the Proxy class a stack transaction user
- // Note: This is done after creating the DialogUsageManager so that it acts
- // like a catchall and will handle all requests the DUM does not
- mSipStack->registerTransactionUser(*mProxy);
-
- return true;
-}
-
-void
-ReproRunner::populateRegistrations()
-{
- assert(mRegistrationPersistenceManager);
- assert(mProxyConfig);
- assert(mProxyConfig->getDataStore());
-
- // Copy contacts from the StaticRegStore to the RegistrationPersistanceManager
- StaticRegStore::StaticRegRecordMap& staticRegList = mProxyConfig->getDataStore()->mStaticRegStore.getStaticRegList();
- StaticRegStore::StaticRegRecordMap::iterator it = staticRegList.begin();
- for(; it != staticRegList.end(); it++)
- {
- try
- {
- Uri aor(it->second.mAor);
-
- ContactInstanceRecord rec;
- rec.mContact = NameAddr(it->second.mContact);
- rec.mSipPath = NameAddrs(it->second.mPath);
- rec.mRegExpires = NeverExpire;
- rec.mSyncContact = true; // Tag this permanent contact as being a syncronized contact so that it will
- // be syncronized to a paired server (this is actually configuration information)
- mRegistrationPersistenceManager->updateContact(aor, rec);
- }
- catch(resip::ParseBuffer::Exception& e)
- {
- // This should never happen, since the format should be verified before writing to DB
- ErrLog(<<"Failed to apply a static registration due to parse error: " << e);
- }
- }
-}
-
-bool
-ReproRunner::createWebAdmin()
-{
- assert(!mWebAdmin);
- assert(!mWebAdminThread);
- int httpPort = mProxyConfig->getConfigInt("HttpPort", 5080);
- if (httpPort)
- {
- mWebAdmin = new WebAdmin(*mProxy,
- *mRegistrationPersistenceManager,
- mHttpRealm,
- httpPort);
- if (!mWebAdmin->isSane())
- {
- CritLog(<<"Failed to start the WebAdmin");
- cleanupObjects();
- return false;
- }
- mWebAdminThread = new WebAdminThread(*mWebAdmin);
- }
- return true;
-}
-
-void
-ReproRunner::createRegSync()
-{
- assert(!mRegSyncClient);
- assert(!mRegSyncServerV4);
- assert(!mRegSyncServerV6);
- assert(!mRegSyncServerThread);
- if(mRegSyncPort != 0)
- {
- std::list<RegSyncServer*> regSyncServerList;
- if(mUseV4)
- {
- mRegSyncServerV4 = new RegSyncServer(dynamic_cast<InMemorySyncRegDb*>(mRegistrationPersistenceManager), mRegSyncPort, V4);
- regSyncServerList.push_back(mRegSyncServerV4);
- }
- if(mUseV6)
- {
- mRegSyncServerV6 = new RegSyncServer(dynamic_cast<InMemorySyncRegDb*>(mRegistrationPersistenceManager), mRegSyncPort, V6);
- regSyncServerList.push_back(mRegSyncServerV6);
- }
- if(!regSyncServerList.empty())
- {
- mRegSyncServerThread = new RegSyncServerThread(regSyncServerList);
- }
- Data regSyncPeerAddress(mProxyConfig->getConfigData("RegSyncPeer", ""));
- if(!regSyncPeerAddress.empty())
- {
- mRegSyncClient = new RegSyncClient(dynamic_cast<InMemorySyncRegDb*>(mRegistrationPersistenceManager), regSyncPeerAddress, mRegSyncPort);
- }
- }
-}
-
-void
-ReproRunner::createCommandServer()
-{
- assert(!mCommandServerV4);
- assert(!mCommandServerV6);
- assert(!mCommandServerThread);
- int commandPort = mProxyConfig->getConfigInt("CommandPort", 5081);
- if(commandPort != 0)
- {
- std::list<CommandServer*> commandServerList;
- if(mUseV4)
- {
- mCommandServerV4 = new CommandServer(*this, commandPort, V4);
- commandServerList.push_back(mCommandServerV4);
- }
- if(mUseV6)
- {
- mCommandServerV6 = new CommandServer(*this, commandPort, V6);
- commandServerList.push_back(mCommandServerV6);
- }
- if(!commandServerList.empty())
- {
- mCommandServerThread = new CommandServerThread(commandServerList);
- }
- }
-}
-
-Data
-ReproRunner::addDomains(TransactionUser& tu, bool log)
-{
- assert(mProxyConfig);
- Data realm;
-
- std::vector<Data> configDomains;
- if(mProxyConfig->getConfigValue("Domains", configDomains))
- {
- for (std::vector<Data>::const_iterator i=configDomains.begin();
- i != configDomains.end(); ++i)
- {