@@ -65,16 +65,38 @@ char ip[] = "200.249.12.31";
65
65
66
66
char rules_file[] = " basic_rules.conf" ;
67
67
68
+ const char * const help_message = " Usage: benchmark [num_iterations|-h|-?|--help]" ;
68
69
69
- # define NUM_REQUESTS 10000
70
+ int main ( int argc, char *argv[]) {
70
71
72
+ unsigned long long NUM_REQUESTS (10000 );
71
73
72
- int main (int argc, char *argv[]) {
73
- int i = 0 ;
74
+ if (argc > 1 ) {
75
+ if (0 == strcmp (argv[1 ], " -h" ) ||
76
+ 0 == strcmp (argv[1 ], " -?" ) ||
77
+ 0 == strcmp (argv[1 ], " --help" )) {
78
+ std::cout << help_message << std::endl;
79
+ return 0 ;
80
+ }
81
+ errno = 0 ;
82
+ unsigned long long upper = strtoull (argv[1 ], 0 , 10 );
83
+ if (!errno && upper) {
84
+ NUM_REQUESTS = upper;
85
+ } else {
86
+ if (errno) {
87
+ perror (" Invalid number of iterations" );
88
+ } else {
89
+ std::cerr << " Failed to convert '" << argv[1 ] << " ' to integer value" << std::endl
90
+ << help_message << std::endl;
91
+ return -1 ;
92
+ }
93
+ }
94
+ }
95
+ std::cout << " Doing " << NUM_REQUESTS << " transactions...\n " ;
74
96
modsecurity::ModSecurity *modsec;
75
97
modsecurity::Rules *rules;
76
98
modsecurity::ModSecurityIntervention it;
77
-
99
+ modsecurity::intervention::reset (&it);
78
100
modsec = new modsecurity::ModSecurity ();
79
101
modsec->setConnectorInformation (" ModSecurity-benchmark v0.0.1-alpha" \
80
102
" (ModSecurity benchmark utility)" );
@@ -86,8 +108,8 @@ int main(int argc, char *argv[]) {
86
108
return -1 ;
87
109
}
88
110
89
- for (i = 0 ; i < NUM_REQUESTS; i++) {
90
- std::cout << " Proceeding with request " << i << std::endl;
111
+ for (unsigned long long i = 0 ; i < NUM_REQUESTS; i++) {
112
+ // std::cout << "Proceeding with request " << i << std::endl;
91
113
92
114
Transaction *modsecTransaction = new Transaction (modsec, rules, NULL );
93
115
modsecTransaction->processConnection (ip, 12345 , " 127.0.0.1" , 80 );
0 commit comments