@@ -7,10 +7,10 @@ HTTP_MODULE_ID CModuleConfiguration::moduleId = NULL;
7
7
BOOL CModuleConfiguration::invalid = FALSE ;
8
8
9
9
CModuleConfiguration::CModuleConfiguration ()
10
- : nodeProcessCommandLine(NULL ), logDirectoryNameSuffix (NULL ), debuggerPathSegment(NULL ),
10
+ : nodeProcessCommandLine(NULL ), logDirectory (NULL ), debuggerPathSegment(NULL ),
11
11
debugPortRange(NULL ), debugPortStart(0 ), debugPortEnd(0 ), node_env(NULL ), watchedFiles(NULL ),
12
12
enableXFF(FALSE ), promoteServerVars(NULL ), promoteServerVarsRaw(NULL ), configOverridesFileName(NULL ),
13
- configOverrides(NULL )
13
+ configOverrides(NULL ), interceptor( NULL )
14
14
{
15
15
InitializeSRWLock (&this ->srwlock );
16
16
}
@@ -23,10 +23,15 @@ CModuleConfiguration::~CModuleConfiguration()
23
23
this ->nodeProcessCommandLine = NULL ;
24
24
}
25
25
26
- if (NULL != this ->logDirectoryNameSuffix )
26
+ if (NULL != this ->interceptor ) {
27
+ delete [] this ->interceptor ;
28
+ this ->interceptor = NULL ;
29
+ }
30
+
31
+ if (NULL != this ->logDirectory )
27
32
{
28
- delete [] this ->logDirectoryNameSuffix ;
29
- this ->logDirectoryNameSuffix = NULL ;
33
+ delete [] this ->logDirectory ;
34
+ this ->logDirectory = NULL ;
30
35
}
31
36
32
37
if (NULL != this ->debuggerPathSegment )
@@ -240,6 +245,48 @@ HRESULT CModuleConfiguration::CreateNodeEnvironment(IHttpContext* ctx, DWORD deb
240
245
tmpIndex += propertySize + 1 ;
241
246
}
242
247
248
+ if (CModuleConfiguration::GetLoggingEnabled (ctx))
249
+ {
250
+ // set IISNODE_LOGGINGENABLED variable
251
+
252
+ ErrorIf ((tmpSize - (tmpIndex - tmpStart)) < 25 , ERROR_NOT_ENOUGH_MEMORY);
253
+ sprintf (tmpIndex, " IISNODE_LOGGINGENABLED=1" );
254
+ tmpIndex += 25 ;
255
+
256
+ // set IISNODE_LOGDIRECTORY variable based on the iisnode/@logDirectory configuration setting, if not empty
257
+
258
+ LPWSTR logDirectory = CModuleConfiguration::GetLogDirectory (ctx);
259
+ if (0 != wcscmp (L" " , logDirectory))
260
+ {
261
+ ErrorIf ((tmpSize - (tmpIndex - tmpStart)) < 22 , ERROR_NOT_ENOUGH_MEMORY);
262
+ sprintf (tmpIndex, " IISNODE_LOGDIRECTORY=" );
263
+ tmpIndex += 21 ;
264
+ ErrorIf (0 == (propertySize = WideCharToMultiByte (CP_ACP, 0 , logDirectory, wcslen (logDirectory), NULL , 0 , NULL , NULL )), E_FAIL);
265
+ ErrorIf ((propertySize + 1 ) > (tmpSize - (tmpStart - tmpIndex)), ERROR_NOT_ENOUGH_MEMORY);
266
+ ErrorIf (propertySize != WideCharToMultiByte (CP_ACP, 0 , logDirectory, wcslen (logDirectory), tmpIndex, propertySize, NULL , NULL ), E_FAIL);
267
+ tmpIndex += propertySize + 1 ;
268
+ }
269
+
270
+ // set IISNODE_MAXTOTALLOGFILESIZEINKB, IISNODE_MAXLOGFILESIZEINKB, and IISNODE_MAXLOGFILES variables
271
+
272
+ char tmp[64 ];
273
+ sprintf (tmp, " %d" , CModuleConfiguration::GetMaxTotalLogFileSizeInKB (ctx));
274
+ ErrorIf ((tmpSize - (tmpIndex - tmpStart)) < (strlen (tmp) + 33 ), ERROR_NOT_ENOUGH_MEMORY);
275
+ sprintf (tmpIndex, " IISNODE_MAXTOTALLOGFILESIZEINKB=%s" , tmp);
276
+ tmpIndex += strlen (tmp) + 33 ;
277
+
278
+ sprintf (tmp, " %d" , CModuleConfiguration::GetMaxLogFileSizeInKB (ctx));
279
+ ErrorIf ((tmpSize - (tmpIndex - tmpStart)) < (strlen (tmp) + 28 ), ERROR_NOT_ENOUGH_MEMORY);
280
+ sprintf (tmpIndex, " IISNODE_MAXLOGFILESIZEINKB=%s" , tmp);
281
+ tmpIndex += strlen (tmp) + 28 ;
282
+
283
+ sprintf (tmp, " %d" , CModuleConfiguration::GetMaxLogFiles (ctx));
284
+ ErrorIf ((tmpSize - (tmpIndex - tmpStart)) < (strlen (tmp) + 21 ), ERROR_NOT_ENOUGH_MEMORY);
285
+ sprintf (tmpIndex, " IISNODE_MAXLOGFILES=%s" , tmp);
286
+ tmpIndex += strlen (tmp) + 21 ;
287
+
288
+ }
289
+
243
290
// add a trailing zero to new variables
244
291
245
292
ErrorIf (1 > (tmpSize - (tmpStart - tmpIndex)), ERROR_NOT_ENOUGH_MEMORY);
@@ -584,21 +631,21 @@ HRESULT CModuleConfiguration::ApplyConfigOverrideKeyValue(IHttpContext* context,
584
631
{
585
632
CheckError (GetDWORD (valueStart, &config->gracefulShutdownTimeout ));
586
633
}
587
- else if (0 == strcmpi (keyStart, " logFileFlushInterval " ))
634
+ else if (0 == strcmpi (keyStart, " maxTotalLogFileSizeInKB " ))
588
635
{
589
- CheckError (GetDWORD (valueStart, &config->logFileFlushInterval ));
636
+ CheckError (GetDWORD (valueStart, &config->maxTotalLogFileSizeInKB ));
590
637
}
591
638
else if (0 == strcmpi (keyStart, " maxLogFileSizeInKB" ))
592
639
{
593
640
CheckError (GetDWORD (valueStart, &config->maxLogFileSizeInKB ));
594
641
}
595
- else if (0 == strcmpi (keyStart, " loggingEnabled " ))
642
+ else if (0 == strcmpi (keyStart, " maxLogFiles " ))
596
643
{
597
- CheckError (GetBOOL (valueStart, &config->loggingEnabled ));
644
+ CheckError (GetDWORD (valueStart, &config->maxLogFiles ));
598
645
}
599
- else if (0 == strcmpi (keyStart, " appendToExistingLog " ))
646
+ else if (0 == strcmpi (keyStart, " loggingEnabled " ))
600
647
{
601
- CheckError (GetBOOL (valueStart, &config->appendToExistingLog ));
648
+ CheckError (GetBOOL (valueStart, &config->loggingEnabled ));
602
649
}
603
650
else if (0 == strcmpi (keyStart, " devErrorsEnabled" ))
604
651
{
@@ -616,9 +663,9 @@ HRESULT CModuleConfiguration::ApplyConfigOverrideKeyValue(IHttpContext* context,
616
663
{
617
664
CheckError (GetBOOL (valueStart, &config->enableXFF ));
618
665
}
619
- else if (0 == strcmpi (keyStart, " logDirectoryNameSuffix " ))
666
+ else if (0 == strcmpi (keyStart, " logDirectory " ))
620
667
{
621
- CheckError (GetString (valueStart, &config->logDirectoryNameSuffix ));
668
+ CheckError (GetString (valueStart, &config->logDirectory ));
622
669
}
623
670
else if (0 == strcmpi (keyStart, " node_env" ))
624
671
{
@@ -659,7 +706,24 @@ HRESULT CModuleConfiguration::ApplyConfigOverrideKeyValue(IHttpContext* context,
659
706
strcpy (config->nodeProcessCommandLine , " " );
660
707
}
661
708
}
709
+ else if (0 == strcmpi (keyStart, " interceptor" ))
710
+ {
711
+ if (config->interceptor )
712
+ {
713
+ delete [] config->interceptor ;
714
+ config->interceptor = NULL ;
715
+ }
662
716
717
+ ErrorIf (NULL == (config->interceptor = new char [MAX_PATH]), ERROR_NOT_ENOUGH_MEMORY);
718
+ if (valueStart)
719
+ {
720
+ strcpy (config->interceptor , valueStart);
721
+ }
722
+ else
723
+ {
724
+ strcpy (config->interceptor , " " );
725
+ }
726
+ }
663
727
664
728
return S_OK;
665
729
Error:
@@ -996,13 +1060,13 @@ HRESULT CModuleConfiguration::GetConfig(IHttpContext* context, CModuleConfigurat
996
1060
CheckError (GetDWORD (section, L" maxRequestBufferSize" , &c->maxRequestBufferSize ));
997
1061
CheckError (GetDWORD (section, L" uncFileChangesPollingInterval" , &c->uncFileChangesPollingInterval ));
998
1062
CheckError (GetDWORD (section, L" gracefulShutdownTimeout" , &c->gracefulShutdownTimeout ));
999
- CheckError (GetDWORD (section, L" logFileFlushInterval " , &c->logFileFlushInterval ));
1063
+ CheckError (GetDWORD (section, L" maxTotalLogFileSizeInKB " , &c->maxTotalLogFileSizeInKB ));
1000
1064
CheckError (GetDWORD (section, L" maxLogFileSizeInKB" , &c->maxLogFileSizeInKB ));
1065
+ CheckError (GetDWORD (section, L" maxLogFiles" , &c->maxLogFiles ));
1001
1066
CheckError (GetBOOL (section, L" loggingEnabled" , &c->loggingEnabled ));
1002
- CheckError (GetBOOL (section, L" appendToExistingLog" , &c->appendToExistingLog ));
1003
1067
CheckError (GetBOOL (section, L" devErrorsEnabled" , &c->devErrorsEnabled ));
1004
1068
CheckError (GetBOOL (section, L" flushResponse" , &c->flushResponse ));
1005
- CheckError (GetString (section, L" logDirectoryNameSuffix " , &c->logDirectoryNameSuffix ));
1069
+ CheckError (GetString (section, L" logDirectory " , &c->logDirectory ));
1006
1070
CheckError (GetBOOL (section, L" debuggingEnabled" , &c->debuggingEnabled ));
1007
1071
CheckError (GetString (section, L" node_env" , &c->node_env ));
1008
1072
CheckError (GetString (section, L" debuggerPortRange" , &c->debugPortRange ));
@@ -1024,6 +1088,14 @@ HRESULT CModuleConfiguration::GetConfig(IHttpContext* context, CModuleConfigurat
1024
1088
delete [] commandLine;
1025
1089
commandLine = NULL ;
1026
1090
1091
+ // interceptor
1092
+
1093
+ CheckError (GetString (section, L" interceptor" , &commandLine));
1094
+ ErrorIf (NULL == (c->interceptor = new char [MAX_PATH]), ERROR_NOT_ENOUGH_MEMORY);
1095
+ ErrorIf (0 != wcstombs_s (&i, c->interceptor , (size_t )MAX_PATH, commandLine, _TRUNCATE), ERROR_INVALID_PARAMETER);
1096
+ delete [] commandLine;
1097
+ commandLine = NULL ;
1098
+
1027
1099
// apply config setting overrides from the optional YAML configuration file
1028
1100
1029
1101
CheckError (CModuleConfiguration::ApplyYamlConfigOverrides (context, c));
@@ -1097,6 +1169,11 @@ LPCTSTR CModuleConfiguration::GetNodeProcessCommandLine(IHttpContext* ctx)
1097
1169
GETCONFIG (nodeProcessCommandLine)
1098
1170
}
1099
1171
1172
+ LPCTSTR CModuleConfiguration::GetInterceptor (IHttpContext* ctx)
1173
+ {
1174
+ GETCONFIG (interceptor)
1175
+ }
1176
+
1100
1177
DWORD CModuleConfiguration::GetMaxConcurrentRequestsPerProcess (IHttpContext* ctx)
1101
1178
{
1102
1179
GETCONFIG (maxConcurrentRequestsPerProcess)
@@ -1132,9 +1209,9 @@ DWORD CModuleConfiguration::GetGracefulShutdownTimeout(IHttpContext* ctx)
1132
1209
GETCONFIG (gracefulShutdownTimeout)
1133
1210
}
1134
1211
1135
- LPWSTR CModuleConfiguration::GetLogDirectoryNameSuffix (IHttpContext* ctx)
1212
+ LPWSTR CModuleConfiguration::GetLogDirectory (IHttpContext* ctx)
1136
1213
{
1137
- GETCONFIG (logDirectoryNameSuffix )
1214
+ GETCONFIG (logDirectory )
1138
1215
}
1139
1216
1140
1217
LPWSTR CModuleConfiguration::GetDebuggerPathSegment (IHttpContext* ctx)
@@ -1147,24 +1224,24 @@ DWORD CModuleConfiguration::GetDebuggerPathSegmentLength(IHttpContext* ctx)
1147
1224
GETCONFIG (debuggerPathSegmentLength)
1148
1225
}
1149
1226
1150
- DWORD CModuleConfiguration::GetLogFileFlushInterval (IHttpContext* ctx)
1227
+ DWORD CModuleConfiguration::GetMaxTotalLogFileSizeInKB (IHttpContext* ctx)
1151
1228
{
1152
- GETCONFIG (logFileFlushInterval )
1229
+ GETCONFIG (maxTotalLogFileSizeInKB )
1153
1230
}
1154
1231
1155
1232
DWORD CModuleConfiguration::GetMaxLogFileSizeInKB (IHttpContext* ctx)
1156
1233
{
1157
1234
GETCONFIG (maxLogFileSizeInKB)
1158
1235
}
1159
1236
1160
- BOOL CModuleConfiguration::GetLoggingEnabled (IHttpContext* ctx)
1237
+ DWORD CModuleConfiguration::GetMaxLogFiles (IHttpContext* ctx)
1161
1238
{
1162
- GETCONFIG (loggingEnabled);
1239
+ GETCONFIG (maxLogFiles)
1163
1240
}
1164
1241
1165
- BOOL CModuleConfiguration::GetAppendToExistingLog (IHttpContext* ctx)
1242
+ BOOL CModuleConfiguration::GetLoggingEnabled (IHttpContext* ctx)
1166
1243
{
1167
- GETCONFIG (appendToExistingLog)
1244
+ GETCONFIG (loggingEnabled);
1168
1245
}
1169
1246
1170
1247
BOOL CModuleConfiguration::GetDebuggingEnabled (IHttpContext* ctx)
0 commit comments