Skip to content
Snippets Groups Projects
Commit e2ca196b authored by Tomáš Plesník's avatar Tomáš Plesník
Browse files

pridan limit pro nastaveni maximalniho poctu odeslanych udalosti klientovi,...

pridan limit pro nastaveni maximalniho poctu odeslanych udalosti klientovi, ochrana pred zahlcenim klienta
parent 078fc14f
No related branches found
No related tags found
No related merge requests found
2012-00-00 v2.1 stable version 2012-00-00 v2.1 stable version
------------------------------ ------------------------------
- receiving of all types of messages now supported - add limit of events that can be downloaded from server to client
- add receiving of all types of messages
2012-07-27 v2.0 stable version 2012-07-27 v2.0 stable version
......
...@@ -157,6 +157,10 @@ C. Installation ...@@ -157,6 +157,10 @@ C. Installation
DB_HOST - MySQL database host DB_HOST - MySQL database host
e.g. localhost e.g. localhost
MAX_EVENT_LIMIT - maximum number of events that can be downloaded from Warden server
in a single getNewEvents client function call
e.g. 2000000
c) warden-apache.conf c) warden-apache.conf
The Apache2 configuration file for Warden server The Apache2 configuration file for Warden server
......
...@@ -33,16 +33,17 @@ our $DB_NAME = undef; ...@@ -33,16 +33,17 @@ our $DB_NAME = undef;
our $DB_USER = undef; our $DB_USER = undef;
our $DB_PASS = undef; our $DB_PASS = undef;
our $DB_HOST = undef; our $DB_HOST = undef;
our $MAX_EVENT_LIMIT = undef;
# read config file # read config file
if (!open( TMP, $conf_file)) { if (!open( TMP, $conf_file)) {
die errMsg("Can't read config file '$conf_file': $!\n"); errMsg("Can't read config file '$conf_file': $!\n");
} }
close TMP; close TMP;
# load set variables by user # load set variables by user
if (!do $conf_file) { if (!do $conf_file) {
die errMsg("Errors in config file '$conf_file': $@"); errMsg("Errors in config file '$conf_file': $@");
} }
...@@ -241,30 +242,30 @@ sub getNewEvents ...@@ -241,30 +242,30 @@ sub getNewEvents
my $client_type = "r"; # incoming client MUST be sender my $client_type = "r"; # incoming client MUST be sender
# parse SOAP data object # parse SOAP data object
my $requested_type = $data->{'REQUESTED_TYPE'}; my $requested_type = $data->{'REQUESTED_TYPE'};
my $last_id = $data->{'LAST_ID'}; my $last_id = $data->{'LAST_ID'};
my %client = authorizeClient($alt_names, $ip, $requested_type, $client_type, 'getNewEvents'); my %client = authorizeClient($alt_names, $ip, $requested_type, $client_type, 'getNewEvents');
if(defined %client) { if(defined %client) {
if ($client{'receive_own'} eq 't') { # check if client want your own events or not if ($client{'receive_own'} eq 't') { # check if client want your own events or not
if ($requested_type eq '_any_') { # check if client want each or only one type of messages if ($requested_type eq '_any_') { # check if client want each or only one type of messages
$sth = $DBH->prepare("SELECT * FROM events WHERE type != 'test' AND id > ? AND valid = 't' ORDER BY id ASC;"); $sth = $DBH->prepare("SELECT * FROM events WHERE type != 'test' AND id > ? AND valid = 't' ORDER BY id ASC limit $MAX_EVENT_LIMIT;");
if (!defined $sth) {die("Cannot prepare ROE-ANY statement in getNewEvents: $DBI::errstr\n")} if (!defined $sth) {die("Cannot prepare ROE-ANY statement in getNewEvents: $DBI::errstr\n")}
$sth->execute($last_id); $sth->execute($last_id);
} else { } else {
$sth = $DBH->prepare("SELECT * FROM events WHERE type != 'test' AND id > ? AND type = ? AND valid = 't' ORDER BY id ASC;"); $sth = $DBH->prepare("SELECT * FROM events WHERE type != 'test' AND id > ? AND type = ? AND valid = 't' ORDER BY id ASC limit $MAX_EVENT_LIMIT;");
if (!defined $sth) {die("Cannot prepare ROE statement in getNewEvents: $DBI::errstr\n")} if (!defined $sth) {die("Cannot prepare ROE statement in getNewEvents: $DBI::errstr\n")}
$sth->execute($last_id, $requested_type); $sth->execute($last_id, $requested_type);
} }
} else { } else {
if ($requested_type eq '_any_') { if ($requested_type eq '_any_') {
$sth = $DBH->prepare("SELECT * FROM events WHERE type != 'test' AND id > ? AND valid = 't' AND hostname NOT LIKE ? ORDER BY id ASC;"); $sth = $DBH->prepare("SELECT * FROM events WHERE type != 'test' AND id > ? AND valid = 't' AND hostname NOT LIKE ? ORDER BY id ASC limit $MAX_EVENT_LIMIT;");
if (!defined $sth) {die("Cannot prepare ANY statement in getNewEvents: $DBI::errstr\n")} if (!defined $sth) {die("Cannot prepare ANY statement in getNewEvents: $DBI::errstr\n")}
my ($domain) = $cn =~ /([^\.]+\.[^\.]+)$/; my ($domain) = $cn =~ /([^\.]+\.[^\.]+)$/;
$domain = '\%' . $domain; $domain = '\%' . $domain;
$sth->execute($last_id, $domain); $sth->execute($last_id, $domain);
} else { } else {
$sth = $DBH->prepare("SELECT * FROM events WHERE type != 'test' AND id > ? AND type = ? AND valid = 't' AND hostname NOT LIKE ? ORDER BY id ASC;"); $sth = $DBH->prepare("SELECT * FROM events WHERE type != 'test' AND id > ? AND type = ? AND valid = 't' AND hostname NOT LIKE ? ORDER BY id ASC limit $MAX_EVENT_LIMIT;");
if (!defined $sth) {die("Cannot prepare statement in getNewEvents: $DBI::errstr\n")} if (!defined $sth) {die("Cannot prepare statement in getNewEvents: $DBI::errstr\n")}
my ($domain) = $cn =~ /([^\.]+\.[^\.]+)$/; my ($domain) = $cn =~ /([^\.]+\.[^\.]+)$/;
$domain = '\%' . $domain; $domain = '\%' . $domain;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment